Write heuristics for perl, closes #550

This commit is contained in:
Adam Stankiewicz
2020-09-16 15:50:39 +02:00
parent 271679272c
commit 17c2b630e1
16 changed files with 1035 additions and 42 deletions

20
syntax/bzl.vim Normal file
View File

@@ -0,0 +1,20 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'bzl') == -1
" Vim syntax file
" Language: Bazel (http://bazel.io)
" Maintainer: David Barnett (https://github.com/google/vim-ft-bzl)
" Last Change: 2015 Aug 11
if exists('b:current_syntax')
finish
endif
runtime! syntax/python.vim
let b:current_syntax = 'bzl'
syn region bzlRule start='^\w\+($' end='^)\n*' transparent fold
syn region bzlList start='\[' end='\]' transparent fold
endif

122
syntax/prolog.vim Normal file
View File

@@ -0,0 +1,122 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'prolog') == -1
" Vim syntax file
" Language: PROLOG
" Maintainer: Anton Kochkov <anton.kochkov@gmail.com>
" Last Change: 2019 Aug 29
" There are two sets of highlighting in here:
" If the "prolog_highlighting_clean" variable exists, it is rather sparse.
" Otherwise you get more highlighting.
"
" You can also set the "prolog_highlighting_no_keyword" variable. If set,
" keywords will not be highlighted.
" quit when a syntax file was already loaded
if exists("b:current_syntax")
finish
endif
" Prolog is case sensitive.
syn case match
" Very simple highlighting for comments, clause heads and
" character codes. It respects prolog strings and atoms.
syn region prologCComment start=+/\*+ end=+\*/+
syn match prologComment +%.*+
if !exists("prolog_highlighting_no_keyword")
syn keyword prologKeyword module meta_predicate multifile dynamic
endif
syn match prologCharCode +0'\\\=.+
syn region prologString start=+"+ skip=+\\\\\|\\"+ end=+"+
syn region prologAtom start=+'+ skip=+\\\\\|\\'+ end=+'+
syn region prologClause matchgroup=prologClauseHead start=+^\s*[a-z]\w*+ matchgroup=Normal end=+\.\s\|\.$+ contains=ALLBUT,prologClause
if !exists("prolog_highlighting_clean")
" some keywords
" some common predicates are also highlighted as keywords
" is there a better solution?
if !exists("prolog_highlighting_no_keyword")
syn keyword prologKeyword abolish current_output peek_code
syn keyword prologKeyword append current_predicate put_byte
syn keyword prologKeyword arg current_prolog_flag put_char
syn keyword prologKeyword asserta fail put_code
syn keyword prologKeyword assertz findall read
syn keyword prologKeyword at_end_of_stream float read_term
syn keyword prologKeyword atom flush_output repeat
syn keyword prologKeyword atom_chars functor retract
syn keyword prologKeyword atom_codes get_byte set_input
syn keyword prologKeyword atom_concat get_char set_output
syn keyword prologKeyword atom_length get_code set_prolog_flag
syn keyword prologKeyword atomic halt set_stream_position
syn keyword prologKeyword bagof integer setof
syn keyword prologKeyword call is stream_property
syn keyword prologKeyword catch nl sub_atom
syn keyword prologKeyword char_code nonvar throw
syn keyword prologKeyword char_conversion number true
syn keyword prologKeyword clause number_chars unify_with_occurs_check
syn keyword prologKeyword close number_codes var
syn keyword prologKeyword compound once write
syn keyword prologKeyword copy_term op write_canonical
syn keyword prologKeyword current_char_conversion open write_term
syn keyword prologKeyword current_input peek_byte writeq
syn keyword prologKeyword current_op peek_char
endif
syn match prologOperator "=\\=\|=:=\|\\==\|=<\|==\|>=\|\\=\|\\+\|=\.\.\|<\|>\|="
syn match prologAsIs "===\|\\===\|<=\|=>"
syn match prologNumber "\<\d*\>'\@!"
syn match prologNumber "\<0[xX]\x*\>'\@!"
syn match prologCommentError "\*/"
syn match prologSpecialCharacter ";"
syn match prologSpecialCharacter "!"
syn match prologSpecialCharacter ":-"
syn match prologSpecialCharacter "-->"
syn match prologQuestion "?-.*\." contains=prologNumber
endif
syn sync maxlines=50
" Define the default highlighting.
" Only when an item doesn't have highlighting yet
" The default highlighting.
hi def link prologComment Comment
hi def link prologCComment Comment
hi def link prologCharCode Special
if exists ("prolog_highlighting_clean")
hi def link prologKeyword Statement
hi def link prologClauseHead Statement
hi def link prologClause Normal
else
hi def link prologKeyword Keyword
hi def link prologClauseHead Constant
hi def link prologClause Normal
hi def link prologQuestion PreProc
hi def link prologSpecialCharacter Special
hi def link prologNumber Number
hi def link prologAsIs Normal
hi def link prologCommentError Error
hi def link prologAtom String
hi def link prologString String
hi def link prologOperator Operator
endif
let b:current_syntax = "prolog"
" vim: ts=8
endif

