Make cp-name-parser.y a pure parser
This changes cp-name-parser.y to be a pure parser.
Originally I had thought that doing this would mean that gdb would
always require Bison. However, I've learned that Byacc supports some
of the Bison extensions in this area. So, the new code ought to work
reasonably well with both.
Note that the Byacc documentations says:
%pure-parser
Most variables (other than yydebug and yynerrs) are allocated
on the stack within yyparse, making the parser reasonably
reentrant.
In our case this is ok, first because gdb does not yet actualy require
reentrancy, and second because gdb does not use yynerrs.
gdb/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* cp-name-parser.y: Use %pure-parser, %lex-param, and
%parse-param.
(lexptr, prev_lexptr, error_lexptr, global_errmsg, demangle_info)
(global_result): Remove globals.
(struct cpname_state): New.
(yyparse): Don't declare.
(yylex, yyerror): Move declarations after %union.
(d_grab, fill_comp, make_operator, make_dtor, make_builtin_type)
(make_name): Add state parameter.
Update all callers.
(d_qualify, d_int_type, d_unary, d_binary, parse_number) Add state
parameter.
(HANDLE_QUAL, HANDLE_SPECIAL, HANDLE_TOKEN2, HANDLE_TOKEN3):
Update.
(yylex): Add lvalp, state parameters.
(yyerror): Add state parameter.
(cp_demangled_name_to_comp): Update.