A fix to the documentation makefile from John D. Mitchell.
[ragel.git] / ragel.vim
blob10cf3951d40c046f00789b81204fb6abc58ba96a
1 " Vim syntax file
3 " Language: Ragel
4 " Author: Adrian Thurston
6 syntax clear
9 " Outside code
12 " Comments
13 syntax region ocComment start="\/\*" end="\*\/"
14 syntax match ocComment "\/\/.*$"
16 " Anything preprocessor
17 syntax match ocPreproc "#.*$"
19 " Strings
20 syntax match ocLiteral "'\(\\.\|[^'\\]\)*'"
21 syntax match ocLiteral "\"\(\\.\|[^\"\\]\)*\""
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
35 " D Keywords
36 syntax keyword ocType wchar dchar bit byte ubyte ushort uint ulong cent ucent 
37 syntax keyword ocType cfloat ifloat cdouble idouble real creal ireal
38 syntax keyword ocKeyword abstract alias align asm assert body cast debug delegate
39 syntax keyword ocKeyword deprecated export final finally foreach function import in inout 
40 syntax keyword ocKeyword interface invariant is mixin module out override package pragma
41 syntax keyword ocKeyword super synchronized typeof unittest version with
43 " Java Keywords
44 syntax keyword ocType byte short char int
46 " Objective-C Directives
47 syntax match ocKeyword "@public\|@private\|@protected"
48 syntax match ocKeyword "@interface\|@implementation"
49 syntax match ocKeyword "@class\|@end\|@defs"
50 syntax match ocKeyword "@encode\|@protocol\|@selector"
52 " Numbers
53 syntax match ocNumber "[0-9][0-9]*"
54 syntax match ocNumber "0x[0-9a-fA-F][0-9a-fA-F]*"
56 " Booleans
57 syntax keyword ocBoolean true false
59 " Identifiers
60 syntax match anyId "[a-zA-Z_][a-zA-Z_0-9]*"
62 " Inline code only
63 syntax keyword fsmType fpc fc fcurs fbuf fblen ftargs fstack
64 syntax keyword fsmKeyword fhold fgoto fcall fret fentry fnext fexec fbreak
66 syntax cluster rlItems contains=rlComment,rlLiteral,rlAugmentOps,rlOtherOps,rlKeywords,rlWrite,rlCodeCurly,rlCodeSemi,rlNumber,anyId,rlLabelColon,rlExprKeywords
68 syntax region machineSpec1 matchgroup=beginRL start="%%{" end="}%%" contains=@rlItems
69 syntax region machineSpec2 matchgroup=beginRL start="%%[^{]"rs=e-1 end="$" keepend contains=@rlItems
70 syntax region machineSpec2 matchgroup=beginRL start="%%$" end="$" keepend contains=@rlItems
72 " Comments
73 syntax match rlComment "#.*$" contained
75 " Literals
76 syntax match rlLiteral "'\(\\.\|[^'\\]\)*'[i]*" contained
77 syntax match rlLiteral "\"\(\\.\|[^\"\\]\)*\"[i]*" contained
78 syntax match rlLiteral /\/\(\\.\|[^\/\\]\)*\/[i]*/ contained
79 syntax match rlLiteral "\[\(\\.\|[^\]\\]\)*\]" contained
81 " Numbers
82 syntax match rlNumber "[0-9][0-9]*" contained
83 syntax match rlNumber "0x[0-9a-fA-F][0-9a-fA-F]*" contained
85 " Operators
86 syntax match rlAugmentOps "[>$%@]" contained
87 syntax match rlAugmentOps "<>\|<" contained
88 syntax match rlAugmentOps "[>\<$%@][!\^/*~]" contained
89 syntax match rlAugmentOps "[>$%]?" contained
90 syntax match rlAugmentOps "<>[!\^/*~]" contained
91 syntax match rlAugmentOps "=>" contained
92 syntax match rlOtherOps "->" contained
94 syntax match rlOtherOps ":>" contained
95 syntax match rlOtherOps ":>>" contained
96 syntax match rlOtherOps "<:" contained
98 " Keywords
99 " FIXME: Enable the range keyword post 5.17.
100 " syntax keyword rlKeywords machine action context include range contained
101 syntax keyword rlKeywords machine action context include import export prepush postpop contained
102 syntax keyword rlExprKeywords when inwhen outwhen err lerr eof from to contained
104 " Case Labels
105 syntax keyword caseLabelKeyword case contained
106 syntax cluster caseLabelItems contains=ocComment,ocPreproc,ocLiteral,ocType,ocKeyword,caseLabelKeyword,ocNumber,ocBoolean,anyId,fsmType,fsmKeyword
107 syntax match caseLabelColon "case" contains=@caseLabelItems
108 syntax match caseLabelColon "case[\t ]\+.*:$" contains=@caseLabelItems
109 syntax match caseLabelColon "case[\t ]\+.*:[^=:]"me=e-1 contains=@caseLabelItems
111 " Labels
112 syntax match ocLabelColon "^[\t ]*[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:$" contains=anyLabel
113 syntax match ocLabelColon "^[\t ]*[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:[^=:]"me=e-1 contains=anyLabel
115 syntax match rlLabelColon "[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:$" contained contains=anyLabel
116 syntax match rlLabelColon "[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:[^=:>]"me=e-1 contained contains=anyLabel
117 syntax match anyLabel "[a-zA-Z_][a-zA-Z_0-9]*" contained
119 " All items that can go in a code block.
121 syntax cluster inlineItems contains=rlCodeCurly,ocComment,ocPreproc,ocLiteral,ocType,ocKeyword,ocNumber,ocBoolean,ocLabelColon,anyId,fsmType,fsmKeyword,caseLabelColon
123 " Blocks of code. rlCodeCurly is recursive.
124 syntax region rlCodeCurly matchgroup=NONE start="{" end="}" contained contains=@inlineItems
125 syntax region rlCodeSemi matchgroup=Type start="\<alphtype\>" start="\<getkey\>" start="\<access\>" start="\<variable\>" matchgroup=NONE end=";" contained contains=@inlineItems
127 syntax region rlWrite matchgroup=Type start="\<write\>" matchgroup=NONE end=";" contained contains=rlWriteKeywords,rlWriteOptions
129 syntax keyword rlWriteKeywords init data exec eof exports contained
130 syntax keyword rlWriteOptions noerror nofinal noprefix noend nocs contained
133 " Sync at the start of machine specs.
135 " Match The ragel delimiters only if there quotes no ahead on the same line.
136 " On the open marker, use & to consume the leader.
137 syntax sync match ragelSyncPat grouphere NONE "^[^\'\"%]*%%{&^[^\'\"%]*"
138 syntax sync match ragelSyncPat grouphere NONE "^[^\'\"%]*%%[^{]&^[^\'\"%]*"
139 syntax sync match ragelSyncPat grouphere NONE "^[^\'\"]*}%%"
142 " Specifying Groups
144 hi link ocComment Comment
145 hi link ocPreproc Macro
146 hi link ocLiteral String
147 hi link ocType Type
148 hi link ocKeyword Keyword
149 hi link ocNumber Number
150 hi link ocBoolean Boolean
151 hi link rlComment Comment
152 hi link rlNumber Number
153 hi link rlLiteral String
154 hi link rlAugmentOps Keyword
155 hi link rlExprKeywords Keyword
156 hi link rlWriteKeywords Keyword
157 hi link rlWriteOptions Keyword
158 hi link rlKeywords Type
159 hi link fsmType Type
160 hi link fsmKeyword Keyword
161 hi link anyLabel Label
162 hi link caseLabelKeyword Keyword
163 hi link beginRL Type
165 let b:current_syntax = "ragel"