Don't segfault when there are no machine instantiations.
[external/ragel.git] / ragel-java.vim
1 " Vim syntax file
2 "
3 " Language: Ragel
4 " Author: Adrian Thurston
5
6 syntax clear
7
8 "
9 " Outside code
10 "
11
12 " Comments
13 syntax region ocComment start="\/\*" end="\*\/"
14 syntax match ocComment "\/\/.*$"
15
16 " Anything preprocessor
17 syntax match ocPreproc "#.*$"
18
19 " Strings
20 syntax match ocLiteral "'\(\\.\|[^'\\]\)*'"
21 syntax match ocLiteral "\"\(\\.\|[^\"\\]\)*\""
22
23 " C/C++ Keywords
24 syntax keyword ocType unsigned signed void char short int long float double bool
25 syntax keyword ocType inline static extern register const volatile auto
26 syntax keyword ocType union enum struct class typedef
27 syntax keyword ocType namespace template typename mutable
28 syntax keyword ocKeyword break continue default do else for
29 syntax keyword ocKeyword goto if return switch while
30 syntax keyword ocKeyword new delete this using friend public private protected sizeof
31 syntax keyword ocKeyword throw try catch operator typeid
32 syntax keyword ocKeyword and bitor xor compl bitand and_eq or_eq xor_eq not not_eq
33 syntax keyword ocKeyword static_cast dynamic_cast
34
35 " Java Keywords
36 syntax keyword ocType byte short char int
37
38 " Numbers
39 syntax match ocNumber "[0-9][0-9]*"
40 syntax match ocNumber "0x[0-9a-fA-F][0-9a-fA-F]*"
41
42 " Booleans
43 syntax keyword ocBoolean true false
44
45 " Identifiers
46 syntax match anyId "[a-zA-Z_][a-zA-Z_0-9]*"
47
48 " Inline code only
49 syntax keyword fsmType fpc fc fcurs fbuf fblen ftargs fstack
50 syntax keyword fsmKeyword fhold fgoto fcall fret fentry fnext fexec fbreak
51
52 syntax cluster rlItems contains=rlComment,rlLiteral,rlAugmentOps,rlOtherOps,rlKeywords,rlWrite,rlCodeCurly,rlCodeSemi,rlNumber,anyId,rlLabelColon,rlExprKeywords
53
54 syntax region machineSpec1 matchgroup=beginRL start="%%{" end="}%%" contains=@rlItems
55 syntax region machineSpec2 matchgroup=beginRL start="%%[^{]"rs=e-1 end="$" keepend contains=@rlItems
56 syntax region machineSpec2 matchgroup=beginRL start="%%$" end="$" keepend contains=@rlItems
57
58 " Comments
59 syntax match rlComment "#.*$" contained
60
61 " Literals
62 syntax match rlLiteral "'\(\\.\|[^'\\]\)*'[i]*" contained
63 syntax match rlLiteral "\"\(\\.\|[^\"\\]\)*\"[i]*" contained
64 syntax match rlLiteral /\/\(\\.\|[^\/\\]\)*\/[i]*/ contained
65 syntax match rlLiteral "\[\(\\.\|[^\]\\]\)*\]" contained
66
67 " Numbers
68 syntax match rlNumber "[0-9][0-9]*" contained
69 syntax match rlNumber "0x[0-9a-fA-F][0-9a-fA-F]*" contained
70
71 " Operators
72 syntax match rlAugmentOps "[>$%@]" contained
73 syntax match rlAugmentOps "<>\|<" contained
74 syntax match rlAugmentOps "[>\<$%@][!\^/*~]" contained
75 syntax match rlAugmentOps "[>$%]?" contained
76 syntax match rlAugmentOps "<>[!\^/*~]" contained
77 syntax match rlAugmentOps "=>" contained
78 syntax match rlOtherOps "->" contained
79
80 syntax match rlOtherOps ":>" contained
81 syntax match rlOtherOps ":>>" contained
82 syntax match rlOtherOps "<:" contained
83
84 " Keywords
85 " FIXME: Enable the range keyword post 5.17.
86 " syntax keyword rlKeywords machine action context include range contained
87 syntax keyword rlKeywords machine action context include import export prepush postpop contained
88 syntax keyword rlExprKeywords when inwhen outwhen err lerr eof from to contained
89
90 " Case Labels
91 syntax keyword caseLabelKeyword case contained
92 syntax cluster caseLabelItems contains=ocComment,ocPreproc,ocLiteral,ocType,ocKeyword,caseLabelKeyword,ocNumber,ocBoolean,anyId,fsmType,fsmKeyword
93 syntax match caseLabelColon "case" contains=@caseLabelItems
94 syntax match caseLabelColon "case[\t ]\+.*:$" contains=@caseLabelItems
95 syntax match caseLabelColon "case[\t ]\+.*:[^=:]"me=e-1 contains=@caseLabelItems
96
97 " Labels
98 syntax match ocLabelColon "^[\t ]*[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:$" contains=anyLabel
99 syntax match ocLabelColon "^[\t ]*[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:[^=:]"me=e-1 contains=anyLabel
100
101 syntax match rlLabelColon "[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:$" contained contains=anyLabel
102 syntax match rlLabelColon "[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:[^=:>]"me=e-1 contained contains=anyLabel
103 syntax match anyLabel "[a-zA-Z_][a-zA-Z_0-9]*" contained
104
105 " All items that can go in a code block.
106
107 syntax cluster inlineItems contains=rlCodeCurly,ocComment,ocPreproc,ocLiteral,ocType,ocKeyword,ocNumber,ocBoolean,ocLabelColon,anyId,fsmType,fsmKeyword,caseLabelColon
108
109 " Blocks of code. rlCodeCurly is recursive.
110 syntax region rlCodeCurly matchgroup=NONE start="{" end="}" contained contains=@inlineItems
111 syntax region rlCodeSemi matchgroup=Type start="\<alphtype\>" start="\<getkey\>" start="\<access\>" start="\<variable\>" matchgroup=NONE end=";" contained contains=@inlineItems
112
113 syntax region rlWrite matchgroup=Type start="\<write\>" matchgroup=NONE end="[;)]" contained contains=rlWriteKeywords,rlWriteOptions
114
115 syntax keyword rlWriteKeywords init data exec exports start error first_final contained
116 syntax keyword rlWriteOptions noerror nofinal noprefix noend nocs contained
117
118 "
119 " Sync at the start of machine specs.
120 "
121 " Match The ragel delimiters only if there quotes no ahead on the same line.
122 " On the open marker, use & to consume the leader.
123 syntax sync match ragelSyncPat grouphere NONE "^[^\'\"%]*%%{&^[^\'\"%]*"
124 syntax sync match ragelSyncPat grouphere NONE "^[^\'\"%]*%%[^{]&^[^\'\"%]*"
125 syntax sync match ragelSyncPat grouphere NONE "^[^\'\"]*}%%"
126
127 "
128 " Specifying Groups
129 "
130 hi link ocComment Comment
131 hi link ocPreproc Macro
132 hi link ocLiteral String
133 hi link ocType Type
134 hi link ocKeyword Keyword
135 hi link ocNumber Number
136 hi link ocBoolean Boolean
137 hi link rlComment Comment
138 hi link rlNumber Number
139 hi link rlLiteral String
140 hi link rlAugmentOps Keyword
141 hi link rlExprKeywords Keyword
142 hi link rlWriteKeywords Keyword
143 hi link rlWriteOptions Keyword
144 hi link rlKeywords Type
145 hi link fsmType Type
146 hi link fsmKeyword Keyword
147 hi link anyLabel Label
148 hi link caseLabelKeyword Keyword
149 hi link beginRL Type
150  
151 let b:current_syntax = "ragel"