From c1b343da33fe7038522d7c0f28b7e061707ccec7 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Thu, 27 Apr 2023 15:17:35 +0200 Subject: [PATCH] gccrs: tokenstream: Add joint punct token conversion 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 --- gcc/rust/ast/rust-ast-tokenstream.cc | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/gcc/rust/ast/rust-ast-tokenstream.cc b/gcc/rust/ast/rust-ast-tokenstream.cc index 134292142177..faafac4e14b3 100644 --- a/gcc/rust/ast/rust-ast-tokenstream.cc +++ b/gcc/rust/ast/rust-ast-tokenstream.cc @@ -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: -- 2.43.5