diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-04-27 17:33:35 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2023-05-11 09:38:20 +0200 |
commit | f087501e3372e62477c9ad17670fc73245ade4a4 (patch) | |
tree | cc61f645291a5b48ce6ea361714fa5bc3527f048 | |
parent | 75eb15164a2253924e22b4559ae95b631e757759 (diff) | |
download | gcc-f087501e3372e62477c9ad17670fc73245ade4a4.zip gcc-f087501e3372e62477c9ad17670fc73245ade4a4.tar.gz gcc-f087501e3372e62477c9ad17670fc73245ade4a4.tar.bz2 |
tokenstream: Add tokens to Ident conversion
Add conversion from a rust token to tokenstream Idents.
gcc/rust/ChangeLog:
* ast/rust-ast-tokenstream.cc (TokenStream::collect): Add Ident
conversion.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
-rw-r--r-- | gcc/rust/ast/rust-ast-tokenstream.cc | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/gcc/rust/ast/rust-ast-tokenstream.cc b/gcc/rust/ast/rust-ast-tokenstream.cc index faafac4..7a28634 100644 --- a/gcc/rust/ast/rust-ast-tokenstream.cc +++ b/gcc/rust/ast/rust-ast-tokenstream.cc @@ -50,6 +50,66 @@ TokenStream::collect () const { switch (token->get_id ()) { + // Ident + case IDENTIFIER: + case ABSTRACT: + case AS: + case ASYNC: + case AUTO: + case BECOME: + case BOX: + case BREAK: + case CONST: + case CONTINUE: + case CRATE: + case DO: + case DYN: + case ELSE: + case ENUM_TOK: + case EXTERN_TOK: + case FINAL_TOK: + case FN_TOK: + case FOR: + case IF: + case IMPL: + case IN: + case LET: + case LOOP: + case MACRO: + case MATCH_TOK: + case MOD: + case MOVE: + case MUT: + case OVERRIDE_TOK: + case PRIV: + case PUB: + case REF: + case RETURN_TOK: + case SELF_ALIAS: + case SELF: + case STATIC_TOK: + case STRUCT_TOK: + case SUPER: + case TRAIT: + case TRY: + case TYPE: + case TYPEOF: + case UNSAFE: + case UNSIZED: + case USE: + case VIRTUAL: + case WHERE: + case WHILE: + case YIELD: + // Underscore is not a Punct, considered as an Ident + case UNDERSCORE: + // True and false are idents, not literals + // (https://doc.rust-lang.org/proc_macro/struct.Literal.html) + case FALSE_LITERAL: + case TRUE_LITERAL: + trees.back ().push (ProcMacro::TokenTree::make_tokentree ( + ProcMacro::Ident::make_ident (token->as_string ()))); + break; // Joint punct case OR: case PIPE_EQ: |