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