xref: /vim-8.2.3635/runtime/syntax/pike.vim (revision bb76f24a)
1" Vim syntax file
2" Language:	Pike
3" Maintainer:	Francesco Chemolli <[email protected]>
4" Last Change:	2001 May 10
5
6" quit when a syntax file was already loaded
7if exists("b:current_syntax")
8  finish
9endif
10
11" A bunch of useful C keywords
12syn keyword pikeStatement	goto break return continue
13syn keyword pikeLabel		case default
14syn keyword pikeConditional	if else switch
15syn keyword pikeRepeat		while for foreach do
16syn keyword pikeStatement	gauge destruct lambda inherit import typeof
17syn keyword pikeException	catch
18syn keyword pikeType		inline nomask private protected public static
19
20
21syn keyword pikeTodo contained	TODO FIXME XXX
22
23" String and Character constants
24" Highlight special characters (those which have a backslash) differently
25syn match pikeSpecial contained	"\\[0-7][0-7][0-7]\=\|\\."
26syn region pikeString		start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=pikeSpecial
27syn match pikeCharacter		"'[^\\]'"
28syn match pikeSpecialCharacter	"'\\.'"
29syn match pikeSpecialCharacter	"'\\[0-7][0-7]'"
30syn match pikeSpecialCharacter	"'\\[0-7][0-7][0-7]'"
31
32" Compound data types
33syn region pikeCompoundType start='({' contains=pikeString,pikeCompoundType,pikeNumber,pikeFloat end='})'
34syn region pikeCompoundType start='(\[' contains=pikeString,pikeCompoundType,pikeNumber,pikeFloat end='\])'
35syn region pikeCompoundType start='(<' contains=pikeString,pikeCompoundType,pikeNumber,pikeFloat end='>)'
36
37"catch errors caused by wrong parenthesis
38syn region pikeParen		transparent start='([^{[<(]' end=')' contains=ALLBUT,pikeParenError,pikeIncluded,pikeSpecial,pikeTodo,pikeUserLabel,pikeBitField
39syn match pikeParenError		")"
40syn match pikeInParen contained	"[^(][{}][^)]"
41
42"integer number, or floating point number without a dot and with "f".
43syn case ignore
44syn match pikeNumber		"\<\d\+\(u\=l\=\|lu\|f\)\>"
45"floating point number, with dot, optional exponent
46syn match pikeFloat		"\<\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=\>"
47"floating point number, starting with a dot, optional exponent
48syn match pikeFloat		"\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
49"floating point number, without dot, with exponent
50syn match pikeFloat		"\<\d\+e[-+]\=\d\+[fl]\=\>"
51"hex number
52syn match pikeNumber		"\<0x[0-9a-f]\+\(u\=l\=\|lu\)\>"
53"syn match pikeIdentifier	"\<[a-z_][a-z0-9_]*\>"
54syn case match
55" flag an octal number with wrong digits
56syn match pikeOctalError		"\<0[0-7]*[89]"
57
58if exists("c_comment_strings")
59  " A comment can contain pikeString, pikeCharacter and pikeNumber.
60  " But a "*/" inside a pikeString in a pikeComment DOES end the comment!  So we
61  " need to use a special type of pikeString: pikeCommentString, which also ends on
62  " "*/", and sees a "*" at the start of the line as comment again.
63  " Unfortunately this doesn't very well work for // type of comments :-(
64  syntax match pikeCommentSkip	contained "^\s*\*\($\|\s\+\)"
65  syntax region pikeCommentString	contained start=+"+ skip=+\\\\\|\\"+ end=+"+ end=+\*/+me=s-1 contains=pikeSpecial,pikeCommentSkip
66  syntax region pikeComment2String	contained start=+"+ skip=+\\\\\|\\"+ end=+"+ end="$" contains=pikeSpecial
67  syntax region pikeComment	start="/\*" end="\*/" contains=pikeTodo,pikeCommentString,pikeCharacter,pikeNumber,pikeFloat
68  syntax match  pikeComment	"//.*" contains=pikeTodo,pikeComment2String,pikeCharacter,pikeNumber
69  syntax match  pikeComment	"#\!.*" contains=pikeTodo,pikeComment2String,pikeCharacter,pikeNumber
70else
71  syn region pikeComment		start="/\*" end="\*/" contains=pikeTodo
72  syn match pikeComment		"//.*" contains=pikeTodo
73  syn match pikeComment		"#!.*" contains=pikeTodo
74endif
75syntax match pikeCommentError	"\*/"
76
77syn keyword pikeOperator	sizeof
78syn keyword pikeType		int string void float mapping array multiset mixed
79syn keyword pikeType		program object function
80
81syn region pikePreCondit	start="^\s*#\s*\(if\>\|ifdef\>\|ifndef\>\|elif\>\|else\>\|endif\>\)" skip="\\$" end="$" contains=pikeComment,pikeString,pikeCharacter,pikeNumber,pikeCommentError
82syn region pikeIncluded contained start=+"+ skip=+\\\\\|\\"+ end=+"+
83syn match pikeIncluded contained "<[^>]*>"
84syn match pikeInclude		"^\s*#\s*include\>\s*["<]" contains=pikeIncluded
85"syn match pikeLineSkip	"\\$"
86syn region pikeDefine		start="^\s*#\s*\(define\>\|undef\>\)" skip="\\$" end="$" contains=ALLBUT,pikePreCondit,pikeIncluded,pikeInclude,pikeDefine,pikeInParen
87syn region pikePreProc		start="^\s*#\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" contains=ALLBUT,pikePreCondit,pikeIncluded,pikeInclude,pikeDefine,pikeInParen
88
89" Highlight User Labels
90syn region	pikeMulti		transparent start='?' end=':' contains=ALLBUT,pikeIncluded,pikeSpecial,pikeTodo,pikeUserLabel,pikeBitField
91" Avoid matching foo::bar() in C++ by requiring that the next char is not ':'
92syn match	pikeUserLabel	"^\s*\I\i*\s*:$"
93syn match	pikeUserLabel	";\s*\I\i*\s*:$"ms=s+1
94syn match	pikeUserLabel	"^\s*\I\i*\s*:[^:]"me=e-1
95syn match	pikeUserLabel	";\s*\I\i*\s*:[^:]"ms=s+1,me=e-1
96
97" Avoid recognizing most bitfields as labels
98syn match	pikeBitField	"^\s*\I\i*\s*:\s*[1-9]"me=e-1
99syn match	pikeBitField	";\s*\I\i*\s*:\s*[1-9]"me=e-1
100
101syn sync ccomment pikeComment minlines=10
102
103" Define the default highlighting.
104" Only when an item doesn't have highlighting yet
105
106hi def link pikeLabel		Label
107hi def link pikeUserLabel		Label
108hi def link pikeConditional	Conditional
109hi def link pikeRepeat		Repeat
110hi def link pikeCharacter		Character
111hi def link pikeSpecialCharacter pikeSpecial
112hi def link pikeNumber		Number
113hi def link pikeFloat		Float
114hi def link pikeOctalError		pikeError
115hi def link pikeParenError		pikeError
116hi def link pikeInParen		pikeError
117hi def link pikeCommentError	pikeError
118hi def link pikeOperator		Operator
119hi def link pikeInclude		Include
120hi def link pikePreProc		PreProc
121hi def link pikeDefine		Macro
122hi def link pikeIncluded		pikeString
123hi def link pikeError		Error
124hi def link pikeStatement		Statement
125hi def link pikePreCondit		PreCondit
126hi def link pikeType		Type
127hi def link pikeCommentError	pikeError
128hi def link pikeCommentString	pikeString
129hi def link pikeComment2String	pikeString
130hi def link pikeCommentSkip	pikeComment
131hi def link pikeString		String
132hi def link pikeComment		Comment
133hi def link pikeSpecial		SpecialChar
134hi def link pikeTodo		Todo
135hi def link pikeException		pikeStatement
136hi def link pikeCompoundType	Constant
137"hi def link pikeIdentifier	Identifier
138
139
140let b:current_syntax = "pike"
141
142" vim: ts=8
143