gccrs: Fix token lexed as a float literal
commit311121156e27e156c71bbbe2f12e35b1618ed100
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Tue, 17 Oct 2023 11:24:54 +0000 (17 13:24 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:09:35 +0000 (16 19:09 +0100)
treee4d01c36bc9befaebc7f73da3e4dabfd08fa3a25
parent80bdb1a85ac6275eb7cdb963b257ba65168c8eb9
gccrs: Fix token lexed as a float literal

The lexer cannot distinguish the difference between a float literal and a
tuple index in some cases. This means we should fix this while parsing
depending on the context.

gcc/rust/ChangeLog:

* expand/rust-macro-invoc-lexer.cc (MacroInvocLexer::split_current_token):
Add implementation for multiple token split.
* expand/rust-macro-invoc-lexer.h: Add function prototype.
* expand/rust-proc-macro-invoc-lexer.cc (ProcMacroInvocLexer::split_current_token):
Add implementation for 2+ token split for procedural macros.
* expand/rust-proc-macro-invoc-lexer.h: Add function prototype.
* lex/rust-lex.cc (Lexer::split_current_token): Add function to split a
token in multiple other tokens.
* lex/rust-lex.h: Add function prototype for split_current_token.
* parse/rust-parse-impl.h (Parser::left_denotation): Handle float tuple
index identified as a float literal.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/expand/rust-macro-invoc-lexer.cc
gcc/rust/expand/rust-macro-invoc-lexer.h
gcc/rust/expand/rust-proc-macro-invoc-lexer.cc
gcc/rust/expand/rust-proc-macro-invoc-lexer.h
gcc/rust/lex/rust-lex.cc
gcc/rust/lex/rust-lex.h
gcc/rust/parse/rust-parse-impl.h