add missing brackets; change to the correct executable name of nqp at parrot
[parrot.git] / editor / pmc.vim
blob8190cb68ba6c85a591f929e0b743848d98db2c5a
1 " Vim syntax file
2 " Language:     Parrot PMC
3 " Maintainer:   Andrew Rodland <arodland@entermail.net>
4 " Last Change:  2004 Aug 2
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
14 syn include @Pod syntax/pod.vim
15 syn region pmcPod start="^=[a-z]" end="^=cut" keepend contained contains=@Pod
17 " A bunch of useful C keywords
18 syn keyword     cStatement      goto break return continue asm
19 syn keyword     cLabel          case default
20 syn keyword     cConditional    if else switch
21 syn keyword     cRepeat         while for do
23 syn keyword     cTodo           contained TODO FIXME XXX
25 " cCommentGroup allows adding matches for special things in comments
26 syn cluster     cCommentGroup   contains=cTodo
28 " String and Character constants
29 " Highlight special characters (those which have a backslash) differently
30 syn match       cSpecial        display contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)"
31 if !exists("c_no_utf")
32   syn match     cSpecial        display contained "\\\(u\x\{4}\|U\x\{8}\)"
33 endif
34 if exists("c_no_cformat")
35   syn region    cString         start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial
36   " cCppString: same as cString, but ends at end of line
37   syn region    cCppString      start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial
38 else
39   syn match     cFormat         display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlL]\|ll\)\=\([diuoxXDOUfeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained
40   syn match     cFormat         display "%%" contained
41   syn region    cString         start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat
42   " cCppString: same as cString, but ends at end of line
43   syn region    cCppString      start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat
44 endif
46 syn match       cCharacter      "L\='[^\\]'"
47 syn match       cCharacter      "L'[^']*'" contains=cSpecial
48 if exists("c_gnu")
49   syn match     cSpecialError   "L\='\\[^'\"?\\abefnrtv]'"
50   syn match     cSpecialCharacter "L\='\\['\"?\\abefnrtv]'"
51 else
52   syn match     cSpecialError   "L\='\\[^'\"?\\abfnrtv]'"
53   syn match     cSpecialCharacter "L\='\\['\"?\\abfnrtv]'"
54 endif
55 syn match       cSpecialCharacter display "L\='\\\o\{1,3}'"
56 syn match       cSpecialCharacter display "'\\x\x\{1,2}'"
57 syn match       cSpecialCharacter display "L'\\x\x\+'"
59 "when wanted, highlight trailing white space
60 if exists("c_space_errors")
61   if !exists("c_no_trail_space_error")
62     syn match   cSpaceError     display excludenl "\s\+$"
63   endif
64   if !exists("c_no_tab_space_error")
65     syn match   cSpaceError     display " \+\t"me=e-1
66   endif
67 endif
69 "catch errors caused by wrong parenthesis and brackets
70 " also accept <% for {, %> for }, <: for [ and :> for ] (C99)
71 syn cluster     cParenGroup     contains=cParenError,cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cBitField,cCommentSkip,cOctalZero,cCppOut,cCppOut2,cCppSkip,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom
72 if exists("c_no_bracket_error")
73   syn region    cParen          transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cCppString
74   " cCppParen: same as cParen but ends at end-of-line; used in cDefine
75   syn region    cCppParen       transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString
76   syn match     cParenError     display ")"
77   syn match     cErrInParen     display contained "[{}]\|<%\|%>"
78 else
79   syn region    cParen          transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,cCppString
80   " cCppParen: same as cParen but ends at end-of-line; used in cDefine
81   syn region    cCppParen       transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString
82   syn match     cParenError     display "[\])]"
83   syn match     cErrInParen     display contained "[\]{}]\|<%\|%>"
84   syn region    cBracket        transparent start='\[\|<:' end=']\|:>' contains=ALLBUT,@cParenGroup,cErrInParen,cCppParen,cCppBracket,cCppString
85   " cCppBracket: same as cParen but ends at end-of-line; used in cDefine
86   syn region    cCppBracket     transparent start='\[\|<:' skip='\\$' excludenl end=']\|:>' end='$' contained contains=ALLBUT,@cParenGroup,cErrInParen,cParen,cBracket,cString
87   syn match     cErrInBracket   display contained "[);{}]\|<%\|%>"
88 endif
90 "integer number, or floating point number without a dot and with "f".
91 syn case ignore
92 syn match       cNumbers        display transparent "\<\d\|\.\d" contains=cNumber,cFloat,cOctalError,cOctal
93 " Same, but without octal error (for comments)
94 syn match       cNumbersCom     display contained transparent "\<\d\|\.\d" contains=cNumber,cFloat,cOctal
95 syn match       cNumber         display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>"
96 "hex number
97 syn match       cNumber         display contained "0x\x\+\(u\=l\{0,2}\|ll\=u\)\>"
98 " Flag the first zero of an octal number as something special
99 syn match       cOctal          display contained "0\o\+\(u\=l\{0,2}\|ll\=u\)\>" contains=cOctalZero
100 syn match       cOctalZero      display contained "\<0"
101 syn match       cFloat          display contained "\d\+f"
102 "floating point number, with dot, optional exponent
103 syn match       cFloat          display contained "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\="
104 "floating point number, starting with a dot, optional exponent
105 syn match       cFloat          display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
106 "floating point number, without dot, with exponent
107 syn match       cFloat          display contained "\d\+e[-+]\=\d\+[fl]\=\>"
108 if !exists("c_no_c99")
109   "hexadecimal floating point number, optional leading digits, with dot, with exponent
110   syn match     cFloat          display contained "0x\x*\.\x\+p[-+]\=\d\+[fl]\=\>"
111   "hexadecimal floating point number, with leading digits, optional dot, with exponent
112   syn match     cFloat          display contained "0x\x\+\.\=p[-+]\=\d\+[fl]\=\>"
113 endif
115 " flag an octal number with wrong digits
116 syn match       cOctalError     display contained "0\o*[89]\d*"
117 syn case match
119 if exists("c_comment_strings")
120   " A comment can contain cString, cCharacter and cNumber.
121   " But a "*/" inside a cString in a cComment DOES end the comment!  So we
122   " need to use a special type of cString: cCommentString, which also ends on
123   " "*/", and sees a "*" at the start of the line as comment again.
124   " Unfortunately this doesn't very well work for // type of comments :-(
125   syntax match  cCommentSkip    contained "^\s*\*\($\|\s\+\)"
126   syntax region cCommentString  contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end=+\*/+me=s-1 contains=cSpecial,cCommentSkip
127   syntax region cComment2String contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end="$" contains=cSpecial
128   syntax region  cCommentL      start="//" skip="\\$" end="$" keepend contains=@cCommentGroup,cComment2String,cCharacter,cNumbersCom,cSpaceError
129   syntax region cComment        matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cCommentString,cCharacter,cNumbersCom,cSpaceError,pmcPOD
130 else
131   syn region    cCommentL       start="//" skip="\\$" end="$" keepend contains=@cCommentGroup,cSpaceError
132   syn region    cComment        matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cSpaceError,pmcPOD
133 endif
134 " keep a // comment separately, it terminates a preproc. conditional
135 syntax match    cCommentError   display "\*/"
136 syntax match    cCommentStartError display "/\*"me=e-1 contained
138 syn keyword     cOperator       sizeof
139 if exists("c_gnu")
140   syn keyword   cStatement      __asm__
141   syn keyword   cOperator       typeof __real__ __imag__
142 endif
143 syn keyword     cType           int long short char void
144 syn keyword     cType           signed unsigned float double
145 if !exists("c_no_ansi") || exists("c_ansi_typedefs")
146   syn keyword   cType           size_t ssize_t wchar_t ptrdiff_t sig_atomic_t fpos_t
147   syn keyword   cType           clock_t time_t va_list jmp_buf FILE DIR div_t ldiv_t
148   syn keyword   cType           mbstate_t wctrans_t wint_t wctype_t
149 endif
150 if !exists("c_no_c99") " ISO C99
151   syn keyword   cType           bool complex
152   syn keyword   cType           int8_t int16_t int32_t int64_t
153   syn keyword   cType           uint8_t uint16_t uint32_t uint64_t
154   syn keyword   cType           int_least8_t int_least16_t int_least32_t int_least64_t
155   syn keyword   cType           uint_least8_t uint_least16_t uint_least32_t uint_least64_t
156   syn keyword   cType           int_fast8_t int_fast16_t int_fast32_t int_fast64_t
157   syn keyword   cType           uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t
158   syn keyword   cType           intptr_t uintptr_t
159   syn keyword   cType           intmax_t uintmax_t
160 endif
161 if exists("c_gnu")
162   syn keyword   cType           __label__ __complex__ __volatile__
163 endif
165 syn keyword     cStructure      struct union enum typedef
166 syn keyword     cStorageClass   static register auto volatile extern const
167 if exists("c_gnu")
168   syn keyword   cStorageClass   inline __attribute__
169 endif
170 if !exists("c_no_c99")
171   syn keyword   cStorageClass   inline restrict
172 endif
174 if !exists("c_no_ansi") || exists("c_ansi_constants") || exists("c_gnu")
175   if exists("c_gnu")
176     syn keyword cConstant __GNUC__ __FUNCTION__ __PRETTY_FUNCTION__
177   endif
178   syn keyword cConstant __LINE__ __FILE__ __DATE__ __TIME__ __STDC__
179   syn keyword cConstant __STDC_VERSION__
180   syn keyword cConstant CHAR_BIT MB_LEN_MAX MB_CUR_MAX
181   syn keyword cConstant UCHAR_MAX UINT_MAX ULONG_MAX USHRT_MAX
182   syn keyword cConstant CHAR_MIN INT_MIN LONG_MIN SHRT_MIN
183   syn keyword cConstant CHAR_MAX INT_MAX LONG_MAX SHRT_MAX
184   syn keyword cConstant SCHAR_MIN SINT_MIN SLONG_MIN SSHRT_MIN
185   syn keyword cConstant SCHAR_MAX SINT_MAX SLONG_MAX SSHRT_MAX
186   if !exists("c_no_c99")
187     syn keyword cConstant LLONG_MAX ULLONG_MAX
188     syn keyword cConstant INT8_MIN INT16_MIN INT32_MIN INT64_MIN
189     syn keyword cConstant INT8_MAX INT16_MAX INT32_MAX INT64_MAX
190     syn keyword cConstant UINT8_MAX UINT16_MAX UINT32_MAX UINT64_MAX
191     syn keyword cConstant INT_LEAST8_MIN INT_LEAST16_MIN INT_LEAST32_MIN INT_LEAST64_MIN
192     syn keyword cConstant INT_LEAST8_MAX INT_LEAST16_MAX INT_LEAST32_MAX INT_LEAST64_MAX
193     syn keyword cConstant UINT_LEAST8_MAX UINT_LEAST16_MAX UINT_LEAST32_MAX UINT_LEAST64_MAX
194     syn keyword cConstant INT_FAST8_MIN INT_FAST16_MIN INT_FAST32_MIN INT_FAST64_MIN
195     syn keyword cConstant INT_FAST8_MAX INT_FAST16_MAX INT_FAST32_MAX INT_FAST64_MAX
196     syn keyword cConstant UINT_FAST8_MAX UINT_FAST16_MAX UINT_FAST32_MAX UINT_FAST64_MAX
197     syn keyword cConstant INTPTR_MIN INTPTR_MAX UINTPTR_MAX
198     syn keyword cConstant INTMAX_MIN INTMAX_MAX UINTMAX_MAX
199     syn keyword cConstant PTRDIFF_MIN PTRDIFF_MAX SIG_ATOMIC_MIN SIG_ATOMIC_MAX
200     syn keyword cConstant SIZE_MAX WCHAR_MIN WCHAR_MAX WINT_MIN WINT_MAX
201   endif
202   syn keyword cConstant FLT_RADIX FLT_ROUNDS
203   syn keyword cConstant FLT_DIG FLT_MANT_DIG FLT_EPSILON
204   syn keyword cConstant DBL_DIG DBL_MANT_DIG DBL_EPSILON
205   syn keyword cConstant LDBL_DIG LDBL_MANT_DIG LDBL_EPSILON
206   syn keyword cConstant FLT_MIN FLT_MAX FLT_MIN_EXP FLT_MAX_EXP
207   syn keyword cConstant FLT_MIN_10_EXP FLT_MAX_10_EXP
208   syn keyword cConstant DBL_MIN DBL_MAX DBL_MIN_EXP DBL_MAX_EXP
209   syn keyword cConstant DBL_MIN_10_EXP DBL_MAX_10_EXP
210   syn keyword cConstant LDBL_MIN LDBL_MAX LDBL_MIN_EXP LDBL_MAX_EXP
211   syn keyword cConstant LDBL_MIN_10_EXP LDBL_MAX_10_EXP
212   syn keyword cConstant HUGE_VAL CLOCKS_PER_SEC NULL
213   syn keyword cConstant LC_ALL LC_COLLATE LC_CTYPE LC_MONETARY
214   syn keyword cConstant LC_NUMERIC LC_TIME
215   syn keyword cConstant SIG_DFL SIG_ERR SIG_IGN
216   syn keyword cConstant SIGABRT SIGFPE SIGILL SIGHUP SIGINT SIGSEGV SIGTERM
217   " Add POSIX signals as well...
218   syn keyword cConstant SIGABRT SIGALRM SIGCHLD SIGCONT SIGFPE SIGHUP
219   syn keyword cConstant SIGILL SIGINT SIGKILL SIGPIPE SIGQUIT SIGSEGV
220   syn keyword cConstant SIGSTOP SIGTERM SIGTRAP SIGTSTP SIGTTIN SIGTTOU
221   syn keyword cConstant SIGUSR1 SIGUSR2
222   syn keyword cConstant _IOFBF _IOLBF _IONBF BUFSIZ EOF WEOF
223   syn keyword cConstant FOPEN_MAX FILENAME_MAX L_tmpnam
224   syn keyword cConstant SEEK_CUR SEEK_END SEEK_SET
225   syn keyword cConstant TMP_MAX stderr stdin stdout
226   syn keyword cConstant EXIT_FAILURE EXIT_SUCCESS RAND_MAX
227   " Add signals not mentioned above
228   syn keyword cConstant SIGXCPU SIGURG SIGBUS SIGVTALRM SIGPROF SIGWINCH
229   syn keyword cConstant SIGPWR SIGSYS SIGXFSZ SIGIO
230   " Add POSIX errors as well
231   syn keyword cConstant E2BIG EACCES EAGAIN EBADF EBADMSG EBUSY
232   syn keyword cConstant ECANCELED ECHILD EDEADLK EDOM EEXIST EFAULT
233   syn keyword cConstant EFBIG EILSEQ EINPROGRESS EINTR EINVAL EIO EISDIR
234   syn keyword cConstant EMFILE EMLINK EMSGSIZE ENAMETOOLONG ENFILE ENODEV
235   syn keyword cConstant ENOENT ENOEXEC ENOLCK ENOMEM ENOSPC ENOSYS
236   syn keyword cConstant ENOTDIR ENOTEMPTY ENOTSUP ENOTTY ENXIO EPERM
237   syn keyword cConstant EPIPE ERANGE EROFS ESPIPE ESRCH ETIMEDOUT EXDEV
238   " math.h
239   syn keyword cConstant M_E M_LOG2E M_LOG10E M_LN2 M_LN10 M_PI M_PI_2 M_PI_4
240   syn keyword cConstant M_1_PI M_2_PI M_2_SQRTPI M_SQRT2 M_SQRT1_2
241 endif
242 if !exists("c_no_c99") " ISO C99
243   syn keyword cConstant true false
244 endif
246 " Accept %: for # (C99)
247 syn region      cPreCondit      start="^\s*\(%:\|#\)\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" end="//"me=s-1 contains=cComment,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError
248 syn match       cPreCondit      display "^\s*\(%:\|#\)\s*\(else\|endif\)\>"
249 if !exists("c_no_if0")
250   syn region    cCppOut         start="^\s*\(%:\|#\)\s*if\s\+0\+\>" end=".\@=\|$" contains=cCppOut2
251   syn region    cCppOut2        contained start="0" end="^\s*\(%:\|#\)\s*\(endif\>\|else\>\|elif\>\)" contains=cSpaceError,cCppSkip
252   syn region    cCppSkip        contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=cSpaceError,cCppSkip
253 endif
254 syn region      cIncluded       display contained start=+"+ skip=+\\\\\|\\"+ end=+"+
255 syn match       cIncluded       display contained "<[^>]*>"
256 syn match       cInclude        display "^\s*\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded
257 "syn match cLineSkip    "\\$"
258 syn cluster     cPreProcGroup   contains=cPreCondit,cIncluded,cInclude,cDefine,cErrInParen,cErrInBracket,cUserLabel,cSpecial,cOctalZero,cCppOut,cCppOut2,cCppSkip,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cString,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cParen,cBracket,cMulti
259 syn region      cDefine         start="^\s*\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" end="//"me=s-1 contains=ALLBUT,@cPreProcGroup
260 syn region      cPreProc        start="^\s*\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup
262 " Highlight User Labels
263 syn cluster     cMultiGroup     contains=cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cBitField,cOctalZero,cCppOut,cCppOut2,cCppSkip,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cCppParen,cCppBracket,cCppString
264 syn region      cMulti          transparent start='?' skip='::' end=':' contains=ALLBUT,@cMultiGroup
265 " Avoid matching foo::bar() in C++ by requiring that the next char is not ':'
266 syn cluster     cLabelGroup     contains=cUserLabel
267 syn match       cUserCont       display "^\s*\I\i*\s*:$" contains=@cLabelGroup
268 syn match       cUserCont       display ";\s*\I\i*\s*:$" contains=@cLabelGroup
269 syn match       cUserCont       display "^\s*\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup
270 syn match       cUserCont       display ";\s*\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup
272 syn match       cUserLabel      display "\I\i*" contained
274 " Avoid recognizing most bitfields as labels
275 syn match       cBitField       display "^\s*\I\i*\s*:\s*[1-9]"me=e-1
276 syn match       cBitField       display ";\s*\I\i*\s*:\s*[1-9]"me=e-1
278 if exists("c_minlines")
279   let b:c_minlines = c_minlines
280 else
281   if !exists("c_no_if0")
282     let b:c_minlines = 50       " #if 0 constructs can be long
283   else
284     let b:c_minlines = 15       " mostly for () constructs
285   endif
286 endif
287 exec "syn sync ccomment cComment minlines=" . b:c_minlines
289 " Define the default highlighting.
290 " For version 5.7 and earlier: only when not done already
291 " For version 5.8 and later: only when an item doesn't have highlighting yet
292 if version >= 508 || !exists("did_c_syn_inits")
293   if version < 508
294     let did_c_syn_inits = 1
295     command -nargs=+ HiLink hi link <args>
296   else
297     command -nargs=+ HiLink hi def link <args>
298   endif
300   HiLink cFormat                cSpecial
301   HiLink cCppString             cString
302   HiLink cCommentL              cComment
303   HiLink cCommentStart          cComment
304   HiLink cLabel                 Label
305   HiLink cUserLabel             Label
306   HiLink cConditional           Conditional
307   HiLink cRepeat                Repeat
308   HiLink cCharacter             Character
309   HiLink cSpecialCharacter      cSpecial
310   HiLink cNumber                Number
311   HiLink cOctal                 Number
312   HiLink cOctalZero             PreProc  " link this to Error if you want
313   HiLink cFloat                 Float
314   HiLink cOctalError            cError
315   HiLink cParenError            cError
316   HiLink cErrInParen            cError
317   HiLink cErrInBracket          cError
318   HiLink cCommentError          cError
319   HiLink cCommentStartError     cError
320   HiLink cSpaceError            cError
321   HiLink cSpecialError          cError
322   HiLink cOperator              Operator
323   HiLink cStructure             Structure
324   HiLink cStorageClass          StorageClass
325   HiLink cInclude               Include
326   HiLink cPreProc               PreProc
327   HiLink cDefine                Macro
328   HiLink cIncluded              cString
329   HiLink cError                 Error
330   HiLink cStatement             Statement
331   HiLink cPreCondit             PreCondit
332   HiLink cType                  Type
333   HiLink cConstant              Constant
334   HiLink cCommentString         cString
335   HiLink cComment2String        cString
336   HiLink cCommentSkip           cComment
337   HiLink cString                String
338   HiLink cComment               Comment
339   HiLink cSpecial               SpecialChar
340   HiLink cTodo                  Todo
341   HiLink cCppSkip               cCppOut
342   HiLink cCppOut2               cCppOut
343   HiLink cCppOut                Comment
345   delcommand HiLink
346 endif
348 let b:current_syntax = "pmc"
350 " vim: ts=8