xref: /vim-8.2.3635/runtime/syntax/pike.vim (revision 40962ec9)
1071d4279SBram Moolenaar" Vim syntax file
2071d4279SBram Moolenaar" Language:		Pike
3*40962ec9SBram Moolenaar" Maintainer:		Stephen R. van den Berg <[email protected]>
4*40962ec9SBram Moolenaar" Maintainer of previous implementation: Francesco Chemolli <[email protected]>
5*40962ec9SBram Moolenaar" Last Change:		2018 Jan 28
6*40962ec9SBram Moolenaar" Version:		2.9
7*40962ec9SBram Moolenaar" Remark: Derived from the C-syntax; fixed several bugs in the C-syntax
8*40962ec9SBram Moolenaar" Remark: and extended it with the Pike syntax.
9*40962ec9SBram Moolenaar" Remark: Includes a highlighter for all Pike types of parenthesis errors.
10*40962ec9SBram Moolenaar" Remark: Includes a highlighter for SQL on multiline strings.
11*40962ec9SBram Moolenaar" Remark: Includes a highlighter for any embedded Autodoc format.
12071d4279SBram Moolenaar
13*40962ec9SBram Moolenaar" Quit when a (custom) syntax file was already loaded
1489bcfda6SBram Moolenaarif exists("b:current_syntax")
15071d4279SBram Moolenaar  finish
16071d4279SBram Moolenaarendif
17071d4279SBram Moolenaar
18*40962ec9SBram Moolenaarlet s:cpo_save = &cpo
19*40962ec9SBram Moolenaarset cpo&vim
20*40962ec9SBram Moolenaar
21*40962ec9SBram Moolenaar" For multiline strings, try formatting them as SQL
22*40962ec9SBram Moolenaarsyn include @pikeSQL <sfile>:p:h/sqloracle.vim
23*40962ec9SBram Moolenaarunlet b:current_syntax
24*40962ec9SBram Moolenaar
25*40962ec9SBram Moolenaar" For embedded Autodoc documentation (WIP)
26*40962ec9SBram Moolenaarsyn include @pikeAutodoc <sfile>:p:h/autodoc.vim
27*40962ec9SBram Moolenaarunlet b:current_syntax
28*40962ec9SBram Moolenaar
29*40962ec9SBram Moolenaarsyn case match
30*40962ec9SBram Moolenaar
31*40962ec9SBram Moolenaar" Supports array, multiset, mapping multi-character delimiter matching
32*40962ec9SBram Moolenaar" Supports rotating amongst several same-level preprocessor conditionals
33*40962ec9SBram Moolenaarpackadd! matchit
34*40962ec9SBram Moolenaarlet b:match_words = "({:}\\@1<=),(\\[:]\\@1<=),(<:>\\@1<=),^\s*#\s*\%(if\%(n\?def\)\|else\|el\%(se\)\?if\|endif\)\>"
35*40962ec9SBram Moolenaar
36*40962ec9SBram Moolenaar" A bunch of useful Pike keywords
37*40962ec9SBram Moolenaarsyn keyword	pikeDebug	gauge backtrace describe_backtrace werror _Static_assert static_assert
38*40962ec9SBram Moolenaarsyn keyword	pikeException	error catch throw
39*40962ec9SBram Moolenaarsyn keyword	pikeLabel	case default break return continue
40071d4279SBram Moolenaarsyn keyword	pikeConditional	if else switch
41071d4279SBram Moolenaarsyn keyword	pikeRepeat	while for foreach do
42071d4279SBram Moolenaar
43*40962ec9SBram Moolenaarsyn keyword pikePredef RegGetKeyNames RegGetValue RegGetValues
44*40962ec9SBram Moolenaarsyn keyword pikePredef __automap__ __empty_program
45*40962ec9SBram Moolenaarsyn keyword pikePredef __handle_sprintf_format __parse_pike_type _disable_threads
46*40962ec9SBram Moolenaarsyn keyword pikePredef _do_call_outs _exit _gdb_breakpoint
47*40962ec9SBram Moolenaarsyn keyword pikePredef abs access acos acosh add_constant alarm all_constants
48*40962ec9SBram Moolenaarsyn keyword pikePredef array_sscanf asin asinh atan atan2 atanh atexit
49*40962ec9SBram Moolenaarsyn keyword pikePredef basetype call_function call_out call_out_info cd ceil
50*40962ec9SBram Moolenaarsyn keyword pikePredef combine_path combine_path_nt
51*40962ec9SBram Moolenaarsyn keyword pikePredef combine_path_unix compile copy_value cos cosh cpp crypt
52*40962ec9SBram Moolenaarsyn keyword pikePredef ctime decode_value delay encode_value encode_value_canonic
53*40962ec9SBram Moolenaarsyn keyword pikePredef enumerate errno exece exit exp file_stat file_truncate
54*40962ec9SBram Moolenaarsyn keyword pikePredef filesystem_stat find_call_out floor fork function_name
55*40962ec9SBram Moolenaarsyn keyword pikePredef function_object function_program gc
56*40962ec9SBram Moolenaarsyn keyword pikePredef get_active_compilation_handler get_active_error_handler
57*40962ec9SBram Moolenaarsyn keyword pikePredef get_all_groups get_all_users get_dir get_groups_for_user
58*40962ec9SBram Moolenaarsyn keyword pikePredef get_iterator get_profiling_info get_weak_flag getcwd
59*40962ec9SBram Moolenaarsyn keyword pikePredef getgrgid getgrnam gethrdtime gethrtime gethrvtime getpid
60*40962ec9SBram Moolenaarsyn keyword pikePredef getpwnam getpwuid getxattr glob gmtime has_index has_prefix
61*40962ec9SBram Moolenaarsyn keyword pikePredef has_suffix has_value hash hash_7_0 hash_7_4 hash_8_0
62*40962ec9SBram Moolenaarsyn keyword pikePredef hash_value kill limit listxattr load_module localtime
63*40962ec9SBram Moolenaarsyn keyword pikePredef log lower_case master max min mkdir mktime mv
64*40962ec9SBram Moolenaarsyn keyword pikePredef object_program pow query_num_arg random_seed
65*40962ec9SBram Moolenaarsyn keyword pikePredef remove_call_out removexattr replace_master rm round
66*40962ec9SBram Moolenaarsyn keyword pikePredef set_priority set_weak_flag setxattr sgn signal signame
67*40962ec9SBram Moolenaarsyn keyword pikePredef signum sin sinh sleep sort sprintf sqrt sscanf strerror
68*40962ec9SBram Moolenaarsyn keyword pikePredef string_filter_non_unicode string_to_unicode string_to_utf8
69*40962ec9SBram Moolenaarsyn keyword pikePredef tan tanh time trace types ualarm unicode_to_string
70*40962ec9SBram Moolenaarsyn keyword pikePredef upper_case utf8_to_string version
71*40962ec9SBram Moolenaar
72*40962ec9SBram Moolenaarsyn keyword pikePredef write lock try_lock
73*40962ec9SBram Moolenaarsyn keyword pikePredef MutexKey Timestamp Date Time TimeTZ Interval Inet Range
74*40962ec9SBram Moolenaarsyn keyword pikePredef Null null inf nan
75071d4279SBram Moolenaar
76071d4279SBram Moolenaarsyn keyword	pikeTodo		contained TODO FIXME XXX
77071d4279SBram Moolenaar
78*40962ec9SBram Moolenaar" Match parengroups: allows for highlighting indices of mappings and
79*40962ec9SBram Moolenaar" highlighting semicolons that are out of place due to a paren imbalance
80*40962ec9SBram Moolenaarsyn cluster	pikePreShort	contains=pikeDefine,pikePreProc,pikeCppOutWrapper,pikeCppInWrapper,pikePreCondit,pikePreConditMatch
81*40962ec9SBram Moolenaarsyn cluster	pikeExprGroup	contains=pikeMappIndex,@pikeStmt,pikeNest,@pikeBadGroup,pikeSoftCast
82*40962ec9SBram Moolenaarsyn match	pikeWord	transparent contained /[^()'"[\]{},;:]\+/ contains=ALLBUT,@pikePreProcGroup,@pikeExprGroup
83*40962ec9SBram Moolenaarsyn match	pikeFirstWord	transparent display contained /^\s*#[^()'"[\]{},;:]\+/ contains=@pikePreShort
84*40962ec9SBram Moolenaarsyn cluster	pikeMappElm	contains=pikeMappIndex,@pikeStmt
85*40962ec9SBram Moolenaarsyn cluster	pikeStmt	contains=pikeFirstWord,pikeCharacter,pikeString,pikeMlString,pikeWord,pikeNest
86*40962ec9SBram Moolenaarsyn cluster     pikeBadGroup	contains=pikeBadPClose,pikeBadAClose,pikeBadBClose,pikeBadSPClose,pikeBadSAClose,pikeBadSBClose,pikeBadSClose,pikeBadSPAClose,pikeBadSBAClose
87*40962ec9SBram Moolenaarsyn match	pikeBadPClose	display contained "[}\]]"
88*40962ec9SBram Moolenaarsyn match	pikeBadAClose	display contained "[)\]]"
89*40962ec9SBram Moolenaarsyn match	pikeBadBClose	display contained "[)}]"
90*40962ec9SBram Moolenaarsyn match	pikeBadSPClose	display contained "[;}\]]"
91*40962ec9SBram Moolenaarsyn match	pikeBadSAClose	display contained "[;)\]]"
92*40962ec9SBram Moolenaarsyn match	pikeBadSPAClose	display contained "[;\]]"
93*40962ec9SBram Moolenaarsyn match	pikeBadSBAClose	display contained "[;}]"
94*40962ec9SBram Moolenaarsyn match	pikeBadSClose	display contained "[;)}\]]"
95*40962ec9SBram Moolenaarsyn region	pikeNest	transparent start="(\@1<!{" end="}" contains=@pikeStmt,pikeUserLabel,pikeBadAClose
96*40962ec9SBram Moolenaarsyn region	pikeNest	transparent start="\%(\<for\%(each\)\?\s\?\)\@8<!([[{<]\@!" end=")" contains=@pikeStmt,pikeBadSPClose
97*40962ec9SBram Moolenaarsyn region	pikeNest	transparent start="\%(\<for\%(each\)\?\s\?\)\@8<=(" end=")" contains=@pikeStmt,pikeBadPClose
98*40962ec9SBram Moolenaarsyn region	pikeNest	transparent start="(\@1<!\[" end="]" contains=@pikeStmt,pikeBadSBClose
99*40962ec9SBram Moolenaarsyn region	pikeNest	transparent start="(\zs\[" end="])" contains=@pikeMappElm,pikeBadSBAClose
100*40962ec9SBram Moolenaar" For some reason specifying a matchgroup on the pikeNest below makes it
101*40962ec9SBram Moolenaar" override the shorter variant; consider it a kludge, no idea why it works
102*40962ec9SBram Moolenaarsyn region	pikeNest	transparent matchgroup=pikeSoftCast start=%(\zs\[[ \t\v\r\n.a-zA-Z0-9_():,|]\+])\@!% end=")" contains=@pikeStmt
103*40962ec9SBram Moolenaarsyn region	pikeNest	transparent start="(\zs{" end="})" contains=@pikeStmt,pikeBadSPAClose
104*40962ec9SBram Moolenaarsyn region	pikeNest	transparent start="(\zs<" end=">)" contains=@pikeStmt,pikeBadSPClose keepend
105*40962ec9SBram Moolenaar
106*40962ec9SBram Moolenaar" It's easy to accidentally add a space after a backslash that was intended
107*40962ec9SBram Moolenaar" for line continuation.  Some compilers allow it, which makes it
108*40962ec9SBram Moolenaar" unpredictable and should be avoided.
109*40962ec9SBram Moolenaarsyn match	pikeBadContinuation contained "\\\s\+$"
110*40962ec9SBram Moolenaar
111*40962ec9SBram Moolenaar" pikeCommentGroup allows adding matches for special things in comments
112*40962ec9SBram Moolenaarsyn cluster	pikeCommentGroup	contains=pikeTodo,pikeBadContinuation
113*40962ec9SBram Moolenaar
114071d4279SBram Moolenaar" String and Character constants
115071d4279SBram Moolenaar" Highlight special characters (those which have a backslash) differently
116*40962ec9SBram Moolenaarsyn match	pikeSpecial	display contained "\\\%(x\x*\|d\d*\|\o\+\|u\x\{4}\|U\x\{8}\|[abefnrtv]\|$\)"
117071d4279SBram Moolenaar
118*40962ec9SBram Moolenaar" ISO C11 or ISO C++ 11
119*40962ec9SBram Moolenaarif !exists("c_no_cformat")
120*40962ec9SBram Moolenaar  " Highlight % items in strings.
121*40962ec9SBram Moolenaar  syn match	pikeFormat		display "%\%(\d\+\$\)\=[-+' #0*]*\%(\d*\|\*\|\*\d\+\$\)\%(\.\%(\d*\|\*\|\*\d\+\$\)\)\=\%([hlLjzt]\|ll\|hh\)\=\%([aAbdiuoxXDOUfFeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained
122*40962ec9SBram Moolenaar  syn match	pikeFormat		display "%%" contained
123*40962ec9SBram Moolenaar  syn region 	pikeString		start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=pikeSpecial,pikeDelimiterDQ,pikeFormat,@Spell keepend
124*40962ec9SBram Moolenaar  syn region	pikeMlString	start=+#"+ skip=+\\\\\|\\"+ end=+"+ contains=pikeSpecial,pikeFormat,pikeDelimiterDQ,@Spell,pikeEmbeddedString keepend
125*40962ec9SBram Moolenaarelse
126*40962ec9SBram Moolenaar  syn region 	pikeString		start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=pikeSpecial,pikeDelimiterDQ,@Spell
127*40962ec9SBram Moolenaar  syn region	pikeMlString	transparent start=+#"+ skip=+\\\\\|\\"+ end=+"+ contains=pikeSpecial,pikeDelimiterDQ,@Spell,pikeEmbeddedString keepend
128*40962ec9SBram Moolenaarendif
129071d4279SBram Moolenaar
130*40962ec9SBram Moolenaar" Use SQL-syntax highlighting in multiline string if it starts with
131*40962ec9SBram Moolenaar" a standard SQL keyword
132*40962ec9SBram Moolenaarsyn case ignore
133*40962ec9SBram Moolenaar" FIXME Use explicit newline match to cover up a bug in the regexp engine
134*40962ec9SBram Moolenaar" If the kludge is not used, the match will only start unless at least a space
135*40962ec9SBram Moolenaar" follows the initial doublequote on the first line (or the keyword is on
136*40962ec9SBram Moolenaar" the first line).
137*40962ec9SBram Moolenaarsyn region	pikeEmbeddedString	contained start=+\%(#"\n\?\)\@2<=\_s*\%(SELECT\|INSERT\|UPDATE\|DELETE\|WITH\|CREATE\|DROP\|ALTER\)\>+ skip=+\\\\\|\\"+ end=+[\\#]\@1<!"+ contains=@pikeSQL,pikeBindings keepend
138*40962ec9SBram Moolenaarsyn case match
139*40962ec9SBram Moolenaar
140*40962ec9SBram Moolenaarsyn match	pikeBindings	display contained ":\@1<!:\I\i*"
141*40962ec9SBram Moolenaar
142*40962ec9SBram Moolenaarsyn match	pikeCharacter	"'[^\\']'" contains=pikeDelimiterSQ
143*40962ec9SBram Moolenaarsyn match	pikeCharacter	"'[^']*'" contains=pikeSpecial,pikeDelimiterSQ
144*40962ec9SBram Moolenaarsyn match	pikeSpecialError	"'\\[^'\"?\\abefnrtv]'"
145*40962ec9SBram Moolenaarsyn match	pikeDelimiterDQ	display +"+ contained
146*40962ec9SBram Moolenaarsyn match	pikeDelimiterSQ	display +'+ contained
147*40962ec9SBram Moolenaar
148*40962ec9SBram Moolenaar"when wanted, highlight trailing white space
149*40962ec9SBram Moolenaarif exists("c_space_errors")
150*40962ec9SBram Moolenaar  if !exists("c_no_trail_space_error")
151*40962ec9SBram Moolenaar    syn match	pikeSpaceError	display excludenl "\s\+$"
152*40962ec9SBram Moolenaar  endif
153*40962ec9SBram Moolenaar  if !exists("c_no_tab_space_error")
154*40962ec9SBram Moolenaar    syn match	pikeSpaceError	display " \+\ze\t"
155*40962ec9SBram Moolenaar  endif
156*40962ec9SBram Moolenaarendif
157071d4279SBram Moolenaar
158071d4279SBram Moolenaar"integer number, or floating point number without a dot and with "f".
159071d4279SBram Moolenaarsyn case ignore
160*40962ec9SBram Moolenaarsyn match	pikeNumbers	display transparent "\<\d\|\.\d" contains=pikeNumber,pikeFloat,pikeOctalError,pikeOctal
161*40962ec9SBram Moolenaar" Same, but without octal error (for comments)
162*40962ec9SBram Moolenaarsyn match	pikeNumbersCom	display contained transparent "\<\d\|\.\d" contains=pikeNumber,pikeFloat,pikeOctal
163*40962ec9SBram Moolenaarsyn match	pikeNumber		display contained "\<\d\+\%(u\=l\{0,2}\|ll\=u\)\>"
164071d4279SBram Moolenaar"hex number
165*40962ec9SBram Moolenaarsyn match	pikeNumber		display contained "\<0x\x\+\%(u\=l\{0,2}\|ll\=u\)\>"
166*40962ec9SBram Moolenaar" Flag the first zero of an octal number as something special
167*40962ec9SBram Moolenaarsyn match	pikeOctal		display contained "\<0\o\+\%(u\=l\{0,2}\|ll\=u\)\>" contains=pikeOctalZero
168*40962ec9SBram Moolenaarsyn match	pikeOctalZero	display contained "\<0"
169*40962ec9SBram Moolenaar"floating point number, with dot, optional exponent
170*40962ec9SBram Moolenaarsyn match	pikeFloat		display contained "\<\d\+\%(f\|\.[0-9.]\@!\d*\%(e[-+]\=\d\+\)\=[fl]\=\)"
171*40962ec9SBram Moolenaar"floating point number, starting with a dot, optional exponent
172*40962ec9SBram Moolenaarsyn match	pikeFloat		display contained "[0-9.]\@1<!\.\d\+\%(e[-+]\=\d\+\)\=[fl]\=\>"
173*40962ec9SBram Moolenaar"floating point number, without dot, with exponent
174*40962ec9SBram Moolenaarsyn match	pikeFloat		display contained "\<\d\+e[-+]\=\d\+[fl]\=\>"
175*40962ec9SBram Moolenaar
176*40962ec9SBram Moolenaar"hexadecimal floating point number, two variants, with exponent
177*40962ec9SBram Moolenaarsyn match	pikeFloat		display contained "\<0x\%(\x\+\.\?\|\x*\.\x\+\)p[-+]\=\d\+[fl]\=\>"
178*40962ec9SBram Moolenaar
179071d4279SBram Moolenaar" flag an octal number with wrong digits
180*40962ec9SBram Moolenaarsyn match	pikeOctalError	display contained "\<0\o*[89]\d*"
181*40962ec9SBram Moolenaarsyn case match
182071d4279SBram Moolenaar
183071d4279SBram Moolenaarif exists("c_comment_strings")
184071d4279SBram Moolenaar  " A comment can contain pikeString, pikeCharacter and pikeNumber.
185071d4279SBram Moolenaar  " But a "*/" inside a pikeString in a pikeComment DOES end the comment!  So we
186071d4279SBram Moolenaar  " need to use a special type of pikeString: pikeCommentString, which also ends on
187071d4279SBram Moolenaar  " "*/", and sees a "*" at the start of the line as comment again.
188071d4279SBram Moolenaar  " Unfortunately this doesn't very well work for // type of comments :-(
189*40962ec9SBram Moolenaar  syn match	pikeCommentSkip	contained "^\s*\*\%($\|\s\+\)"
190*40962ec9SBram Moolenaar  syn region pikeCommentString	contained start=+\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end=+\ze\*/+ contains=pikeSpecial,pikeCommentSkip
191*40962ec9SBram Moolenaar  syn region pikeComment2String	contained start=+\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end="$" contains=pikeSpecial
192*40962ec9SBram Moolenaar  syn region  pikeCommentL	start="//" skip="\\$" end="$" keepend contains=@pikeCommentGroup,pikeComment2String,pikeCharacter,pikeNumbersCom,pikeSpaceError,@Spell containedin=pikeWord,pikeFirstWord
193*40962ec9SBram Moolenaar  if exists("c_no_comment_fold")
194*40962ec9SBram Moolenaar    " Use "extend" here to have preprocessor lines not terminate halfway a
195*40962ec9SBram Moolenaar    " comment.
196*40962ec9SBram Moolenaar    syn region pikeComment	matchgroup=pikeCommentStart start="/\*" end="\*/" contains=@pikeCommentGroup,pikeCommentStartError,pikeCommentString,pikeCharacter,pikeNumbersCom,pikeSpaceError,@Spell extend containedin=pikeWord,pikeFirstWord
197071d4279SBram Moolenaar  else
198*40962ec9SBram Moolenaar    syn region pikeComment	matchgroup=pikeCommentStart start="/\*" end="\*/" contains=@pikeCommentGroup,pikeCommentStartError,pikeCommentString,pikeCharacter,pikeNumbersCom,pikeSpaceError,@Spell fold extend containedin=pikeWord,pikeFirstWord
199071d4279SBram Moolenaar  endif
200*40962ec9SBram Moolenaarelse
201*40962ec9SBram Moolenaar  syn region	pikeCommentL	start="//" skip="\\$" end="$" keepend contains=@pikeCommentGroup,pikeSpaceError,@Spell containedin=pikeWord,pikeFirstWord
202*40962ec9SBram Moolenaar  if exists("c_no_comment_fold")
203*40962ec9SBram Moolenaar    syn region	pikeComment	matchgroup=pikeCommentStart start="/\*" end="\*/" contains=@pikeCommentGroup,pikeCommentStartError,pikeSpaceError,@Spell extend containedin=pikeWord,pikeFirstWord
204*40962ec9SBram Moolenaar  else
205*40962ec9SBram Moolenaar    syn region	pikeComment	matchgroup=pikeCommentStart start="/\*" end="\*/" contains=@pikeCommentGroup,pikeCommentStartError,pikeSpaceError,@Spell fold extend containedin=pikeWord,pikeFirstWord
206*40962ec9SBram Moolenaar  endif
207*40962ec9SBram Moolenaarendif
208*40962ec9SBram Moolenaar" keep a // comment separately, it terminates a preproc. conditional
209*40962ec9SBram Moolenaarsyn match	pikeCommentError	display "\*/"
210*40962ec9SBram Moolenaarsyn match	pikeCommentStartError display "/\ze\*" contained
211071d4279SBram Moolenaar
212071d4279SBram Moolenaarsyn keyword	pikeOperator	sizeof
213*40962ec9SBram Moolenaarsyn keyword	pikeOperator	typeof _typeof _refs
214*40962ec9SBram Moolenaarsyn keyword	pikeOperator	zero_type intp stringp arrayp mappingp multisetp
215*40962ec9SBram Moolenaarsyn keyword	pikeOperator	objectp functionp programp callablep destructedp
216*40962ec9SBram Moolenaarsyn keyword	pikeOperator	object_variablep undefinedp
217*40962ec9SBram Moolenaarsyn keyword	pikeOperator	allocate equal
218*40962ec9SBram Moolenaarsyn keyword	pikeOperator	aggregate aggregate_mapping aggregate_multiset
219*40962ec9SBram Moolenaarsyn keyword	pikeOperator	map filter search replace reverse column rows
220*40962ec9SBram Moolenaarsyn keyword	pikeOperator	indices values mkmapping mkmultiset m_delete sort
221*40962ec9SBram Moolenaarsyn keyword	pikeOperator	m_delete destruct
222*40962ec9SBram Moolenaarsyn keyword	pikeOperator	create _destruct _sprintf cast _encode _decode
223*40962ec9SBram Moolenaarsyn keyword     pikeOperator    __hash _sizeof _values _indices __INIT _equal
224*40962ec9SBram Moolenaarsyn keyword     pikeOperator    _is_type _m_delete _get_iterator _search
225*40962ec9SBram Moolenaarsyn keyword     pikeOperator    _serialize _deserialize _sqrt _types _random
226*40962ec9SBram Moolenaarsyn keyword     pikeOperator    _size_object
227071d4279SBram Moolenaar
228*40962ec9SBram Moolenaarsyn keyword	pikeType		int void
229*40962ec9SBram Moolenaarsyn keyword	pikeType		float
230*40962ec9SBram Moolenaarsyn keyword	pikeType		bool string array mapping multiset mixed
231*40962ec9SBram Moolenaarsyn keyword	pikeType		object function program auto
232*40962ec9SBram Moolenaar
233*40962ec9SBram Moolenaarsyn keyword	pikeType		this this_object this_program
234*40962ec9SBram Moolenaarsyn keyword	pikeType		sprintf_args sprintf_format sprintf_result
235*40962ec9SBram Moolenaarsyn keyword	pikeType		strict_sprintf_format
236*40962ec9SBram Moolenaar
237*40962ec9SBram Moolenaarsyn keyword	pikeStructure		class enum typedef inherit import
238*40962ec9SBram Moolenaarsyn keyword	pikeTypedef		typedef
239*40962ec9SBram Moolenaarsyn keyword	pikeStorageClass	private protected public constant final variant
240*40962ec9SBram Moolenaarsyn keyword	pikeStorageClass	optional inline extern static __deprecated__ lambda
241*40962ec9SBram Moolenaar
242*40962ec9SBram Moolenaarsyn keyword pikeConstant __LINE__ __FILE__ __DIR__ __DATE__ __TIME__
243*40962ec9SBram Moolenaarsyn keyword pikeConstant __AUTO_BIGNUM__ __NT__
244*40962ec9SBram Moolenaarsyn keyword pikeConstant __BUILD__ __COUNTER__ _MAJOR__ __MINOR__ __VERSION__
245*40962ec9SBram Moolenaarsyn keyword pikeConstant __REAL_BUILD__ _REAL_MAJOR__ __REAL_MINOR__
246*40962ec9SBram Moolenaarsyn keyword pikeConstant __REAL_VERSION__ __PIKE__ UNDEFINED
247*40962ec9SBram Moolenaar
248*40962ec9SBram Moolenaar" These should actually only be parsed in preprocessor conditionals
249*40962ec9SBram Moolenaarsyn keyword pikeCppOperator contained defined constant efun _Pragma
250*40962ec9SBram Moolenaar
251*40962ec9SBram Moolenaarsyn keyword pikeBoolean true false
252*40962ec9SBram Moolenaar
253*40962ec9SBram Moolenaarsyn match       pikeCppPrefix	display "^\s*\zs#\s*[a-z]\+" contained
254*40962ec9SBram Moolenaarsyn region	pikePreCondit	start="^\s*#\s*\%(if\%(n\?def\)\?\|el\%(se\)\?if\)\>" skip="\\$" end="$" transparent keepend contains=pikeString,pikeCharacter,pikeNumbers,pikeCommentError,pikeSpaceError,pikeCppOperator,pikeCppPrefix
255*40962ec9SBram Moolenaarsyn match	pikePreConditMatch	display "^\s*\zs#\s*\%(else\|endif\)\>"
256*40962ec9SBram Moolenaarif !exists("c_no_if0")
257*40962ec9SBram Moolenaar  syn cluster	pikeCppOutInGroup	contains=pikeCppInIf,pikeCppInElse,pikeCppInElse2,pikeCppOutIf,pikeCppOutIf2,pikeCppOutElse,pikeCppInSkip,pikeCppOutSkip
258*40962ec9SBram Moolenaar  syn region	pikeCppOutWrapper	start="^\s*\zs#\s*if\s\+0\+\s*\%($\|//\|/\*\|&\)" end=".\@=\|$" contains=pikeCppOutIf,pikeCppOutElse,@NoSpell fold
259*40962ec9SBram Moolenaar  syn region	pikeCppOutIf	contained start="0\+" matchgroup=pikeCppOutWrapper end="^\s*#\s*endif\>" contains=pikeCppOutIf2,pikeCppOutElse
260*40962ec9SBram Moolenaar  if !exists("c_no_if0_fold")
261*40962ec9SBram Moolenaar    syn region	pikeCppOutIf2	contained matchgroup=pikeCppOutWrapper start="0\+" end="^\ze\s*#\s*\%(else\>\|el\%(se\)\?if\s\+\%(0\+\s*\%($\|//\|/\*\|&\)\)\@!\|endif\>\)" contains=pikeSpaceError,pikeCppOutSkip,@Spell fold
262*40962ec9SBram Moolenaar  else
263*40962ec9SBram Moolenaar    syn region	pikeCppOutIf2	contained matchgroup=pikeCppOutWrapper start="0\+" end="^\ze\s*#\s*\%(else\>\|el\%(se\)\?if\s\+\%(0\+\s*\%($\|//\|/\*\|&\)\)\@!\|endif\>\)" contains=pikeSpaceError,pikeCppOutSkip,@Spell
264*40962ec9SBram Moolenaar  endif
265*40962ec9SBram Moolenaar  syn region	pikeCppOutElse	contained matchgroup=pikeCppOutWrapper start="^\s*#\s*\%(else\|el\%(se\)\?if\)" end="^\s*#\s*endif\>" contains=TOP,pikePreCondit
266*40962ec9SBram Moolenaar  syn region	pikeCppInWrapper	start="^\s*\zs#\s*if\s\+0*[1-9]\d*\s*\%($\|//\|/\*\||\)" end=".\@=\|$" contains=pikeCppInIf,pikeCppInElse fold
267*40962ec9SBram Moolenaar  syn region	pikeCppInIf	contained matchgroup=pikeCppInWrapper start="\d\+" end="^\s*#\s*endif\>" contains=TOP,pikePreCondit
268*40962ec9SBram Moolenaar  if !exists("c_no_if0_fold")
269*40962ec9SBram Moolenaar    syn region	pikeCppInElse	contained start="^\s*#\s*\%(else\>\|el\%(se\)\?if\s\+\%(0*[1-9]\d*\s*\%($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=pikeCppInIf contains=pikeCppInElse2 fold
270*40962ec9SBram Moolenaar  else
271*40962ec9SBram Moolenaar    syn region	pikeCppInElse	contained start="^\s*#\s*\%(else\>\|el\%(se\)\?if\s\+\%(0*[1-9]\d*\s*\%($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=pikeCppInIf contains=pikeCppInElse2
272*40962ec9SBram Moolenaar  endif
273*40962ec9SBram Moolenaar  syn region	pikeCppInElse2	contained matchgroup=pikeCppInWrapper start="^\s*#\s*\%(else\|el\%(se\)\?if\)\%([^/]\|/[^/*]\)*" end="^\ze\s*#\s*endif\>" contains=pikeSpaceError,pikeCppOutSkip,@Spell
274*40962ec9SBram Moolenaar  syn region	pikeCppOutSkip	contained start="^\s*#\s*if\%(n\?def\)\?\>" skip="\\$" end="^\s*#\s*endif\>" contains=pikeSpaceError,pikeCppOutSkip
275*40962ec9SBram Moolenaar  syn region	pikeCppInSkip	contained matchgroup=pikeCppInWrapper start="^\s*#\s*\%(if\s\+\%(\d\+\s*\%($\|//\|/\*\||\|&\)\)\@!\|ifn\?def\>\)" skip="\\$" end="^\s*#\s*endif\>" containedin=pikeCppOutElse,pikeCppInIf,pikeCppInSkip contains=TOP,pikePreProc
276*40962ec9SBram Moolenaarendif
277*40962ec9SBram Moolenaarsyn region	pikeIncluded	display contained start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=pikeDelimiterDQ keepend
278*40962ec9SBram Moolenaarsyn match	pikeIncluded	display contained "<[^>]*>"
279*40962ec9SBram Moolenaarsyn match	pikeInclude	display "^\s*\zs#\s*include\>\s*["<]" contains=pikeIncluded
280*40962ec9SBram Moolenaarsyn cluster	pikePreProcGroup	contains=pikeIncluded,pikeInclude,pikeEmbeddedString,pikeCppOutWrapper,pikeCppInWrapper,@pikeCppOutInGroup,pikeFormat,pikeMlString,pikeCommentStartError,@pikeBadGroup,pikeWord
281*40962ec9SBram Moolenaarsyn region	pikeDefine		start="^\s*\zs#\s*\%(define\|undef\)\>" skip="\\$" end="$" keepend contains=@pikeStmt,@pikeBadGroup
282*40962ec9SBram Moolenaarsyn region	pikePreProc	start="^\s*\zs#\s*\%(pragma\|charset\|pike\|require\|string\|line\|warning\|error\)\>" skip="\\$" end="$" transparent keepend contains=pikeString,pikeCharacter,pikeNumbers,pikeCommentError,pikeSpaceError,pikeCppOperator,pikeCppPrefix,@Spell,pikeConstant
283*40962ec9SBram Moolenaar
284*40962ec9SBram Moolenaarsyn match	pikeAutodocReal	display contained "\%(//\|[/ \t\v]\*\|^\*\)\@2<=!.*" contains=@pikeAutodoc containedin=pikeComment,pikeCommentL
285*40962ec9SBram Moolenaarsyn cluster pikeCommentGroup add=pikeAutodocReal
286*40962ec9SBram Moolenaarsyn cluster pikePreProcGroup add=pikeAutodocReal
287071d4279SBram Moolenaar
288071d4279SBram Moolenaar" Highlight User Labels
289071d4279SBram Moolenaar" Avoid matching foo::bar() in C++ by requiring that the next char is not ':'
290*40962ec9SBram Moolenaarsyn match	pikeUserLabel	display "\%(^\|[{};]\)\zs\I\i*\s*\ze:\%([^:]\|$\)" contained contains=NONE
291*40962ec9SBram Moolenaarsyn match	pikeUserLabel	display "\%(\<\%(break\|continue\)\_s\+\)\@10<=\I\i*" contained contains=NONE
292*40962ec9SBram Moolenaarsyn match	pikeUserLabel	display "\%(\<case\)\@5<=\s\+[^<()[\]{},;:]\+\ze::\@!" contained contains=pikeDelimiterDQ,pikeDelimiterSQ
293071d4279SBram Moolenaar
294*40962ec9SBram Moolenaarsyn match	pikeMappIndex	display contained "[^<()[\]{},;:]\+\ze::\@!" contains=pikeDelimiterDQ,pikeDelimiterSQ
295*40962ec9SBram Moolenaarsyn match	pikeSoftCast	display contained "\[[ \t\v\r\n.a-zA-Z0-9_():,|\+]" contains=NONE
296071d4279SBram Moolenaar
297*40962ec9SBram Moolenaarif exists("c_minlines")
298*40962ec9SBram Moolenaar  let b:c_minlines = c_minlines
299*40962ec9SBram Moolenaarelse
300*40962ec9SBram Moolenaar  if !exists("c_no_if0")
301*40962ec9SBram Moolenaar    let b:c_minlines = 400	" #if 0 constructs can be long
302*40962ec9SBram Moolenaar  else
303*40962ec9SBram Moolenaar    let b:c_minlines = 200	" mostly for multiline strings
304*40962ec9SBram Moolenaar  endif
305*40962ec9SBram Moolenaarendif
306*40962ec9SBram Moolenaarexec "syn sync ccomment pikeComment minlines=" . b:c_minlines
307*40962ec9SBram Moolenaarsyn sync match pikeMlStringSync grouphere pikeMlString +^[^"#]\+#\"+
308*40962ec9SBram Moolenaarsyn sync match pikeAutodocSync grouphere pikeCommentL "^\s*//!"
309071d4279SBram Moolenaar
310071d4279SBram Moolenaar" Define the default highlighting.
311*40962ec9SBram Moolenaar" Only used when an item doesn't have highlighting yet
312*40962ec9SBram Moolenaarhi def link pikeFormat		SpecialChar
313*40962ec9SBram Moolenaarhi def link pikeMlString	String
314*40962ec9SBram Moolenaarhi def link pikeCommentL	Comment
315*40962ec9SBram Moolenaarhi def link pikeCommentStart	Comment
316f37506f6SBram Moolenaarhi def link pikeLabel		Label
317*40962ec9SBram Moolenaarhi def link pikeUserLabel	Identifier
318f37506f6SBram Moolenaarhi def link pikeConditional	Conditional
319f37506f6SBram Moolenaarhi def link pikeRepeat		Repeat
320f37506f6SBram Moolenaarhi def link pikeCharacter	Character
321*40962ec9SBram Moolenaarhi def link pikeDelimiterDQ	Delimiter
322*40962ec9SBram Moolenaarhi def link pikeDelimiterSQ	Delimiter
323f37506f6SBram Moolenaarhi def link pikeNumber		Number
324*40962ec9SBram Moolenaarhi def link pikeOctal		Number
325*40962ec9SBram Moolenaarhi def link pikeOctalZero	PreProc	 " link this to Error if you want
326f37506f6SBram Moolenaarhi def link pikeFloat		Float
327*40962ec9SBram Moolenaarhi def link pikeOctalError	Error
328*40962ec9SBram Moolenaarhi def link pikeCommentError	Error
329*40962ec9SBram Moolenaarhi def link pikeCommentStartError	Error
330*40962ec9SBram Moolenaarhi def link pikeSpaceError	Error
331*40962ec9SBram Moolenaarhi def link pikeSpecialError	Error
332f37506f6SBram Moolenaarhi def link pikeOperator	Operator
333*40962ec9SBram Moolenaarhi def link pikeCppOperator	Operator
334*40962ec9SBram Moolenaarhi def link pikeStructure	Structure
335*40962ec9SBram Moolenaarhi def link pikeTypedef		Typedef
336*40962ec9SBram Moolenaarhi def link pikeStorageClass	StorageClass
337f37506f6SBram Moolenaarhi def link pikeInclude		Include
338*40962ec9SBram Moolenaarhi def link pikeCppPrefix	PreCondit
339f37506f6SBram Moolenaarhi def link pikePreProc		PreProc
340f37506f6SBram Moolenaarhi def link pikeDefine		Macro
341*40962ec9SBram Moolenaarhi def link pikeIncluded	String
342f37506f6SBram Moolenaarhi def link pikeError		Error
343*40962ec9SBram Moolenaarhi def link pikeDebug		Debug
344*40962ec9SBram Moolenaarhi def link pikeException	Exception
345f37506f6SBram Moolenaarhi def link pikeStatement	Statement
346f37506f6SBram Moolenaarhi def link pikeType		Type
347*40962ec9SBram Moolenaarhi def link pikeConstant	Constant
348*40962ec9SBram Moolenaarhi def link pikeBoolean		Boolean
349*40962ec9SBram Moolenaarhi def link pikeCommentString	String
350*40962ec9SBram Moolenaarhi def link pikeComment2String	String
351*40962ec9SBram Moolenaarhi def link pikeCommentSkip	Comment
352f37506f6SBram Moolenaarhi def link pikeString		String
353f37506f6SBram Moolenaarhi def link pikeComment		Comment
354f37506f6SBram Moolenaarhi def link pikeSpecial		SpecialChar
355f37506f6SBram Moolenaarhi def link pikeTodo		Todo
356*40962ec9SBram Moolenaarhi def link pikeBadContinuation	Error
357071d4279SBram Moolenaar
358*40962ec9SBram Moolenaarhi def link pikeCppInWrapper	PreCondit
359*40962ec9SBram Moolenaarhi def link pikeCppOutWrapper	PreCondit
360*40962ec9SBram Moolenaarhi def link pikePreConditMatch	PreCondit
361*40962ec9SBram Moolenaar
362*40962ec9SBram Moolenaarhi def link pikeCppOutSkip	Comment
363*40962ec9SBram Moolenaarhi def link pikeCppInElse2	Comment
364*40962ec9SBram Moolenaarhi def link pikeCppOutIf2	Comment
365*40962ec9SBram Moolenaarhi def link pikeCppOut		Comment
366*40962ec9SBram Moolenaar
367*40962ec9SBram Moolenaarhi def link pikePredef		Statement
368*40962ec9SBram Moolenaarhi def link pikeBindings	Identifier
369*40962ec9SBram Moolenaarhi def link pikeMappIndex	Identifier
370*40962ec9SBram Moolenaarhi def link pikeSoftCast	Type
371*40962ec9SBram Moolenaarhi def link pikeBadGroup	Error
372*40962ec9SBram Moolenaarhi def link pikeBadPClose	Error
373*40962ec9SBram Moolenaarhi def link pikeBadAClose	Error
374*40962ec9SBram Moolenaarhi def link pikeBadBClose	Error
375*40962ec9SBram Moolenaarhi def link pikeBadSPClose	Error
376*40962ec9SBram Moolenaarhi def link pikeBadSAClose	Error
377*40962ec9SBram Moolenaarhi def link pikeBadSBClose	Error
378*40962ec9SBram Moolenaarhi def link pikeBadSPAClose	Error
379*40962ec9SBram Moolenaarhi def link pikeBadSBAClose	Error
380*40962ec9SBram Moolenaarhi def link pikeBadSClose	Error
381071d4279SBram Moolenaar
382071d4279SBram Moolenaarlet b:current_syntax = "pike"
383071d4279SBram Moolenaar
384*40962ec9SBram Moolenaarlet &cpo = s:cpo_save
385*40962ec9SBram Moolenaarunlet s:cpo_save
386071d4279SBram Moolenaar" vim: ts=8
387