mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-23 18:14:13 +08:00
Add Rust parser check for end of expression
I noticed that "print 5," passed in Rust -- the parser wasn't checking that the entire input was used. This patch fixes the problem. This in turn pointed out another bug in the parser, namely that it didn't lex the next token after handling a string token. This is also fixed here.
This commit is contained in:
parent
52a4a5885a
commit
f77c52719d
@ -271,7 +271,10 @@ struct rust_parser
|
||||
operation_up parse_entry_point ()
|
||||
{
|
||||
lex ();
|
||||
return parse_expr ();
|
||||
operation_up result = parse_expr ();
|
||||
if (current_token != 0)
|
||||
error (_("Syntax error near '%s'"), pstate->prev_lexptr);
|
||||
return result;
|
||||
}
|
||||
|
||||
operation_up parse_tuple ();
|
||||
@ -2020,6 +2023,7 @@ rust_parser::parse_atom (bool required)
|
||||
|
||||
case STRING:
|
||||
result = parse_string ();
|
||||
lex ();
|
||||
break;
|
||||
|
||||
case BYTESTRING:
|
||||
|
@ -145,3 +145,5 @@ gdb_test "print 0x0 as fn(i64) -> ()" " = \\\(\\*mut fn \\\(i64\\\) -> \\\(\\\)\
|
||||
gdb_test "print r#" "No symbol 'r' in current context"
|
||||
|
||||
gdb_test "printf \"%d %d\\n\", 23+1, 23-1" "24 22"
|
||||
|
||||
gdb_test "print 5," "Syntax error near ','"
|
||||
|
Loading…
Reference in New Issue
Block a user