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.
This commit is contained in:
Tom Tromey 2018-05-23 21:46:59 -06:00
parent 55b6c98496
commit 49265499d8
2 changed files with 324 additions and 284 deletions

View File

@ -1,3 +1,23 @@
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.
2018-06-01 Tom Tromey <tom@tromey.com>
* cp-name-parser.y (parser_fprintf): Declare.

File diff suppressed because it is too large Load Diff