175
syntax/tads.vim Normal file
View File

@@ -0,0 +1,175 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'tads') == -1
" Vim syntax file
" Language: TADS
" Maintainer: Amir Karger <karger@post.harvard.edu>
" $Date: 2004/06/13 19:28:45 $
" $Revision: 1.1 $
" Stolen from: Bram Moolenaar's C language file
" Newest version at: http://www.hec.utah.edu/~karger/vim/syntax/tads.vim
" History info at the bottom of the file
" TODO lots more keywords
" global, self, etc. are special *objects*, not functions. They should
" probably be a different color than the special functions
" Actually, should cvtstr etc. be functions?! (change tadsFunction)
" Make global etc. into Identifiers, since we don't have regular variables?
" quit when a syntax file was already loaded
if exists("b:current_syntax")
finish
endif
" A bunch of useful keywords
syn keyword tadsStatement goto break return continue pass
syn keyword tadsLabel case default
syn keyword tadsConditional if else switch
syn keyword tadsRepeat while for do
syn keyword tadsStorageClass local compoundWord formatstring specialWords
syn keyword tadsBoolean nil true
" TADS keywords
syn keyword tadsKeyword replace modify
syn keyword tadsKeyword global self inherited
" builtin functions
syn keyword tadsKeyword cvtstr cvtnum caps lower upper substr
syn keyword tadsKeyword say length
syn keyword tadsKeyword setit setscore
syn keyword tadsKeyword datatype proptype
syn keyword tadsKeyword car cdr
syn keyword tadsKeyword defined isclass
syn keyword tadsKeyword find firstobj nextobj
syn keyword tadsKeyword getarg argcount
syn keyword tadsKeyword input yorn askfile
syn keyword tadsKeyword rand randomize
syn keyword tadsKeyword restart restore quit save undo
syn keyword tadsException abort exit exitobj
syn keyword tadsTodo contained TODO FIXME XXX
" String and Character constants
" Highlight special characters (those which have a backslash) differently
syn match tadsSpecial contained "\\."
syn region tadsDoubleString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=tadsSpecial,tadsEmbedded
syn region tadsSingleString start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=tadsSpecial
" Embedded expressions in strings
syn region tadsEmbedded contained start="<<" end=">>" contains=tadsKeyword
" TADS doesn't have \xxx, right?
"syn match cSpecial contained "\\[0-7][0-7][0-7]\=\|\\."
"syn match cSpecialCharacter "'\\[0-7][0-7]'"
"syn match cSpecialCharacter "'\\[0-7][0-7][0-7]'"
"catch errors caused by wrong parenthesis
"syn region cParen transparent start='(' end=')' contains=ALLBUT,cParenError,cIncluded,cSpecial,cTodo,cUserCont,cUserLabel
"syn match cParenError ")"
"syn match cInParen contained "[{}]"
syn region tadsBrace transparent start='{' end='}' contains=ALLBUT,tadsBraceError,tadsIncluded,tadsSpecial,tadsTodo
syn match tadsBraceError "}"
"integer number (TADS has no floating point numbers)
syn case ignore
syn match tadsNumber "\<[0-9]\+\>"
"hex number
syn match tadsNumber "\<0x[0-9a-f]\+\>"
syn match tadsIdentifier "\<[a-z][a-z0-9_$]*\>"
syn case match
" flag an octal number with wrong digits
syn match tadsOctalError "\<0[0-7]*[89]"
" Removed complicated c_comment_strings
syn region tadsComment start="/\*" end="\*/" contains=tadsTodo
syn match tadsComment "//.*" contains=tadsTodo
syntax match tadsCommentError "\*/"
syn region tadsPreCondit start="^\s*#\s*\(if\>\|ifdef\>\|ifndef\>\|elif\>\|else\>\|endif\>\)" skip="\\$" end="$" contains=tadsComment,tadsString,tadsNumber,tadsCommentError
syn region tadsIncluded contained start=+"+ skip=+\\\\\|\\"+ end=+"+
syn match tadsIncluded contained "<[^>]*>"
syn match tadsInclude "^\s*#\s*include\>\s*["<]" contains=tadsIncluded
syn region tadsDefine start="^\s*#\s*\(define\>\|undef\>\)" skip="\\$" end="$" contains=ALLBUT,tadsPreCondit,tadsIncluded,tadsInclude,tadsDefine,tadsInBrace,tadsIdentifier
syn region tadsPreProc start="^\s*#\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" contains=ALLBUT,tadsPreCondit,tadsIncluded,tadsInclude,tadsDefine,tadsInParen,tadsIdentifier
" Highlight User Labels
" TODO labels for gotos?
"syn region cMulti transparent start='?' end=':' contains=ALLBUT,cIncluded,cSpecial,cTodo,cUserCont,cUserLabel,cBitField
" Avoid matching foo::bar() in C++ by requiring that the next char is not ':'
"syn match cUserCont "^\s*\I\i*\s*:$" contains=cUserLabel
"syn match cUserCont ";\s*\I\i*\s*:$" contains=cUserLabel
"syn match cUserCont "^\s*\I\i*\s*:[^:]" contains=cUserLabel
"syn match cUserCont ";\s*\I\i*\s*:[^:]" contains=cUserLabel
"syn match cUserLabel "\I\i*" contained
" identifier: class-name [, class-name [...]] [property-list] ;
" Don't highlight comment in class def
syn match tadsClassDef "\<class\>[^/]*" contains=tadsObjectDef,tadsClass
syn match tadsClass contained "\<class\>"
syn match tadsObjectDef "\<[a-zA-Z][a-zA-Z0-9_$]*\s*:\s*[a-zA-Z0-9_$]\+\(\s*,\s*[a-zA-Z][a-zA-Z0-9_$]*\)*\(\s*;\)\="
syn keyword tadsFunction contained function
syn match tadsFunctionDef "\<[a-zA-Z][a-zA-Z0-9_$]*\s*:\s*function[^{]*" contains=tadsFunction
"syn region tadsObject transparent start = '[a-zA-Z][\i$]\s*:\s*' end=";" contains=tadsBrace,tadsObjectDef
" How far back do we go to find matching groups
if !exists("tads_minlines")
let tads_minlines = 15
endif
exec "syn sync ccomment tadsComment minlines=" . tads_minlines
if !exists("tads_sync_dist")
let tads_sync_dist = 100
endif
execute "syn sync maxlines=" . tads_sync_dist
" Define the default highlighting.
" Only when an item doesn't have highlighting yet
" The default methods for highlighting. Can be overridden later
hi def link tadsFunctionDef Function
hi def link tadsFunction Structure
hi def link tadsClass Structure
hi def link tadsClassDef Identifier
hi def link tadsObjectDef Identifier
" no highlight for tadsEmbedded, so it prints as normal text w/in the string
hi def link tadsOperator Operator
hi def link tadsStructure Structure
hi def link tadsTodo Todo
hi def link tadsLabel Label
hi def link tadsConditional Conditional
hi def link tadsRepeat Repeat
hi def link tadsException Exception
hi def link tadsStatement Statement
hi def link tadsStorageClass StorageClass
hi def link tadsKeyWord Keyword
hi def link tadsSpecial SpecialChar
hi def link tadsNumber Number
hi def link tadsBoolean Boolean
hi def link tadsDoubleString tadsString
hi def link tadsSingleString tadsString
hi def link tadsOctalError tadsError
hi def link tadsCommentError tadsError
hi def link tadsBraceError tadsError
hi def link tadsInBrace tadsError
hi def link tadsError Error
hi def link tadsInclude Include
hi def link tadsPreProc PreProc
hi def link tadsDefine Macro
hi def link tadsIncluded tadsString
hi def link tadsPreCondit PreCondit
hi def link tadsString String
hi def link tadsComment Comment
let b:current_syntax = "tads"
" Changes:
" 11/18/99 Added a bunch of TADS functions, tadsException
" 10/22/99 Misspelled Moolenaar (sorry!), c_minlines to tads_minlines
"
" vim: ts=8
endif