From c8b4c36f8161d34c8145a49965efee4514275989 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 10 Apr 2020 10:11:05 +0200 Subject: Semicolon token --- xtask/src/ast_src.rs | 22 +++++++++++----------- xtask/src/codegen/gen_syntax.rs | 10 ++++++++-- 2 files changed, 19 insertions(+), 13 deletions(-) (limited to 'xtask/src') diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs index 3da280551..1a6ee935f 100644 --- a/xtask/src/ast_src.rs +++ b/xtask/src/ast_src.rs @@ -319,7 +319,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { ParamList, RetType, body: BlockExpr, - Semi + T![;] } struct RetType { ThinArrow, TypeRef } @@ -327,7 +327,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { struct StructDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner { T![struct], FieldDefList, - Semi + T![;] } struct UnionDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner { @@ -368,7 +368,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { struct Module: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner { T![mod], ItemList, - Semi + T![;] } struct ItemList: ModuleItemOwner { @@ -382,7 +382,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { T![const], Eq, body: Expr, - Semi + T![;] } struct StaticDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner { @@ -390,7 +390,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { T![mut], Eq, body: Expr, - Semi + T![;] } struct TypeAliasDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeBoundsOwner { @@ -398,7 +398,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { T![type], Eq, TypeRef, - Semi + T![;] } struct ImplDef: TypeParamsOwner, AttrsOwner { @@ -416,7 +416,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { struct NeverType { Excl } struct PathType { Path } struct PointerType { Star, T![const], T![mut], TypeRef } - struct ArrayType { LBrack, TypeRef, Semi, Expr, RBrack } + struct ArrayType { LBrack, TypeRef, T![;], Expr, RBrack } struct SliceType { LBrack, TypeRef, RBrack } struct ReferenceType { Amp, Lifetime, T![mut], TypeRef } struct PlaceholderType { Underscore } @@ -426,7 +426,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { struct DynTraitType: TypeBoundsOwner { T![dyn] } struct TupleExpr: AttrsOwner { LParen, exprs: [Expr], RParen } - struct ArrayExpr: AttrsOwner { LBrack, exprs: [Expr], Semi, RBrack } + struct ArrayExpr: AttrsOwner { LBrack, exprs: [Expr], T![;], RBrack } struct ParenExpr: AttrsOwner { LParen, Expr, RParen } struct PathExpr { Path } struct LambdaExpr: AttrsOwner { @@ -520,7 +520,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { struct NameRef { NameRefToken } struct MacroCall: NameOwner, AttrsOwner,DocCommentsOwner { - Path, Excl, TokenTree, Semi + Path, Excl, TokenTree, T![;] } struct Attr { Pound, Excl, LBrack, Path, Eq, input: AttrInput, RBrack } struct TokenTree {} @@ -546,13 +546,13 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { struct WherePred: TypeBoundsOwner { Lifetime, TypeRef } struct WhereClause { T![where], predicates: [WherePred] } struct Abi { String } - struct ExprStmt: AttrsOwner { Expr, Semi } + struct ExprStmt: AttrsOwner { Expr, T![;] } struct LetStmt: AttrsOwner, TypeAscriptionOwner { T![let], Pat, Eq, initializer: Expr, - Semi, + T![;], } struct Condition { T![let], Pat, Eq, Expr } struct Block: AttrsOwner, ModuleItemOwner { diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs index c4fb29bbf..26f541da1 100644 --- a/xtask/src/codegen/gen_syntax.rs +++ b/xtask/src/codegen/gen_syntax.rs @@ -515,7 +515,7 @@ impl Field<'_> { fn token_kind(&self) -> Option { let res = match self { Field::Token(token) => { - let token = format_ident!("{}", token); + let token: proc_macro2::TokenStream = token.parse().unwrap(); quote! { T![#token] } } _ => return None, @@ -524,7 +524,13 @@ impl Field<'_> { } fn method_name(&self) -> proc_macro2::Ident { match self { - Field::Token(name) => format_ident!("{}_token", name), + Field::Token(name) => { + let name = match *name { + ";" => "semicolon", + _ => name, + }; + format_ident!("{}_token", name) + } Field::Node { name, src } => match src { FieldSrc::Shorthand => format_ident!("{}", to_lower_snake_case(name)), _ => format_ident!("{}", name), -- cgit v1.2.3