4 " Author: Adrian Thurston
13 syntax region ocComment start="\/\*" end="\*\/"
14 syntax match ocComment "\/\/.*$"
16 " Anything preprocessor
17 syntax match ocPreproc "#.*$"
20 syntax match ocLiteral "'\(\\.\|[^'\\]\)*'"
21 syntax match ocLiteral "\"\(\\.\|[^\"\\]\)*\""
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
36 syntax keyword ocType byte short char int
39 syntax match ocNumber "[0-9][0-9]*"
40 syntax match ocNumber "0x[0-9a-fA-F][0-9a-fA-F]*"
43 syntax keyword ocBoolean true false
46 syntax match anyId "[a-zA-Z_][a-zA-Z_0-9]*"
49 syntax keyword fsmType fpc fc fcurs fbuf fblen ftargs fstack
50 syntax keyword fsmKeyword fhold fgoto fcall fret fentry fnext fexec fbreak
52 syntax cluster rlItems contains=rlComment,rlLiteral,rlAugmentOps,rlOtherOps,rlKeywords,rlWrite,rlCodeCurly,rlCodeSemi,rlNumber,anyId,rlLabelColon,rlExprKeywords,rlBuiltIns
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
59 syntax match rlComment "#.*$" contained
62 syntax match rlLiteral "'\(\\.\|[^'\\]\)*'[i]*" contained
63 syntax match rlLiteral "\"\(\\.\|[^\"\\]\)*\"[i]*" contained
64 syntax match rlLiteral /\/\(\\.\|[^\/\\]\)*\/[i]*/ contained
65 syntax match rlLiteral "\[\(\\.\|[^\]\\]\)*\]" contained
68 syntax match rlNumber "[0-9][0-9]*" contained
69 syntax match rlNumber "0x[0-9a-fA-F][0-9a-fA-F]*" contained
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
80 syntax match rlOtherOps ":>" contained
81 syntax match rlOtherOps ":>>" contained
82 syntax match rlOtherOps "<:" contained
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
91 syntax keyword rlBuiltIns any ascii extend alpha digit alnum lower upper xdigit cntrl graph print punct space zlen empty contained
94 syntax keyword caseLabelKeyword case contained
95 syntax cluster caseLabelItems contains=ocComment,ocPreproc,ocLiteral,ocType,ocKeyword,caseLabelKeyword,ocNumber,ocBoolean,anyId,fsmType,fsmKeyword
96 syntax match caseLabelColon "case" contains=@caseLabelItems
97 syntax match caseLabelColon "case[\t ]\+.*:$" contains=@caseLabelItems
98 syntax match caseLabelColon "case[\t ]\+.*:[^=:]"me=e-1 contains=@caseLabelItems
101 syntax match ocLabelColon "^[\t ]*[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:$" contains=anyLabel
102 syntax match ocLabelColon "^[\t ]*[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:[^=:]"me=e-1 contains=anyLabel
104 syntax match rlLabelColon "[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:$" contained contains=anyLabel
105 syntax match rlLabelColon "[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:[^=:>]"me=e-1 contained contains=anyLabel
106 syntax match anyLabel "[a-zA-Z_][a-zA-Z_0-9]*" contained
108 " All items that can go in a code block.
110 syntax cluster inlineItems contains=rlCodeCurly,ocComment,ocPreproc,ocLiteral,ocType,ocKeyword,ocNumber,ocBoolean,ocLabelColon,anyId,fsmType,fsmKeyword,caseLabelColon
112 " Blocks of code. rlCodeCurly is recursive.
113 syntax region rlCodeCurly matchgroup=NONE start="{" end="}" contained contains=@inlineItems
114 syntax region rlCodeSemi matchgroup=Type start="\<alphtype\>" start="\<getkey\>" start="\<access\>" start="\<variable\>" matchgroup=NONE end=";" contained contains=@inlineItems
116 syntax region rlWrite matchgroup=Type start="\<write\>" matchgroup=NONE end="[;)]" contained contains=rlWriteKeywords,rlWriteOptions
118 syntax keyword rlWriteKeywords init data exec exports start error first_final contained
119 syntax keyword rlWriteOptions noerror nofinal noprefix noend nocs contained
122 " Sync at the start of machine specs.
124 " Match The ragel delimiters only if there quotes no ahead on the same line.
125 " On the open marker, use & to consume the leader.
126 syntax sync match ragelSyncPat grouphere NONE "^[^\'\"%]*%%{&^[^\'\"%]*"
127 syntax sync match ragelSyncPat grouphere NONE "^[^\'\"%]*%%[^{]&^[^\'\"%]*"
128 syntax sync match ragelSyncPat grouphere NONE "^[^\'\"]*}%%"
133 hi link ocComment Comment
134 hi link ocPreproc Macro
135 hi link ocLiteral String
137 hi link ocKeyword Keyword
138 hi link ocNumber Number
139 hi link ocBoolean Boolean
140 hi link rlComment Comment
141 hi link rlNumber Number
142 hi link rlLiteral String
143 hi link rlAugmentOps Keyword
144 hi link rlExprKeywords Keyword
145 hi link rlWriteKeywords Keyword
146 hi link rlWriteOptions Keyword
147 hi link rlKeywords Type
149 hi link fsmKeyword Keyword
150 hi link anyLabel Label
151 hi link caseLabelKeyword Keyword
153 hi link rlBuiltIns Constant
155 let b:current_syntax = "ragel"