aboutsummaryrefslogtreecommitdiff
path: root/xtask
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-08-01 12:49:36 +0100
committerGitHub <[email protected]>2020-08-01 12:49:36 +0100
commitcf17366df97d460f246f69d06fbfb129074d1a5c (patch)
treecb6e4783b74d04ae2188fb04b652488e97429b99 /xtask
parent5af32aeb2b83c7ae8adf3e088bf4f3691aa45eb1 (diff)
parentbff8dd094958f1abe2fcfe8fe9f15dc7a7e6b53e (diff)
Merge #5642
5642: Grammar updates r=matklad a=matklad bors r+ Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'xtask')
-rw-r--r--xtask/Cargo.toml2
-rw-r--r--xtask/src/ast_src.rs6
-rw-r--r--xtask/src/codegen/gen_syntax.rs11
3 files changed, 9 insertions, 10 deletions
diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml
index 72a2ae26b..1a1140b04 100644
--- a/xtask/Cargo.toml
+++ b/xtask/Cargo.toml
@@ -15,6 +15,6 @@ flate2 = "1.0"
15pico-args = "0.3.1" 15pico-args = "0.3.1"
16proc-macro2 = "1.0.8" 16proc-macro2 = "1.0.8"
17quote = "1.0.2" 17quote = "1.0.2"
18ungrammar = "0.1.0" 18ungrammar = "1.1.1"
19walkdir = "2.3.1" 19walkdir = "2.3.1"
20write-json = "0.1.0" 20write-json = "0.1.0"
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
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;