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.
This commit is contained in:
Tom Tromey
2021-04-16 16:34:07 -06:00
parent 458620aabb
commit 3cbc7ac344
7 changed files with 2373 additions and 2890 deletions

2351
gdb/rust-parse.c Normal file

File diff suppressed because it is too large Load Diff