-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtree-sitter-cmake.ebnf
217 lines (154 loc) · 3.63 KB
/
tree-sitter-cmake.ebnf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
//
// From tree-sitter-cmake/src/grammar.json
//
//
// EBNF to generate railroad diagram at
// (IPV6) https://www.bottlecaps.de/rr/ui
// (IPV4) https://rr.red-dove.com/ui
//
source_file ::=
_untrimmed_command_invocation*
escape_sequence ::=
_escape_identity
| _escape_encoded
| _escape_semicolon
_escape_identity ::=
'\'[^A-Za-z0-9;]
_escape_encoded ::=
'\t'
| '\r'
| '\n'
_escape_semicolon ::=
';'
| '\;'
variable ::=
( [a-zA-Z0-9/_.+-] | escape_sequence | variable_ref )+
variable_ref ::=
normal_var
| env_var
| cache_var
normal_var ::=
'$' '{' variable '}'
env_var ::=
'$' 'ENV' '{' variable '}'
cache_var ::=
'$' 'CACHE' '{' variable '}'
gen_exp ::=
'$' '<' _gen_exp_content? '>'
_gen_exp_content ::=
argument _gen_exp_arguments?
_gen_exp_arguments ::=
':' ( argument [,;]? )*
argument ::=
bracket_argument
| quoted_argument
| unquoted_argument
_untrimmed_argument ::=
[ #x09#x0A#x0B#x0C#x0D]
| bracket_comment
| line_comment
| argument
| _paren_argument
_paren_argument ::=
'(' _untrimmed_argument* ')'
quoted_argument ::=
'"' quoted_element? '"'
quoted_element ::=
( variable_ref | gen_exp | _quoted_text | escape_sequence )+
_quoted_text ::=
( '$' | [^\"] )+
unquoted_argument ::=
( variable_ref | gen_exp | _unquoted_text | escape_sequence )+
_unquoted_text ::=
( '$' | [^()#x23"\] )+
body ::=
_untrimmed_command_invocation+
argument_list ::=
_untrimmed_argument+
if_command ::=
if [#x09 ]* '(' argument_list ')'
elseif_command ::=
elseif [#x09 ]* '(' argument_list ')'
else_command ::=
else [#x09 ]* '(' argument_list? ')'
endif_command ::=
endif [#x09 ]* '(' argument_list? ')'
if_condition ::=
if_command ( body | elseif_command | else_command )* endif_command
foreach_command ::=
foreach [#x09 ]* '(' argument_list ')'
endforeach_command ::=
endforeach [#x09 ]* '(' argument? ')'
foreach_loop ::=
foreach_command body endforeach_command
while_command ::=
while [#x09 ]* '(' argument_list ')'
endwhile_command ::=
endwhile [#x09 ]* '(' ( [ #x09#x0A#x0B#x0C#x0D]* argument [ #x09#x0A#x0B#x0C#x0D]* )? ')'
while_loop ::=
while_command body endwhile_command
function_command ::=
function [#x09 ]* '(' argument_list ')'
endfunction_command ::=
endfunction [#x09 ]* '(' argument_list? ')'
function_def ::=
function_command body endfunction_command
macro_command ::=
macro [#x09 ]* '(' argument_list ')'
endmacro_command ::=
endmacro [#x09 ]* '(' argument_list? ')'
macro_def ::=
macro_command body endmacro_command
block_command ::=
block [#x09 ]* '(' argument_list ')'
endblock_command ::=
endblock [#x09 ]* '(' argument_list? ')'
block_def ::=
block_command body endblock_command
normal_command ::=
identifier [#x09 ]* '(' argument_list? ')'
_command_invocation ::=
normal_command
| if_condition
| foreach_loop
| while_loop
| function_def
| macro_def
| block_def
_untrimmed_command_invocation ::=
[ #x09#x0A#x0B#x0C#x0D]
| bracket_comment
| line_comment
| _command_invocation
if ::=
[iI][fF]
elseif ::=
[eE][lL][sS][eE][iI][fF]
else ::=
[eE][lL][sS][eE]
endif ::=
[eE][nN][dD][iI][fF]
foreach ::=
[fF][oO][rR][eE][aA][cC][hH]
endforeach ::=
[eE][nN][dD][fF][oO][rR][eE][aA][cC][hH]
while ::=
[wW][hH][iI][lL][eE]
endwhile ::=
[eE][nN][dD][wW][hH][iI][lL][eE]
function ::=
[fF][uU][nN][cC][tT][iI][oO][nN]
endfunction ::=
[eE][nN][dD][fF][uU][nN][cC][tT][iI][oO][nN]
macro ::=
[mM][aA][cC][rR][oO]
endmacro ::=
[eE][nN][dD][mM][aA][cC][rR][oO]
block ::=
[bB][lL][oO][cC][kK]
endblock ::=
[eE][nN][dD][bB][lL][oO][cC][kK]
identifier ::=
[A-Za-z_][A-Za-z0-9_]*
integer ::=
[+-]*[0-9]+