Just discovered that $srcdir is available in the configure script for checking
[external/ragel.git] / ragel-d.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 " Numbers
44 syntax match ocNumber "[0-9][0-9]*"
45 syntax match ocNumber "0x[0-9a-fA-F][0-9a-fA-F]*"
46
47 " Booleans
48 syntax keyword ocBoolean true false
49
50 " Identifiers
51 syntax match anyId "[a-zA-Z_][a-zA-Z_0-9]*"
52
53 " Inline code only
54 syntax keyword fsmType fpc fc fcurs fbuf fblen ftargs fstack
55 syntax keyword fsmKeyword fhold fgoto fcall fret fentry fnext fexec fbreak
56
57 syntax cluster rlItems contains=rlComment,rlLiteral,rlAugmentOps,rlOtherOps,rlKeywords,rlWrite,rlCodeCurly,rlCodeSemi,rlNumber,anyId,rlLabelColon,rlExprKeywords
58
59 syntax region machineSpec1 matchgroup=beginRL start="%%{" end="}%%" contains=@rlItems
60 syntax region machineSpec2 matchgroup=beginRL start="%%[^{]"rs=e-1 end="$" keepend contains=@rlItems
61 syntax region machineSpec2 matchgroup=beginRL start="%%$" end="$" keepend contains=@rlItems
62
63 " Comments
64 syntax match rlComment "#.*$" contained
65
66 " Literals
67 syntax match rlLiteral "'\(\\.\|[^'\\]\)*'[i]*" contained
68 syntax match rlLiteral "\"\(\\.\|[^\"\\]\)*\"[i]*" contained
69 syntax match rlLiteral /\/\(\\.\|[^\/\\]\)*\/[i]*/ contained
70 syntax match rlLiteral "\[\(\\.\|[^\]\\]\)*\]" contained
71
72 " Numbers
73 syntax match rlNumber "[0-9][0-9]*" contained
74 syntax match rlNumber "0x[0-9a-fA-F][0-9a-fA-F]*" contained
75
76 " Operators
77 syntax match rlAugmentOps "[>$%@]" contained
78 syntax match rlAugmentOps "<>\|<" contained
79 syntax match rlAugmentOps "[>\<$%@][!\^/*~]" contained
80 syntax match rlAugmentOps "[>$%]?" contained
81 syntax match rlAugmentOps "<>[!\^/*~]" contained
82 syntax match rlAugmentOps "=>" contained
83 syntax match rlOtherOps "->" contained
84
85 syntax match rlOtherOps ":>" contained
86 syntax match rlOtherOps ":>>" contained
87 syntax match rlOtherOps "<:" contained
88
89 " Keywords
90 " FIXME: Enable the range keyword post 5.17.
91 " syntax keyword rlKeywords machine action context include range contained
92 syntax keyword rlKeywords machine action context include import export prepush postpop contained
93 syntax keyword rlExprKeywords when inwhen outwhen err lerr eof from to contained
94
95 " Case Labels
96 syntax keyword caseLabelKeyword case contained
97 syntax cluster caseLabelItems contains=ocComment,ocPreproc,ocLiteral,ocType,ocKeyword,caseLabelKeyword,ocNumber,ocBoolean,anyId,fsmType,fsmKeyword
98 syntax match caseLabelColon "case" contains=@caseLabelItems
99 syntax match caseLabelColon "case[\t ]\+.*:$" contains=@caseLabelItems
100 syntax match caseLabelColon "case[\t ]\+.*:[^=:]"me=e-1 contains=@caseLabelItems
101
102 " Labels
103 syntax match ocLabelColon "^[\t ]*[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:$" contains=anyLabel
104 syntax match ocLabelColon "^[\t ]*[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:[^=:]"me=e-1 contains=anyLabel
105
106 syntax match rlLabelColon "[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:$" contained contains=anyLabel
107 syntax match rlLabelColon "[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:[^=:>]"me=e-1 contained contains=anyLabel
108 syntax match anyLabel "[a-zA-Z_][a-zA-Z_0-9]*" contained
109
110 " All items that can go in a code block.
111
112 syntax cluster inlineItems contains=rlCodeCurly,ocComment,ocPreproc,ocLiteral,ocType,ocKeyword,ocNumber,ocBoolean,ocLabelColon,anyId,fsmType,fsmKeyword,caseLabelColon
113
114 " Blocks of code. rlCodeCurly is recursive.
115 syntax region rlCodeCurly matchgroup=NONE start="{" end="}" contained contains=@inlineItems
116 syntax region rlCodeSemi matchgroup=Type start="\<alphtype\>" start="\<getkey\>" start="\<access\>" start="\<variable\>" matchgroup=NONE end=";" contained contains=@inlineItems
117
118 syntax region rlWrite matchgroup=Type start="\<write\>" matchgroup=NONE end="[;)]" contained contains=rlWriteKeywords,rlWriteOptions
119
120 syntax keyword rlWriteKeywords init data exec exports start error first_final contained
121 syntax keyword rlWriteOptions noerror nofinal noprefix noend nocs contained
122
123 "
124 " Sync at the start of machine specs.
125 "
126 " Match The ragel delimiters only if there quotes no ahead on the same line.
127 " On the open marker, use & to consume the leader.
128 syntax sync match ragelSyncPat grouphere NONE "^[^\'\"%]*%%{&^[^\'\"%]*"
129 syntax sync match ragelSyncPat grouphere NONE "^[^\'\"%]*%%[^{]&^[^\'\"%]*"
130 syntax sync match ragelSyncPat grouphere NONE "^[^\'\"]*}%%"
131
132 "
133 " Specifying Groups
134 "
135 hi link ocComment Comment
136 hi link ocPreproc Macro
137 hi link ocLiteral String
138 hi link ocType Type
139 hi link ocKeyword Keyword
140 hi link ocNumber Number
141 hi link ocBoolean Boolean
142 hi link rlComment Comment
143 hi link rlNumber Number
144 hi link rlLiteral String
145 hi link rlAugmentOps Keyword
146 hi link rlExprKeywords Keyword
147 hi link rlWriteKeywords Keyword
148 hi link rlWriteOptions Keyword
149 hi link rlKeywords Type
150 hi link fsmType Type
151 hi link fsmKeyword Keyword
152 hi link anyLabel Label
153 hi link caseLabelKeyword Keyword
154 hi link beginRL Type
155  
156 let b:current_syntax = "ragel"