]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Add operation-related methods to parser_state
authorTom Tromey <tom@tromey.com>
Mon, 8 Mar 2021 14:27:57 +0000 (07:27 -0700)
committerTom Tromey <tom@tromey.com>
Mon, 8 Mar 2021 14:28:37 +0000 (07:28 -0700)
commit8227d9e2f4af14c7e36f1792747bd5d7edf71d6a
treeccd72473a386dc22c44b237893aea832b1e78451
parent4933522da0d59823d2bfef3706e2252203365e9c
Add operation-related methods to parser_state

This adds several operation-related methods to parser_state.  These
methods make it more convenient to change the parsers to be
operation-based.

Because byacc has poor support for C++, a stack of operations is added
to parser_state.  A parser can push operations, then later pop them
for combination into new operations.  This approach avoids the memory
leaks that would result if raw pointers were used in the parsers, at
the cost of parser productions not being type-safe (they can't
indicate that they return an operation).

This also introduces analogs of some write_exp functions, like
write_exp_string_vector, write_dollar_variable, and
write_exp_symbol_reference.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

* parser-defs.h (struct parser_state) <push, push_new,
push_c_string, push_symbol, push_dollar, pop, pop_vector, wrap,
wrap2>: New methods.
<m_operations>: New member.
* parse.c (parser_state::push_c_string)
(parser_state::push_symbol, parser_state::push_dollar): New
methods.
gdb/ChangeLog
gdb/parse.c
gdb/parser-defs.h