diff options
author | Tom Tromey <tom@tromey.com> | 2022-03-17 22:36:12 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2022-03-28 15:02:52 -0600 |
commit | f77c52719df41f5f5cf34b7ba1ae9f591f0b0bf5 (patch) | |
tree | 3c2036cd9465af995c16e0aa1c95b378743ebb73 /gdb/rust-parse.c | |
parent | 52a4a5885af15e7ef32d5f4e5b77f98349c32276 (diff) | |
download | gdb-f77c52719df41f5f5cf34b7ba1ae9f591f0b0bf5.zip gdb-f77c52719df41f5f5cf34b7ba1ae9f591f0b0bf5.tar.gz gdb-f77c52719df41f5f5cf34b7ba1ae9f591f0b0bf5.tar.bz2 |
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.
Diffstat (limited to 'gdb/rust-parse.c')
-rw-r--r-- | gdb/rust-parse.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c index 4006df7..7d7d882 100644 --- a/gdb/rust-parse.c +++ b/gdb/rust-parse.c @@ -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: |