From: Pierre-Emmanuel Patry Date: Thu, 27 Apr 2023 11:24:40 +0000 (+0200) Subject: gccrs: tokenstream: Convert single punctuation tokens X-Git-Tag: basepoints/gcc-15~2571 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c010c77c47964f0d660bff1313a57cea565b8506;p=thirdparty%2Fgcc.git gccrs: tokenstream: Convert single punctuation tokens 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 --- diff --git a/gcc/rust/ast/rust-ast-tokenstream.cc b/gcc/rust/ast/rust-ast-tokenstream.cc index 417c0f30c1aa..134292142177 100644 --- a/gcc/rust/ast/rust-ast-tokenstream.cc +++ b/gcc/rust/ast/rust-ast-tokenstream.cc @@ -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;