aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/grammar.ron
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-09-16 10:54:24 +0100
committerAleksey Kladov <[email protected]>2018-09-16 11:07:39 +0100
commitb5021411a84822cb3f1e3aeffad9550dd15bdeb6 (patch)
tree9dca564f8e51b298dced01c4ce669c756dce3142 /crates/ra_syntax/src/grammar.ron
parentba0bfeee12e19da40b5eabc8d0408639af10e96f (diff)
rename all things
Diffstat (limited to 'crates/ra_syntax/src/grammar.ron')
-rw-r--r--crates/ra_syntax/src/grammar.ron538
1 files changed, 538 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron
new file mode 100644
index 000000000..77ae4c7db
--- /dev/null
+++ b/crates/ra_syntax/src/grammar.ron
@@ -0,0 +1,538 @@
1Grammar(
2 single_byte_tokens: [
3 [";", "SEMI"],
4 [",", "COMMA"],
5 ["(", "L_PAREN"],
6 [")", "R_PAREN"],
7 ["{", "L_CURLY"],
8 ["}", "R_CURLY"],
9 ["[", "L_BRACK"],
10 ["]", "R_BRACK"],
11 ["<", "L_ANGLE"],
12 [">", "R_ANGLE"],
13 ["@", "AT"],
14 ["#", "POUND"],
15 ["~", "TILDE"],
16 ["?", "QUESTION"],
17 ["$", "DOLLAR"],
18 ["&", "AMP"],
19 ["|", "PIPE"],
20 ["+", "PLUS"],
21 ["*", "STAR"],
22 ["/", "SLASH"],
23 ["^", "CARET"],
24 ["%", "PERCENT"],
25 ],
26 multi_byte_tokens: [
27 [".", "DOT"],
28 ["..", "DOTDOT"],
29 ["...", "DOTDOTDOT"],
30 ["..=", "DOTDOTEQ"],
31 [":", "COLON"],
32 ["::", "COLONCOLON"],
33 ["=", "EQ"],
34 ["==", "EQEQ"],
35 ["=>", "FAT_ARROW"],
36 ["!", "EXCL"],
37 ["!=", "NEQ"],
38 ["-", "MINUS"],
39 ["->", "THIN_ARROW"],
40 ["<=", "LTEQ"],
41 [">=", "GTEQ"],
42 ["+=", "PLUSEQ"],
43 ["-=", "MINUSEQ"],
44 ["|=", "PIPEEQ"],
45 ["&=", "AMPEQ"],
46 ["^=", "CARETEQ"],
47 ["/=", "SLASHEQ"],
48 ["*=", "STAREQ"],
49 ["&&", "AMPAMP"],
50 ["||", "PIPEPIPE"],
51 ["<<", "SHL"],
52 [">>", "SHR"],
53 ["<<=", "SHLEQ"],
54 [">>=", "SHREQ"],
55 ],
56 keywords: [
57 "use",
58 "fn",
59 "struct",
60 "enum",
61 "trait",
62 "impl",
63 "dyn",
64 "true",
65 "false",
66 "as",
67 "extern",
68 "crate",
69 "mod",
70 "pub",
71 "self",
72 "super",
73 "in",
74 "where",
75 "for",
76 "loop",
77 "while",
78 "continue",
79 "break",
80 "if",
81 "else",
82 "match",
83 "const",
84 "static",
85 "mut",
86 "unsafe",
87 "type",
88 "ref",
89 "let",
90 "move",
91 "return",
92 ],
93 contextual_keywords: [
94 "auto",
95 "default",
96 "union",
97 ],
98 tokens: [
99 "ERROR",
100 "IDENT",
101 "UNDERSCORE",
102 "WHITESPACE",
103 "INT_NUMBER",
104 "FLOAT_NUMBER",
105 "LIFETIME",
106 "CHAR",
107 "BYTE",
108 "STRING",
109 "RAW_STRING",
110 "BYTE_STRING",
111 "RAW_BYTE_STRING",
112 "COMMENT",
113 "DOC_COMMENT",
114 "SHEBANG",
115 ],
116 nodes: [
117 "ROOT",
118
119 "STRUCT_DEF",
120 "ENUM_DEF",
121 "FN_DEF",
122 "RET_TYPE",
123 "EXTERN_CRATE_ITEM",
124 "MODULE",
125 "USE_ITEM",
126 "STATIC_DEF",
127 "CONST_DEF",
128 "TRAIT_DEF",
129 "IMPL_ITEM",
130 "TYPE_DEF",
131 "MACRO_CALL",
132 "TOKEN_TREE",
133
134 "PAREN_TYPE",
135 "TUPLE_TYPE",
136 "NEVER_TYPE",
137 "PATH_TYPE",
138 "POINTER_TYPE",
139 "ARRAY_TYPE",
140 "SLICE_TYPE",
141 "REFERENCE_TYPE",
142 "PLACEHOLDER_TYPE",
143 "FN_POINTER_TYPE",
144 "FOR_TYPE",
145 "IMPL_TRAIT_TYPE",
146 "DYN_TRAIT_TYPE",
147
148 "REF_PAT",
149 "BIND_PAT",
150 "PLACEHOLDER_PAT",
151 "PATH_PAT",
152 "STRUCT_PAT",
153 "FIELD_PAT_LIST",
154 "TUPLE_STRUCT_PAT",
155 "TUPLE_PAT",
156 "SLICE_PAT",
157 "RANGE_PAT",
158
159 // atoms
160 "TUPLE_EXPR",
161 "ARRAY_EXPR",
162 "PAREN_EXPR",
163 "PATH_EXPR",
164 "LAMBDA_EXPR",
165 "IF_EXPR",
166 "WHILE_EXPR",
167 "CONDITION",
168 "LOOP_EXPR",
169 "FOR_EXPR",
170 "CONTINUE_EXPR",
171 "BREAK_EXPR",
172 "LABEL",
173 "BLOCK_EXPR",
174 "RETURN_EXPR",
175 "MATCH_EXPR",
176 "MATCH_ARM_LIST",
177 "MATCH_ARM",
178 "MATCH_GUARD",
179 "STRUCT_LIT",
180 "NAMED_FIELD_LIST",
181 "NAMED_FIELD",
182
183 // postfix
184 "CALL_EXPR",
185 "INDEX_EXPR",
186 "METHOD_CALL_EXPR",
187 "FIELD_EXPR",
188 "TRY_EXPR",
189 "CAST_EXPR",
190
191 // unary
192 "REF_EXPR",
193 "PREFIX_EXPR",
194
195 "RANGE_EXPR", // just weird
196 "BIN_EXPR",
197
198 "BLOCK",
199 "EXTERN_BLOCK",
200 "EXTERN_ITEM_LIST",
201 "ENUM_VARIANT",
202 "NAMED_FIELD_DEF_LIST",
203 "NAMED_FIELD_DEF",
204 "POS_FIELD_LIST",
205 "POS_FIELD",
206 "ENUM_VARIANT_LIST",
207 "ITEM_LIST",
208 "ATTR",
209 "META_ITEM", // not an item actually
210 "USE_TREE",
211 "USE_TREE_LIST",
212 "PATH",
213 "PATH_SEGMENT",
214 "LITERAL",
215 "ALIAS",
216 "VISIBILITY",
217 "WHERE_CLAUSE",
218 "WHERE_PRED",
219 "ABI",
220 "NAME",
221 "NAME_REF",
222
223 "LET_STMT",
224 "EXPR_STMT",
225
226 "TYPE_PARAM_LIST",
227 "LIFETIME_PARAM",
228 "TYPE_PARAM",
229 "TYPE_ARG_LIST",
230 "LIFETIME_ARG",
231 "TYPE_ARG",
232 "ASSOC_TYPE_ARG",
233
234 "PARAM_LIST",
235 "PARAM",
236 "SELF_PARAM",
237 "ARG_LIST",
238 ],
239 ast: {
240 "Root": (
241 traits: [ "ModuleItemOwner", "FnDefOwner" ],
242 collections: [
243 ["modules", "Module"],
244 ]
245 ),
246 "FnDef": (
247 traits: [
248 "NameOwner",
249 "TypeParamsOwner",
250 "AttrsOwner",
251 ],
252 options: [ "ParamList", ["body", "Block"], "RetType" ],
253 ),
254 "RetType": (),
255 "StructDef": (
256 traits: [
257 "NameOwner",
258 "TypeParamsOwner",
259 "AttrsOwner",
260 ],
261 collections: [
262 ["fields", "NamedFieldDef"]
263 ]
264 ),
265 "NamedFieldDef": ( traits: ["NameOwner", "AttrsOwner"] ),
266 "EnumDef": ( traits: [
267 "NameOwner",
268 "TypeParamsOwner",
269 "AttrsOwner",
270 ] ),
271 "TraitDef": ( traits: ["NameOwner", "AttrsOwner"] ),
272 "Module": (
273 traits: ["NameOwner", "AttrsOwner" ],
274 options: [ "ItemList" ]
275 ),
276 "ItemList": (
277 traits: [ "FnDefOwner", "ModuleItemOwner" ],
278 ),
279 "ConstDef": ( traits: [
280 "NameOwner",
281 "TypeParamsOwner",
282 "AttrsOwner",
283 ] ),
284 "StaticDef": ( traits: [
285 "NameOwner",
286 "TypeParamsOwner",
287 "AttrsOwner",
288 ] ),
289 "TypeDef": ( traits: [
290 "NameOwner",
291 "TypeParamsOwner",
292 "AttrsOwner",
293 ] ),
294 "ImplItem": (),
295
296 "ParenType": (),
297 "TupleType": (),
298 "NeverType": (),
299 "PathType": (),
300 "PointerType": (),
301 "ArrayType": (),
302 "SliceType": (),
303 "ReferenceType": (),
304 "PlaceholderType": (),
305 "FnPointerType": (),
306 "ForType": (),
307 "ImplTraitType": (),
308 "DynTraitType": (),
309
310 "TypeRef": ( enum: [
311 "ParenType",
312 "TupleType",
313 "NeverType",
314 "PathType",
315 "PointerType",
316 "ArrayType",
317 "SliceType",
318 "ReferenceType",
319 "PlaceholderType",
320 "FnPointerType",
321 "ForType",
322 "ImplTraitType",
323 "DynTraitType",
324 ]),
325
326 "NominalDef": (
327 enum: ["StructDef", "EnumDef"],
328 traits: [
329 "NameOwner",
330 "TypeParamsOwner",
331 "AttrsOwner"
332 ],
333 ),
334 "ModuleItem": (
335 enum: ["StructDef", "EnumDef", "FnDef", "TraitDef", "TypeDef", "ImplItem",
336 "UseItem", "ExternCrateItem", "ConstDef", "StaticDef", "Module" ]
337 ),
338
339 "TupleExpr": (),
340 "ArrayExpr": (),
341 "ParenExpr": (),
342 "PathExpr": (),
343 "LambdaExpr": (
344 options: [
345 "ParamList",
346 ["body", "Expr"],
347 ]
348 ),
349 "IfExpr": (
350 options: [ "Condition" ]
351 ),
352 "LoopExpr": (
353 traits: ["LoopBodyOwner"],
354 ),
355 "ForExpr": (
356 traits: ["LoopBodyOwner"],
357 options: [
358 "Pat",
359 ["iterable", "Expr"],
360 ]
361 ),
362 "WhileExpr": (
363 traits: ["LoopBodyOwner"],
364 options: [ "Condition" ]
365 ),
366 "ContinueExpr": (),
367 "BreakExpr": (),
368 "Label": (),
369 "BlockExpr": (
370 options: [ "Block" ]
371 ),
372 "ReturnExpr": (),
373 "MatchExpr": (
374 options: [ "Expr", "MatchArmList" ],
375 ),
376 "MatchArmList": (
377 collections: [ ["arms", "MatchArm"] ],
378 ),
379 "MatchArm": (
380 options: [
381 [ "guard", "MatchGuard" ],
382 "Expr",
383 ],
384 collections: [ [ "pats", "Pat" ] ]
385 ),
386 "MatchGuard": (),
387 "StructLit": (),
388 "NamedFieldList": (),
389 "NamedField": (),
390 "CallExpr": (
391 traits: ["ArgListOwner"],
392 options: [ "Expr" ],
393 ),
394 "MethodCallExpr": (
395 traits: ["ArgListOwner"],
396 options: [ "Expr" ],
397 ),
398 "IndexExpr": (),
399 "FieldExpr": (),
400 "TryExpr": (),
401 "CastExpr": (),
402 "RefExpr": (),
403 "PrefixExpr": (),
404 "RangeExpr": (),
405 "BinExpr": (),
406 "Literal": (),
407
408 "Expr": (
409 enum: [
410 "TupleExpr",
411 "ArrayExpr",
412 "ParenExpr",
413 "PathExpr",
414 "LambdaExpr",
415 "IfExpr",
416 "LoopExpr",
417 "ForExpr",
418 "WhileExpr",
419 "ContinueExpr",
420 "BreakExpr",
421 "Label",
422 "BlockExpr",
423 "ReturnExpr",
424 "MatchExpr",
425 "MatchArmList",
426 "MatchArm",
427 "MatchGuard",
428 "StructLit",
429 "NamedFieldList",
430 "NamedField",
431 "CallExpr",
432 "IndexExpr",
433 "MethodCallExpr",
434 "FieldExpr",
435 "TryExpr",
436 "CastExpr",
437 "RefExpr",
438 "PrefixExpr",
439 "RangeExpr",
440 "BinExpr",
441 "Literal",
442 ],
443 ),
444
445 "RefPat": (),
446 "BindPat": ( traits: ["NameOwner"] ),
447 "PlaceholderPat": (),
448 "PathPat": (),
449 "StructPat": (),
450 "FieldPatList": (),
451 "TupleStructPat": (),
452 "TuplePat": (),
453 "SlicePat": (),
454 "RangePat": (),
455
456 "Pat": (
457 enum: [
458 "RefPat",
459 "BindPat",
460 "PlaceholderPat",
461 "PathPat",
462 "StructPat",
463 "FieldPatList",
464 "TupleStructPat",
465 "TuplePat",
466 "SlicePat",
467 "RangePat",
468 ],
469 ),
470
471 "Name": (),
472 "NameRef": (),
473 "Attr": ( options: [ ["value", "TokenTree"] ] ),
474 "TokenTree": (),
475 "TypeParamList": (
476 collections: [
477 ["type_params", "TypeParam" ],
478 ["lifetime_params", "LifetimeParam" ],
479 ]
480 ),
481 "TypeParam": ( traits: ["NameOwner"] ),
482 "LifetimeParam": ( options: [ "Lifetime" ] ),
483 "Lifetime": (),
484 "WhereClause": (),
485 "ExprStmt": (
486 options: [ ["expr", "Expr"] ]
487 ),
488 "LetStmt": ( options: [
489 ["pat", "Pat"],
490 ["initializer", "Expr"],
491 ]),
492 "Condition": (
493 options: [ "Pat", "Expr" ]
494 ),
495 "Stmt": (
496 enum: ["ExprStmt", "LetStmt"],
497 ),
498 "Block": (
499 options: [ "Expr" ],
500 collections: [
501 ["statements", "Stmt"],
502 ]
503 ),
504 "ParamList": (
505 options: [ "SelfParam" ],
506 collections: [
507 ["params", "Param"]
508 ]
509 ),
510 "SelfParam": (),
511 "Param": (
512 options: [ "Pat" ],
513 ),
514 "UseItem": (
515 options: [ "UseTree" ]
516 ),
517 "UseTree": (
518 options: [ "Path", "UseTreeList" ]
519 ),
520 "UseTreeList": (
521 collections: [["use_trees", "UseTree"]]
522 ),
523 "ExternCrateItem": (),
524 "ArgList": (
525 collections: [
526 ["args", "Expr"]
527 ]
528 ),
529 "Path": (
530 options: [
531 ["segment", "PathSegment"]
532 ]
533 ),
534 "PathSegment": (
535 options: [ "NameRef" ]
536 ),
537 },
538)