From bff8dd094958f1abe2fcfe8fe9f15dc7a7e6b53e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 1 Aug 2020 13:47:19 +0200 Subject: Update grammar --- xtask/Cargo.toml | 2 +- xtask/src/ast_src.rs | 6 +++--- xtask/src/codegen/gen_syntax.rs | 11 +++++------ 3 files changed, 9 insertions(+), 10 deletions(-) (limited to 'xtask') 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" pico-args = "0.3.1" proc-macro2 = "1.0.8" quote = "1.0.2" -ungrammar = "0.1.0" +ungrammar = "1.1.1" walkdir = "2.3.1" write-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 { "TUPLE_TYPE", "NEVER_TYPE", "PATH_TYPE", - "POINTER_TYPE", + "PTR_TYPE", "ARRAY_TYPE", "SLICE_TYPE", - "REFERENCE_TYPE", + "REF_TYPE", "INFER_TYPE", - "FN_POINTER_TYPE", + "FN_PTR_TYPE", "FOR_TYPE", "IMPL_TRAIT_TYPE", "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::{ use proc_macro2::{Punct, Spacing}; use quote::{format_ident, quote}; -use ungrammar::{Grammar, Rule}; +use ungrammar::{rust_grammar, Grammar, Rule}; use crate::{ ast_src::{AstEnumSrc, AstNodeSrc, AstSrc, Cardinality, Field, KindsSrc, KINDS_SRC}, @@ -19,9 +19,7 @@ use crate::{ }; pub fn generate_syntax(mode: Mode) -> Result<()> { - let grammar = include_str!("rust.ungram") - .parse::() - .unwrap_or_else(|err| panic!("\n \x1b[91merror\x1b[0m: {}\n", err)); + let grammar = rust_grammar(); let ast = lower(&grammar); let syntax_kinds_file = project_root().join(codegen::SYNTAX_KINDS); @@ -538,6 +536,7 @@ fn lower_enum(grammar: &Grammar, rule: &Rule) -> Option> { for alternative in alternatives { match alternative { Rule::Node(it) => variants.push(grammar[*it].name.clone()), + Rule::Token(it) if grammar[*it].name == ";" => (), _ => return None, } } @@ -591,8 +590,8 @@ fn lower_rule(acc: &mut Vec, grammar: &Grammar, label: Option<&String>, r | "index" | "base" | "value" - | "target_type" - | "target_trait" + | "trait" + | "self_ty" ); if manually_implemented { return; -- cgit v1.2.3