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> | 2024-01-16 18:37:16 +0100 |
commit | 8c465d5fb09d1c7769ba4d9ce641e3e7c261b528 (patch) | |
tree | ea9d668884b41c0024c62e74e2a361d018df9933 /gcc/rust | |
parent | c1b343da33fe7038522d7c0f28b7e061707ccec7 (diff) | |
download | gcc-8c465d5fb09d1c7769ba4d9ce641e3e7c261b528.zip gcc-8c465d5fb09d1c7769ba4d9ce641e3e7c261b528.tar.gz gcc-8c465d5fb09d1c7769ba4d9ce641e3e7c261b528.tar.bz2 |
gccrs: 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>
Diffstat (limited to 'gcc/rust')
-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: |