Use portable types in the C/C++ code generator
[ragel-jkt.git] / ragel-m.vim
blobe374562851219c911448b86a110ebc63953f57de
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 " Objective-C Directives
36 syntax match ocKeyword "@public\|@private\|@protected"
37 syntax match ocKeyword "@interface\|@implementation"
38 syntax match ocKeyword "@class\|@end\|@defs"
39 syntax match ocKeyword "@encode\|@protocol\|@selector"
41 " Numbers
42 syntax match ocNumber "[0-9][0-9]*"
43 syntax match ocNumber "0x[0-9a-fA-F][0-9a-fA-F]*"
45 " Booleans
46 syntax keyword ocBoolean true false
48 " Identifiers
49 syntax match anyId "[a-zA-Z_][a-zA-Z_0-9]*"
51 " Inline code only
52 syntax keyword fsmType fpc fc fcurs fbuf fblen ftargs fstack
53 syntax keyword fsmKeyword fhold fgoto fcall fret fentry fnext fexec fbreak
55 syntax cluster rlItems contains=rlComment,rlLiteral,rlAugmentOps,rlOtherOps,rlKeywords,rlWrite,rlCodeCurly,rlCodeSemi,rlNumber,anyId,rlLabelColon,rlExprKeywords,rlBuiltIns
57 syntax region machineSpec1 matchgroup=beginRL start="%%{" end="}%%" contains=@rlItems
58 syntax region machineSpec2 matchgroup=beginRL start="%%[^{]"rs=e-1 end="$" keepend contains=@rlItems
59 syntax region machineSpec2 matchgroup=beginRL start="%%$" end="$" keepend contains=@rlItems
61 " Comments
62 syntax match rlComment "#.*$" contained
64 " Literals
65 syntax match rlLiteral "'\(\\.\|[^'\\]\)*'[i]*" contained
66 syntax match rlLiteral "\"\(\\.\|[^\"\\]\)*\"[i]*" contained
67 syntax match rlLiteral /\/\(\\.\|[^\/\\]\)*\/[i]*/ contained
68 syntax match rlLiteral "\[\(\\.\|[^\]\\]\)*\]" contained
70 " Numbers
71 syntax match rlNumber "[0-9][0-9]*" contained
72 syntax match rlNumber "0x[0-9a-fA-F][0-9a-fA-F]*" contained
74 " Operators
75 syntax match rlAugmentOps "[>$%@]" contained
76 syntax match rlAugmentOps "<>\|<" contained
77 syntax match rlAugmentOps "[>\<$%@][!\^/*~]" contained
78 syntax match rlAugmentOps "[>$%]?" contained
79 syntax match rlAugmentOps "<>[!\^/*~]" contained
80 syntax match rlAugmentOps "=>" contained
81 syntax match rlOtherOps "->" contained
83 syntax match rlOtherOps ":>" contained
84 syntax match rlOtherOps ":>>" contained
85 syntax match rlOtherOps "<:" contained
87 " Keywords
88 " FIXME: Enable the range keyword post 5.17.
89 " syntax keyword rlKeywords machine action context include range contained
90 syntax keyword rlKeywords machine action context include import export prepush postpop contained
91 syntax keyword rlExprKeywords when inwhen outwhen err lerr eof from to contained
93 " Built-in rules
94 syntax keyword rlBuiltIns any ascii extend alpha digit alnum lower upper xdigit cntrl graph print punct space zlen empty contained
96 " Case Labels
97 syntax keyword caseLabelKeyword case contained
98 syntax cluster caseLabelItems contains=ocComment,ocPreproc,ocLiteral,ocType,ocKeyword,caseLabelKeyword,ocNumber,ocBoolean,anyId,fsmType,fsmKeyword
99 syntax match caseLabelColon "case" contains=@caseLabelItems
100 syntax match caseLabelColon "case[\t ]\+.*:$" contains=@caseLabelItems
101 syntax match caseLabelColon "case[\t ]\+.*:[^=:]"me=e-1 contains=@caseLabelItems
103 " Labels
104 syntax match ocLabelColon "^[\t ]*[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:$" contains=anyLabel
105 syntax match ocLabelColon "^[\t ]*[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:[^=:]"me=e-1 contains=anyLabel
107 syntax match rlLabelColon "[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:$" contained contains=anyLabel
108 syntax match rlLabelColon "[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:[^=:>]"me=e-1 contained contains=anyLabel
109 syntax match anyLabel "[a-zA-Z_][a-zA-Z_0-9]*" contained
111 " All items that can go in a code block.
113 syntax cluster inlineItems contains=rlCodeCurly,ocComment,ocPreproc,ocLiteral,ocType,ocKeyword,ocNumber,ocBoolean,ocLabelColon,anyId,fsmType,fsmKeyword,caseLabelColon
115 " Blocks of code. rlCodeCurly is recursive.
116 syntax region rlCodeCurly matchgroup=NONE start="{" end="}" contained contains=@inlineItems
117 syntax region rlCodeSemi matchgroup=Type start="\<alphtype\>" start="\<getkey\>" start="\<access\>" start="\<variable\>" matchgroup=NONE end=";" contained contains=@inlineItems
119 syntax region rlWrite matchgroup=Type start="\<write\>" matchgroup=NONE end="[;)]" contained contains=rlWriteKeywords,rlWriteOptions
121 syntax keyword rlWriteKeywords init data exec exports start error first_final contained
122 syntax keyword rlWriteOptions noerror nofinal noprefix noend nocs contained
125 " Sync at the start of machine specs.
127 " Match The ragel delimiters only if there quotes no ahead on the same line.
128 " On the open marker, use & to consume the leader.
129 syntax sync match ragelSyncPat grouphere NONE "^[^\'\"%]*%%{&^[^\'\"%]*"
130 syntax sync match ragelSyncPat grouphere NONE "^[^\'\"%]*%%[^{]&^[^\'\"%]*"
131 syntax sync match ragelSyncPat grouphere NONE "^[^\'\"]*}%%"
134 " Specifying Groups
136 hi link ocComment Comment
137 hi link ocPreproc Macro
138 hi link ocLiteral String
139 hi link ocType Type
140 hi link ocKeyword Keyword
141 hi link ocNumber Number
142 hi link ocBoolean Boolean
143 hi link rlComment Comment
144 hi link rlNumber Number
145 hi link rlLiteral String
146 hi link rlAugmentOps Keyword
147 hi link rlExprKeywords Keyword
148 hi link rlWriteKeywords Keyword
149 hi link rlWriteOptions Keyword
150 hi link rlKeywords Type
151 hi link fsmType Type
152 hi link fsmKeyword Keyword
153 hi link anyLabel Label
154 hi link caseLabelKeyword Keyword
155 hi link beginRL Type
156 hi link rlBuiltIns Constant
158 let b:current_syntax = "ragel"