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 | |
parent | 5af32aeb2b83c7ae8adf3e088bf4f3691aa45eb1 (diff) |
Update grammar
Diffstat (limited to 'xtask/src')
-rw-r--r-- | xtask/src/ast_src.rs | 6 | ||||
-rw-r--r-- | xtask/src/codegen/gen_syntax.rs | 11 |
2 files changed, 8 insertions, 9 deletions
diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs index 1386fc4e7..adc191254 100644 --- a/xtask/src/ast_src.rs +++ b/xtask/src/ast_src.rs | |||
@@ -113,12 +113,12 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc { | |||
113 | "TUPLE_TYPE", | 113 | "TUPLE_TYPE", |
114 | "NEVER_TYPE", | 114 | "NEVER_TYPE", |
115 | "PATH_TYPE", | 115 | "PATH_TYPE", |
116 | "POINTER_TYPE", | 116 | "PTR_TYPE", |
117 | "ARRAY_TYPE", | 117 | "ARRAY_TYPE", |
118 | "SLICE_TYPE", | 118 | "SLICE_TYPE", |
119 | "REFERENCE_TYPE", | 119 | "REF_TYPE", |
120 | "INFER_TYPE", | 120 | "INFER_TYPE", |
121 | "FN_POINTER_TYPE", | 121 | "FN_PTR_TYPE", |
122 | "FOR_TYPE", | 122 | "FOR_TYPE", |
123 | "IMPL_TRAIT_TYPE", | 123 | "IMPL_TRAIT_TYPE", |
124 | "DYN_TRAIT_TYPE", | 124 | "DYN_TRAIT_TYPE", |
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; |