]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: tokenstream: Add joint punct token conversion
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Thu, 27 Apr 2023 13:17:35 +0000 (15:17 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:37:16 +0000 (18:37 +0100)
Add the conversion from tokens to punct structures in tokenstream
conversion function.

gcc/rust/ChangeLog:

* ast/rust-ast-tokenstream.cc (TokenStream::collect): Add joint
punct token conversion.

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

index 134292142177917b1a0f3211497dfc49eb170546..faafac4e14b30d858a7157d7d585b221a9f28615 100644 (file)
@@ -50,6 +50,42 @@ TokenStream::collect () const
     {
       switch (token->get_id ())
        {
+       // Joint punct
+       case OR:
+       case PIPE_EQ:
+       case CARET_EQ:
+       case RIGHT_SHIFT_EQ:
+       case RIGHT_SHIFT:
+       case GREATER_OR_EQUAL:
+       case MATCH_ARROW:
+       case LESS_OR_EQUAL:
+       case LEFT_SHIFT_EQ:
+       case LEFT_SHIFT:
+       case DIV_EQ:
+       case ELLIPSIS:
+       case DOT_DOT_EQ:
+       case DOT_DOT:
+       case RETURN_TYPE:
+       case MINUS_EQ:
+       case PLUS_EQ:
+       case ASTERISK_EQ:
+       case LOGICAL_AND:
+       case AMP_EQ:
+       case PERCENT_EQ:
+       case SCOPE_RESOLUTION:
+       case NOT_EQUAL:
+         case EQUAL_EQUAL: {
+           auto str = token->as_string ();
+           auto it = str.cbegin ();
+           for (; it != str.cend () - 1; it++)
+             {
+               trees.back ().push (ProcMacro::TokenTree::make_tokentree (
+                 ProcMacro::Punct::make_punct (*it, ProcMacro::JOINT)));
+             }
+           trees.back ().push (ProcMacro::TokenTree::make_tokentree (
+             ProcMacro::Punct::make_punct (*it, ProcMacro::ALONE)));
+         }
+         break;
        // Alone punct tokens
        case EQUAL:
        case RIGHT_ANGLE: