Import from my private repository. Snapshot after version 5.16, immediately
[external/ragel.git] / ragel.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 " 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
42
43 " Java Keywords
44 syntax keyword ocType byte short char int
45
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"
51
52 " Numbers
53 syntax match ocNumber "[0-9][0-9]*"
54 syntax match ocNumber "0x[0-9a-fA-F][0-9a-fA-F]*"
55
56 " Booleans
57 syntax keyword ocBoolean true false
58
59 " Identifiers
60 syntax match anyId "[a-zA-Z_][a-zA-Z_0-9]*"
61
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
65
66 syntax cluster rlItems contains=rlComment,rlLiteral,rlAugmentOps,rlOtherOps,rlKeywords,rlWrite,rlCodeCurly,rlCodeSemi,rlNumber,anyId,rlLabelColon,rlExprKeywords
67
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
71
72 " Comments
73 syntax match rlComment "#.*$" contained
74
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
80
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
84
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
93
94 syntax match rlOtherOps ":>" contained
95 syntax match rlOtherOps ":>>" contained
96 syntax match rlOtherOps "<:" contained
97
98 " Keywords
99 syntax keyword rlKeywords machine action context include range contained
100 syntax keyword rlExprKeywords when err lerr eof from to contained
101
102 " Case Labels
103 syntax keyword caseLabelKeyword case contained
104 syntax cluster caseLabelItems contains=ocComment,ocPreproc,ocLiteral,ocType,ocKeyword,caseLabelKeyword,ocNumber,ocBoolean,anyId,fsmType,fsmKeyword
105 syntax match caseLabelColon "case" contains=@caseLabelItems
106 syntax match caseLabelColon "case[\t ]\+.*:$" contains=@caseLabelItems
107 syntax match caseLabelColon "case[\t ]\+.*:[^=:]"me=e-1 contains=@caseLabelItems
108
109 " Labels
110 syntax match ocLabelColon "^[\t ]*[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:$" contains=anyLabel
111 syntax match ocLabelColon "^[\t ]*[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:[^=:]"me=e-1 contains=anyLabel
112
113 syntax match rlLabelColon "[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:$" contained contains=anyLabel
114 syntax match rlLabelColon "[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:[^=:>]"me=e-1 contained contains=anyLabel
115 syntax match anyLabel "[a-zA-Z_][a-zA-Z_0-9]*" contained
116
117 " All items that can go in a code block.
118
119 syntax cluster inlineItems contains=rlCodeCurly,ocComment,ocPreproc,ocLiteral,ocType,ocKeyword,ocNumber,ocBoolean,ocLabelColon,anyId,fsmType,fsmKeyword,caseLabelColon
120
121 " Blocks of code. rlCodeCurly is recursive.
122 syntax region rlCodeCurly matchgroup=NONE start="{" end="}" contained contains=@inlineItems
123 syntax region rlCodeSemi matchgroup=Type start="\<alphtype\>" start="\<getkey\>" start="\<access\>" start="\<variable\>" matchgroup=NONE end=";" contained contains=@inlineItems
124
125 syntax region rlWrite matchgroup=Type start="\<write\>" matchgroup=NONE end=";" contained contains=rlWriteKeywords,rlWriteOptions
126
127 syntax keyword rlWriteKeywords init data exec eof contained
128 syntax keyword rlWriteOptions noerror nofinal noprefix noend contained
129
130 "
131 " Sync at the start of machine specs.
132 "
133 syntax sync match ragelSyncPat grouphere NONE "%%{&"
134 syntax sync match ragelSyncPat grouphere NONE "%%[^{]&"
135 syntax sync match ragelSyncPat grouphere NONE "}%%"
136
137 "
138 " Specifying Groups
139 "
140 hi link ocComment Comment
141 hi link ocPreproc Macro
142 hi link ocLiteral String
143 hi link ocType Type
144 hi link ocKeyword Keyword
145 hi link ocNumber Number
146 hi link ocBoolean Boolean
147 hi link rlComment Comment
148 hi link rlNumber Number
149 hi link rlLiteral String
150 hi link rlAugmentOps Keyword
151 hi link rlExprKeywords Keyword
152 hi link rlWriteKeywords Keyword
153 hi link rlWriteOptions Keyword
154 hi link rlKeywords Type
155 hi link fsmType Type
156 hi link fsmKeyword Keyword
157 hi link anyLabel Label
158 hi link caseLabelKeyword Keyword
159 hi link beginRL Type
160  
161 let b:current_syntax = "ragel"