diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-08-03 15:28:40 +0200 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2023-08-17 10:01:43 +0000 |
commit | c5326821d396599a12b3f1293229e943a95f29be (patch) | |
tree | bb09743dac9f19658c878d4d74f76bec3023a102 | |
parent | 294c5906d7b6e9f7a89e58c334f0072f98b679c6 (diff) | |
download | gcc-c5326821d396599a12b3f1293229e943a95f29be.zip gcc-c5326821d396599a12b3f1293229e943a95f29be.tar.gz gcc-c5326821d396599a12b3f1293229e943a95f29be.tar.bz2 |
fix lexer exponent output on tuple indices
The lexer did output a literal for values such as 42.e wich are invalid
in rust.
gcc/rust/ChangeLog:
* lex/rust-lex.cc (Lexer::parse_decimal_int_or_float): Only
accept digits after a dot instead of accepting any float
member.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
-rw-r--r-- | gcc/rust/lex/rust-lex.cc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/gcc/rust/lex/rust-lex.cc b/gcc/rust/lex/rust-lex.cc index 2a92465..0798be3 100644 --- a/gcc/rust/lex/rust-lex.cc +++ b/gcc/rust/lex/rust-lex.cc @@ -2295,7 +2295,17 @@ Lexer::parse_decimal_int_or_float (location_t loc) length += std::get<1> (initial_decimal); // detect float literal - if (current_char == '.' && is_float_digit (peek_input (1).value)) + // + // Note: + // + // We should not use is_float_digit () for this verification but instead + // directly ISDIGIT because rust does not support non digit values right after + // a dot. + // The following value is not legal in rust: + // let a = 3.e1; + // A `0` should be put between the dot and the exponent to be valid + // (eg. 3.0e1). + if (current_char == '.' && ISDIGIT (peek_input (1).value)) { // float with a '.', parse another decimal into it |