blob: dcf32113c56d5531af1f512673a77a2be3ec0f4f [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: Pike
3" Maintainer: Francesco Chemolli <kinkie@kame.usr.dsi.unimi.it>
4" Last Change: 2001 May 10
5
Bram Moolenaar89bcfda2016-08-30 23:26:57 +02006" quit when a syntax file was already loaded
7if exists("b:current_syntax")
Bram Moolenaar071d4272004-06-13 20:20:40 +00008 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.
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200104" Only when an item doesn't have highlighting yet
105command -nargs=+ HiLink hi def link <args>
Bram Moolenaar071d4272004-06-13 20:20:40 +0000106
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200107HiLink pikeLabel Label
108HiLink pikeUserLabel Label
109HiLink pikeConditional Conditional
110HiLink pikeRepeat Repeat
111HiLink pikeCharacter Character
112HiLink pikeSpecialCharacter pikeSpecial
113HiLink pikeNumber Number
114HiLink pikeFloat Float
115HiLink pikeOctalError pikeError
116HiLink pikeParenError pikeError
117HiLink pikeInParen pikeError
118HiLink pikeCommentError pikeError
119HiLink pikeOperator Operator
120HiLink pikeInclude Include
121HiLink pikePreProc PreProc
122HiLink pikeDefine Macro
123HiLink pikeIncluded pikeString
124HiLink pikeError Error
125HiLink pikeStatement Statement
126HiLink pikePreCondit PreCondit
127HiLink pikeType Type
128HiLink pikeCommentError pikeError
129HiLink pikeCommentString pikeString
130HiLink pikeComment2String pikeString
131HiLink pikeCommentSkip pikeComment
132HiLink pikeString String
133HiLink pikeComment Comment
134HiLink pikeSpecial SpecialChar
135HiLink pikeTodo Todo
136HiLink pikeException pikeStatement
137HiLink pikeCompoundType Constant
138"HiLink pikeIdentifier Identifier
Bram Moolenaar071d4272004-06-13 20:20:40 +0000139
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200140delcommand HiLink
Bram Moolenaar071d4272004-06-13 20:20:40 +0000141
142let b:current_syntax = "pike"
143
144" vim: ts=8