$(SUBDIRS) needs to go inside DIST_SUBDIRS.
[external/ragel.git] / ragel-m.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 " 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"
40
41 " Numbers
42 syntax match ocNumber "[0-9][0-9]*"
43 syntax match ocNumber "0x[0-9a-fA-F][0-9a-fA-F]*"
44
45 " Booleans
46 syntax keyword ocBoolean true false
47
48 " Identifiers
49 syntax match anyId "[a-zA-Z_][a-zA-Z_0-9]*"
50
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
54
55 syntax cluster rlItems contains=rlComment,rlLiteral,rlAugmentOps,rlOtherOps,rlKeywords,rlWrite,rlCodeCurly,rlCodeSemi,rlNumber,anyId,rlLabelColon,rlExprKeywords
56
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
60
61 " Comments
62 syntax match rlComment "#.*$" contained
63
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
69
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
73
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
82
83 syntax match rlOtherOps ":>" contained
84 syntax match rlOtherOps ":>>" contained
85 syntax match rlOtherOps "<:" contained
86
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
92
93 " Case Labels
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
99
100 " Labels
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
103
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
107
108 " All items that can go in a code block.
109
110 syntax cluster inlineItems contains=rlCodeCurly,ocComment,ocPreproc,ocLiteral,ocType,ocKeyword,ocNumber,ocBoolean,ocLabelColon,anyId,fsmType,fsmKeyword,caseLabelColon
111
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
115
116 syntax region rlWrite matchgroup=Type start="\<write\>" matchgroup=NONE end="[;)]" contained contains=rlWriteKeywords,rlWriteOptions
117
118 syntax keyword rlWriteKeywords init data exec exports start error first_final contained
119 syntax keyword rlWriteOptions noerror nofinal noprefix noend nocs contained
120
121 "
122 " Sync at the start of machine specs.
123 "
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 "^[^\'\"]*}%%"
129
130 "
131 " Specifying Groups
132 "
133 hi link ocComment Comment
134 hi link ocPreproc Macro
135 hi link ocLiteral String
136 hi link ocType Type
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
148 hi link fsmType Type
149 hi link fsmKeyword Keyword
150 hi link anyLabel Label
151 hi link caseLabelKeyword Keyword
152 hi link beginRL Type
153  
154 let b:current_syntax = "ragel"