aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/grammar.ron14
-rw-r--r--crates/ra_syntax/src/syntax_kinds/generated.rs94
-rw-r--r--crates/ra_syntax/src/syntax_kinds/generated.rs.tera23
3 files changed, 113 insertions, 18 deletions
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron
index d4c863705..47334bdf0 100644
--- a/crates/ra_syntax/src/grammar.ron
+++ b/crates/ra_syntax/src/grammar.ron
@@ -24,6 +24,7 @@ Grammar(
24 ["/", "SLASH"], 24 ["/", "SLASH"],
25 ["^", "CARET"], 25 ["^", "CARET"],
26 ["%", "PERCENT"], 26 ["%", "PERCENT"],
27 ["_", "UNDERSCORE"],
27 ], 28 ],
28 // Tokens for which the longest match must be chosen (e.g. `..` is a DOTDOT, but `.` is a DOT) 29 // Tokens for which the longest match must be chosen (e.g. `..` is a DOTDOT, but `.` is a DOT)
29 multi_byte_tokens: [ 30 multi_byte_tokens: [
@@ -99,20 +100,21 @@ Grammar(
99 "default", 100 "default",
100 "union", 101 "union",
101 ], 102 ],
102 tokens: [ 103 literals: [
103 "ERROR",
104 "IDENT",
105 "UNDERSCORE",
106 "WHITESPACE",
107 "INT_NUMBER", 104 "INT_NUMBER",
108 "FLOAT_NUMBER", 105 "FLOAT_NUMBER",
109 "LIFETIME",
110 "CHAR", 106 "CHAR",
111 "BYTE", 107 "BYTE",
112 "STRING", 108 "STRING",
113 "RAW_STRING", 109 "RAW_STRING",
114 "BYTE_STRING", 110 "BYTE_STRING",
115 "RAW_BYTE_STRING", 111 "RAW_BYTE_STRING",
112 ],
113 tokens: [
114 "ERROR",
115 "IDENT",
116 "WHITESPACE",
117 "LIFETIME",
116 "COMMENT", 118 "COMMENT",
117 "SHEBANG", 119 "SHEBANG",
118 ], 120 ],
diff --git a/crates/ra_syntax/src/syntax_kinds/generated.rs b/crates/ra_syntax/src/syntax_kinds/generated.rs
index 14f610891..fea513458 100644
--- a/crates/ra_syntax/src/syntax_kinds/generated.rs
+++ b/crates/ra_syntax/src/syntax_kinds/generated.rs
@@ -36,6 +36,7 @@ pub enum SyntaxKind {
36 SLASH, 36 SLASH,
37 CARET, 37 CARET,
38 PERCENT, 38 PERCENT,
39 UNDERSCORE,
39 DOT, 40 DOT,
40 DOTDOT, 41 DOTDOT,
41 DOTDOTDOT, 42 DOTDOTDOT,
@@ -103,19 +104,18 @@ pub enum SyntaxKind {
103 AUTO_KW, 104 AUTO_KW,
104 DEFAULT_KW, 105 DEFAULT_KW,
105 UNION_KW, 106 UNION_KW,
106 ERROR,
107 IDENT,
108 UNDERSCORE,
109 WHITESPACE,
110 INT_NUMBER, 107 INT_NUMBER,
111 FLOAT_NUMBER, 108 FLOAT_NUMBER,
112 LIFETIME,
113 CHAR, 109 CHAR,
114 BYTE, 110 BYTE,
115 STRING, 111 STRING,
116 RAW_STRING, 112 RAW_STRING,
117 BYTE_STRING, 113 BYTE_STRING,
118 RAW_BYTE_STRING, 114 RAW_BYTE_STRING,
115 ERROR,
116 IDENT,
117 WHITESPACE,
118 LIFETIME,
119 COMMENT, 119 COMMENT,
120 SHEBANG, 120 SHEBANG,
121 SOURCE_FILE, 121 SOURCE_FILE,
@@ -275,6 +275,79 @@ impl SyntaxKind {
275 } 275 }
276 } 276 }
277 277
278 pub fn is_punct(self) -> bool {
279 match self {
280 | SEMI
281 | COMMA
282 | L_PAREN
283 | R_PAREN
284 | L_CURLY
285 | R_CURLY
286 | L_BRACK
287 | R_BRACK
288 | L_ANGLE
289 | R_ANGLE
290 | AT
291 | POUND
292 | TILDE
293 | QUESTION
294 | DOLLAR
295 | AMP
296 | PIPE
297 | PLUS
298 | STAR
299 | SLASH
300 | CARET
301 | PERCENT
302 | UNDERSCORE
303 | DOT
304 | DOTDOT
305 | DOTDOTDOT
306 | DOTDOTEQ
307 | COLON
308 | COLONCOLON
309 | EQ
310 | EQEQ
311 | FAT_ARROW
312 | EXCL
313 | NEQ
314 | MINUS
315 | THIN_ARROW
316 | LTEQ
317 | GTEQ
318 | PLUSEQ
319 | MINUSEQ
320 | PIPEEQ
321 | AMPEQ
322 | CARETEQ
323 | SLASHEQ
324 | STAREQ
325 | PERCENTEQ
326 | AMPAMP
327 | PIPEPIPE
328 | SHL
329 | SHR
330 | SHLEQ
331 | SHREQ
332 => true,
333 _ => false
334 }
335 }
336 pub fn is_literal(self) -> bool {
337 match self {
338 | INT_NUMBER
339 | FLOAT_NUMBER
340 | CHAR
341 | BYTE
342 | STRING
343 | RAW_STRING
344 | BYTE_STRING
345 | RAW_BYTE_STRING
346 => true,
347 _ => false
348 }
349 }
350
278 pub(crate) fn info(self) -> &'static SyntaxInfo { 351 pub(crate) fn info(self) -> &'static SyntaxInfo {
279 match self { 352 match self {
280 SEMI => &SyntaxInfo { name: "SEMI" }, 353 SEMI => &SyntaxInfo { name: "SEMI" },
@@ -299,6 +372,7 @@ impl SyntaxKind {
299 SLASH => &SyntaxInfo { name: "SLASH" }, 372 SLASH => &SyntaxInfo { name: "SLASH" },
300 CARET => &SyntaxInfo { name: "CARET" }, 373 CARET => &SyntaxInfo { name: "CARET" },
301 PERCENT => &SyntaxInfo { name: "PERCENT" }, 374 PERCENT => &SyntaxInfo { name: "PERCENT" },
375 UNDERSCORE => &SyntaxInfo { name: "UNDERSCORE" },
302 DOT => &SyntaxInfo { name: "DOT" }, 376 DOT => &SyntaxInfo { name: "DOT" },
303 DOTDOT => &SyntaxInfo { name: "DOTDOT" }, 377 DOTDOT => &SyntaxInfo { name: "DOTDOT" },
304 DOTDOTDOT => &SyntaxInfo { name: "DOTDOTDOT" }, 378 DOTDOTDOT => &SyntaxInfo { name: "DOTDOTDOT" },
@@ -366,19 +440,18 @@ impl SyntaxKind {
366 AUTO_KW => &SyntaxInfo { name: "AUTO_KW" }, 440 AUTO_KW => &SyntaxInfo { name: "AUTO_KW" },
367 DEFAULT_KW => &SyntaxInfo { name: "DEFAULT_KW" }, 441 DEFAULT_KW => &SyntaxInfo { name: "DEFAULT_KW" },
368 UNION_KW => &SyntaxInfo { name: "UNION_KW" }, 442 UNION_KW => &SyntaxInfo { name: "UNION_KW" },
369 ERROR => &SyntaxInfo { name: "ERROR" },
370 IDENT => &SyntaxInfo { name: "IDENT" },
371 UNDERSCORE => &SyntaxInfo { name: "UNDERSCORE" },
372 WHITESPACE => &SyntaxInfo { name: "WHITESPACE" },
373 INT_NUMBER => &SyntaxInfo { name: "INT_NUMBER" }, 443 INT_NUMBER => &SyntaxInfo { name: "INT_NUMBER" },
374 FLOAT_NUMBER => &SyntaxInfo { name: "FLOAT_NUMBER" }, 444 FLOAT_NUMBER => &SyntaxInfo { name: "FLOAT_NUMBER" },
375 LIFETIME => &SyntaxInfo { name: "LIFETIME" },
376 CHAR => &SyntaxInfo { name: "CHAR" }, 445 CHAR => &SyntaxInfo { name: "CHAR" },
377 BYTE => &SyntaxInfo { name: "BYTE" }, 446 BYTE => &SyntaxInfo { name: "BYTE" },
378 STRING => &SyntaxInfo { name: "STRING" }, 447 STRING => &SyntaxInfo { name: "STRING" },
379 RAW_STRING => &SyntaxInfo { name: "RAW_STRING" }, 448 RAW_STRING => &SyntaxInfo { name: "RAW_STRING" },
380 BYTE_STRING => &SyntaxInfo { name: "BYTE_STRING" }, 449 BYTE_STRING => &SyntaxInfo { name: "BYTE_STRING" },
381 RAW_BYTE_STRING => &SyntaxInfo { name: "RAW_BYTE_STRING" }, 450 RAW_BYTE_STRING => &SyntaxInfo { name: "RAW_BYTE_STRING" },
451 ERROR => &SyntaxInfo { name: "ERROR" },
452 IDENT => &SyntaxInfo { name: "IDENT" },
453 WHITESPACE => &SyntaxInfo { name: "WHITESPACE" },
454 LIFETIME => &SyntaxInfo { name: "LIFETIME" },
382 COMMENT => &SyntaxInfo { name: "COMMENT" }, 455 COMMENT => &SyntaxInfo { name: "COMMENT" },
383 SHEBANG => &SyntaxInfo { name: "SHEBANG" }, 456 SHEBANG => &SyntaxInfo { name: "SHEBANG" },
384 SOURCE_FILE => &SyntaxInfo { name: "SOURCE_FILE" }, 457 SOURCE_FILE => &SyntaxInfo { name: "SOURCE_FILE" },
@@ -559,6 +632,7 @@ impl SyntaxKind {
559 '/' => SLASH, 632 '/' => SLASH,
560 '^' => CARET, 633 '^' => CARET,
561 '%' => PERCENT, 634 '%' => PERCENT,
635 '_' => UNDERSCORE,
562 _ => return None, 636 _ => return None,
563 }; 637 };
564 Some(tok) 638 Some(tok)
diff --git a/crates/ra_syntax/src/syntax_kinds/generated.rs.tera b/crates/ra_syntax/src/syntax_kinds/generated.rs.tera
index 21f9444b1..837437136 100644
--- a/crates/ra_syntax/src/syntax_kinds/generated.rs.tera
+++ b/crates/ra_syntax/src/syntax_kinds/generated.rs.tera
@@ -23,7 +23,7 @@ pub enum SyntaxKind {
23{% for kw in concat(a=keywords, b=contextual_keywords) %} 23{% for kw in concat(a=keywords, b=contextual_keywords) %}
24 {{kw | upper}}_KW, 24 {{kw | upper}}_KW,
25{%- endfor -%} 25{%- endfor -%}
26{% for t in concat(a=tokens, b=nodes) %} 26{% for t in concat(a=literals, b=tokens, c=nodes) %}
27 {{t}}, 27 {{t}},
28{%- endfor %} 28{%- endfor %}
29} 29}
@@ -40,6 +40,25 @@ impl SyntaxKind {
40 } 40 }
41 } 41 }
42 42
43 pub fn is_punct(self) -> bool {
44 match self {
45{%- for t in concat(a=single_byte_tokens, b=multi_byte_tokens) %}
46 | {{t.1}}
47{%- endfor %}
48 => true,
49 _ => false
50 }
51 }
52 pub fn is_literal(self) -> bool {
53 match self {
54{%- for t in literals %}
55 | {{t}}
56{%- endfor %}
57 => true,
58 _ => false
59 }
60 }
61
43 pub(crate) fn info(self) -> &'static SyntaxInfo { 62 pub(crate) fn info(self) -> &'static SyntaxInfo {
44 match self { 63 match self {
45{%- for t in concat(a=single_byte_tokens, b=multi_byte_tokens) %} 64{%- for t in concat(a=single_byte_tokens, b=multi_byte_tokens) %}
@@ -48,7 +67,7 @@ impl SyntaxKind {
48{% for kw in concat(a=keywords, b=contextual_keywords) %} 67{% for kw in concat(a=keywords, b=contextual_keywords) %}
49 {{kw | upper}}_KW => &SyntaxInfo { name: "{{kw | upper}}_KW" }, 68 {{kw | upper}}_KW => &SyntaxInfo { name: "{{kw | upper}}_KW" },
50{%- endfor -%} 69{%- endfor -%}
51{% for t in concat(a=tokens, b=nodes) %} 70{% for t in concat(a=literals, b=tokens, c=nodes) %}
52 {{t}} => &SyntaxInfo { name: "{{t}}" }, 71 {{t}} => &SyntaxInfo { name: "{{t}}" },
53{%- endfor %} 72{%- endfor %}
54 TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" }, 73 TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" },