Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: Pike |
| 3 | " Maintainer: Francesco Chemolli <kinkie@kame.usr.dsi.unimi.it> |
| 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 |
| 8 | if version < 600 |
| 9 | syntax clear |
| 10 | elseif exists("b:current_syntax") |
| 11 | finish |
| 12 | endif |
| 13 | |
| 14 | " A bunch of useful C keywords |
| 15 | syn keyword pikeStatement goto break return continue |
| 16 | syn keyword pikeLabel case default |
| 17 | syn keyword pikeConditional if else switch |
| 18 | syn keyword pikeRepeat while for foreach do |
| 19 | syn keyword pikeStatement gauge destruct lambda inherit import typeof |
| 20 | syn keyword pikeException catch |
| 21 | syn keyword pikeType inline nomask private protected public static |
| 22 | |
| 23 | |
| 24 | syn keyword pikeTodo contained TODO FIXME XXX |
| 25 | |
| 26 | " String and Character constants |
| 27 | " Highlight special characters (those which have a backslash) differently |
| 28 | syn match pikeSpecial contained "\\[0-7][0-7][0-7]\=\|\\." |
| 29 | syn region pikeString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=pikeSpecial |
| 30 | syn match pikeCharacter "'[^\\]'" |
| 31 | syn match pikeSpecialCharacter "'\\.'" |
| 32 | syn match pikeSpecialCharacter "'\\[0-7][0-7]'" |
| 33 | syn match pikeSpecialCharacter "'\\[0-7][0-7][0-7]'" |
| 34 | |
| 35 | " Compound data types |
| 36 | syn region pikeCompoundType start='({' contains=pikeString,pikeCompoundType,pikeNumber,pikeFloat end='})' |
| 37 | syn region pikeCompoundType start='(\[' contains=pikeString,pikeCompoundType,pikeNumber,pikeFloat end='\])' |
| 38 | syn region pikeCompoundType start='(<' contains=pikeString,pikeCompoundType,pikeNumber,pikeFloat end='>)' |
| 39 | |
| 40 | "catch errors caused by wrong parenthesis |
| 41 | syn region pikeParen transparent start='([^{[<(]' end=')' contains=ALLBUT,pikeParenError,pikeIncluded,pikeSpecial,pikeTodo,pikeUserLabel,pikeBitField |
| 42 | syn match pikeParenError ")" |
| 43 | syn match pikeInParen contained "[^(][{}][^)]" |
| 44 | |
| 45 | "integer number, or floating point number without a dot and with "f". |
| 46 | syn case ignore |
| 47 | syn match pikeNumber "\<\d\+\(u\=l\=\|lu\|f\)\>" |
| 48 | "floating point number, with dot, optional exponent |
| 49 | syn match pikeFloat "\<\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=\>" |
| 50 | "floating point number, starting with a dot, optional exponent |
| 51 | syn match pikeFloat "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>" |
| 52 | "floating point number, without dot, with exponent |
| 53 | syn match pikeFloat "\<\d\+e[-+]\=\d\+[fl]\=\>" |
| 54 | "hex number |
| 55 | syn match pikeNumber "\<0x[0-9a-f]\+\(u\=l\=\|lu\)\>" |
| 56 | "syn match pikeIdentifier "\<[a-z_][a-z0-9_]*\>" |
| 57 | syn case match |
| 58 | " flag an octal number with wrong digits |
| 59 | syn match pikeOctalError "\<0[0-7]*[89]" |
| 60 | |
| 61 | if 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 |
| 73 | else |
| 74 | syn region pikeComment start="/\*" end="\*/" contains=pikeTodo |
| 75 | syn match pikeComment "//.*" contains=pikeTodo |
| 76 | syn match pikeComment "#!.*" contains=pikeTodo |
| 77 | endif |
| 78 | syntax match pikeCommentError "\*/" |
| 79 | |
| 80 | syn keyword pikeOperator sizeof |
| 81 | syn keyword pikeType int string void float mapping array multiset mixed |
| 82 | syn keyword pikeType program object function |
| 83 | |
| 84 | syn region pikePreCondit start="^\s*#\s*\(if\>\|ifdef\>\|ifndef\>\|elif\>\|else\>\|endif\>\)" skip="\\$" end="$" contains=pikeComment,pikeString,pikeCharacter,pikeNumber,pikeCommentError |
| 85 | syn region pikeIncluded contained start=+"+ skip=+\\\\\|\\"+ end=+"+ |
| 86 | syn match pikeIncluded contained "<[^>]*>" |
| 87 | syn match pikeInclude "^\s*#\s*include\>\s*["<]" contains=pikeIncluded |
| 88 | "syn match pikeLineSkip "\\$" |
| 89 | syn region pikeDefine start="^\s*#\s*\(define\>\|undef\>\)" skip="\\$" end="$" contains=ALLBUT,pikePreCondit,pikeIncluded,pikeInclude,pikeDefine,pikeInParen |
| 90 | syn region pikePreProc start="^\s*#\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" contains=ALLBUT,pikePreCondit,pikeIncluded,pikeInclude,pikeDefine,pikeInParen |
| 91 | |
| 92 | " Highlight User Labels |
| 93 | syn 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 ':' |
| 95 | syn match pikeUserLabel "^\s*\I\i*\s*:$" |
| 96 | syn match pikeUserLabel ";\s*\I\i*\s*:$"ms=s+1 |
| 97 | syn match pikeUserLabel "^\s*\I\i*\s*:[^:]"me=e-1 |
| 98 | syn match pikeUserLabel ";\s*\I\i*\s*:[^:]"ms=s+1,me=e-1 |
| 99 | |
| 100 | " Avoid recognizing most bitfields as labels |
| 101 | syn match pikeBitField "^\s*\I\i*\s*:\s*[1-9]"me=e-1 |
| 102 | syn match pikeBitField ";\s*\I\i*\s*:\s*[1-9]"me=e-1 |
| 103 | |
| 104 | syn 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 |
| 109 | if 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 |
| 151 | endif |
| 152 | |
| 153 | let b:current_syntax = "pike" |
| 154 | |
| 155 | " vim: ts=8 |