aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/codegen/gen_syntax.rs
diff options
context:
space:
mode:
Diffstat (limited to 'xtask/src/codegen/gen_syntax.rs')
-rw-r--r--xtask/src/codegen/gen_syntax.rs11
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
11use proc_macro2::{Punct, Spacing}; 11use proc_macro2::{Punct, Spacing};
12use quote::{format_ident, quote}; 12use quote::{format_ident, quote};
13use ungrammar::{Grammar, Rule}; 13use ungrammar::{rust_grammar, Grammar, Rule};
14 14
15use crate::{ 15use 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
21pub fn generate_syntax(mode: Mode) -> Result<()> { 21pub 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;