diff options
author | Aleksey Kladov <[email protected]> | 2020-08-01 12:47:19 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-08-01 12:47:19 +0100 |
commit | bff8dd094958f1abe2fcfe8fe9f15dc7a7e6b53e (patch) | |
tree | cb6e4783b74d04ae2188fb04b652488e97429b99 /xtask/src/codegen | |
parent | 5af32aeb2b83c7ae8adf3e088bf4f3691aa45eb1 (diff) |
Update grammar
Diffstat (limited to 'xtask/src/codegen')
-rw-r--r-- | xtask/src/codegen/gen_syntax.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs index 4602ff1d7..cafad8070 100644 --- a/xtask/src/codegen/gen_syntax.rs +++ b/xtask/src/codegen/gen_syntax.rs | |||
@@ -10,7 +10,7 @@ use std::{ | |||
10 | 10 | ||
11 | use proc_macro2::{Punct, Spacing}; | 11 | use proc_macro2::{Punct, Spacing}; |
12 | use quote::{format_ident, quote}; | 12 | use quote::{format_ident, quote}; |
13 | use ungrammar::{Grammar, Rule}; | 13 | use ungrammar::{rust_grammar, Grammar, Rule}; |
14 | 14 | ||
15 | use crate::{ | 15 | use crate::{ |
16 | ast_src::{AstEnumSrc, AstNodeSrc, AstSrc, Cardinality, Field, KindsSrc, KINDS_SRC}, | 16 | ast_src::{AstEnumSrc, AstNodeSrc, AstSrc, Cardinality, Field, KindsSrc, KINDS_SRC}, |
@@ -19,9 +19,7 @@ use crate::{ | |||
19 | }; | 19 | }; |
20 | 20 | ||
21 | pub fn generate_syntax(mode: Mode) -> Result<()> { | 21 | pub fn generate_syntax(mode: Mode) -> Result<()> { |
22 | let grammar = include_str!("rust.ungram") | 22 | let grammar = rust_grammar(); |
23 | .parse::<Grammar>() | ||
24 | .unwrap_or_else(|err| panic!("\n \x1b[91merror\x1b[0m: {}\n", err)); | ||
25 | let ast = lower(&grammar); | 23 | let ast = lower(&grammar); |
26 | 24 | ||
27 | let syntax_kinds_file = project_root().join(codegen::SYNTAX_KINDS); | 25 | let syntax_kinds_file = project_root().join(codegen::SYNTAX_KINDS); |
@@ -538,6 +536,7 @@ fn lower_enum(grammar: &Grammar, rule: &Rule) -> Option<Vec<String>> { | |||
538 | for alternative in alternatives { | 536 | for alternative in alternatives { |
539 | match alternative { | 537 | match alternative { |
540 | Rule::Node(it) => variants.push(grammar[*it].name.clone()), | 538 | Rule::Node(it) => variants.push(grammar[*it].name.clone()), |
539 | Rule::Token(it) if grammar[*it].name == ";" => (), | ||
541 | _ => return None, | 540 | _ => return None, |
542 | } | 541 | } |
543 | } | 542 | } |
@@ -591,8 +590,8 @@ fn lower_rule(acc: &mut Vec<Field>, grammar: &Grammar, label: Option<&String>, r | |||
591 | | "index" | 590 | | "index" |
592 | | "base" | 591 | | "base" |
593 | | "value" | 592 | | "value" |
594 | | "target_type" | 593 | | "trait" |
595 | | "target_trait" | 594 | | "self_ty" |
596 | ); | 595 | ); |
597 | if manually_implemented { | 596 | if manually_implemented { |
598 | return; | 597 | return; |