]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: tokenstream: Convert single punctuation tokens
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Thu, 27 Apr 2023 11:24:40 +0000 (13:24 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:37:16 +0000 (18:37 +0100)
Add the code to convert single punctuation tokens to a tokenstream
element.

gcc/rust/ChangeLog:

* ast/rust-ast-tokenstream.cc (TokenStream::collect): Add
conversion for single punctuation tokens.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ast/rust-ast-tokenstream.cc

index 417c0f30c1aa453d9b4cf4d3420390564368c0e1..134292142177917b1a0f3211497dfc49eb170546 100644 (file)
@@ -50,6 +50,33 @@ TokenStream::collect () const
     {
       switch (token->get_id ())
        {
+       // Alone punct tokens
+       case EQUAL:
+       case RIGHT_ANGLE:
+       case LEFT_ANGLE:
+       case EXCLAM:
+       case TILDE:
+       case PLUS:
+       case MINUS:
+       case ASTERISK:
+       case DIV:
+       case PERCENT:
+       case CARET:
+       case AMP:
+       case PIPE:
+       case PATTERN_BIND:
+       case DOT:
+       case COMMA:
+       case SEMICOLON:
+       case COLON:
+       case HASH:
+       case DOLLAR_SIGN:
+       case QUESTION_MARK:
+       case SINGLE_QUOTE:
+         trees.back ().push (ProcMacro::TokenTree::make_tokentree (
+           ProcMacro::Punct::make_punct (token->as_string ()[0],
+                                         ProcMacro::ALONE)));
+         break;
        case RIGHT_PAREN:
          pop_group (trees, ProcMacro::PARENTHESIS);
          break;