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