aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.rust/expr.exp
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-04-16 16:34:07 -0600
committerTom Tromey <tom@tromey.com>2021-04-16 16:34:08 -0600
commit3cbc7ac344cd6b500b54588a9099c037de58e75a (patch)
treed65283bae6379d5781766b52fb72a5b7b9dbe987 /gdb/testsuite/gdb.rust/expr.exp
parent458620aabb33d9b0efa61d0fb402c8d19e65eabd (diff)
downloadbinutils-3cbc7ac344cd6b500b54588a9099c037de58e75a.zip
binutils-3cbc7ac344cd6b500b54588a9099c037de58e75a.tar.gz
binutils-3cbc7ac344cd6b500b54588a9099c037de58e75a.tar.bz2
Rewrite the Rust expression parser
The Rust expression parser was written to construct its own AST, then lower this to GDB expressions. I did this primarily because the old expressions were difficult to work with; after rewriting those, I realized I could remove the AST from the Rust parser. After looking at this, I realized it might be simpler to rewrite the parser. This patch reimplements it as a recursive-descent parser. I kept a fair amount of the existing code -- the lexer is pulled in nearly unchanged. There are several benefits to this approach: * The parser is shorter now (from 2882 LOC to 2351). * The parser is just ordinary C++ code that can be debugged in the usual way. * Memory management in the parser is now straightforward, as parsing methods simply return a unique pointer or vector. This required a couple of minor changes to the test suite, as some errors have changed. While this passes the tests, it's possible there are lurking bugs, particularly around error handling. gdb/ChangeLog 2021-04-16 Tom Tromey <tom@tromey.com> * rust-parse.c: New file. * rust-exp.y: Remove. * Makefile.in (COMMON_SFILES): Add rust-parse.c. (SFILES): Remove rust-exp.y. (YYFILES, local-maintainer-clean): Remove rust-exp.c. gdb/testsuite/ChangeLog 2021-04-16 Tom Tromey <tom@tromey.com> * gdb.rust/simple.exp: Change error text. * gdb.rust/expr.exp: Change error text.
Diffstat (limited to 'gdb/testsuite/gdb.rust/expr.exp')
-rw-r--r--gdb/testsuite/gdb.rust/expr.exp6
1 files changed, 5 insertions, 1 deletions
diff --git a/gdb/testsuite/gdb.rust/expr.exp b/gdb/testsuite/gdb.rust/expr.exp
index d77c780..d81b6fc 100644
--- a/gdb/testsuite/gdb.rust/expr.exp
+++ b/gdb/testsuite/gdb.rust/expr.exp
@@ -136,6 +136,10 @@ gdb_test "print \[mut 23usize; 4\]" " = \\\[23, 23, 23, 23\\\]"
# Test lexer corner cases.
gdb_test "print 0x0 as *mut ()" " = \\\(\\*mut \\\(\\\)\\\) 0x0"
gdb_test "print 0x0 as fn(i64) -> ()" " = \\\(\\*mut fn \\\(i64\\\) -> \\\(\\\)\\\) 0x0"
-gdb_test "print r#" "syntax error in expression, near `#'\\."
+
+# The lexer doesn't treat this as a failure, but rather as two tokens,
+# and we error out while trying to look up 'r'. This is fine, though
+# -- what's important is that it isn't accepted.
+gdb_test "print r#" "No symbol 'r' in current context"
gdb_test "printf \"%d %d\\n\", 23+1, 23-1" "24 22"