From b3f11165aad39586cca0352ed5fe32b721699c76 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 22 Apr 2016 16:40:33 +0100 Subject: [PATCH] Centralize yacc interface names remapping (yyparse, yylex, yyerror, etc) This factors out all the yy-variables remapping to a single file, instead of each parser having to do the same, with different prefixes. With this, a parser just needs to define the prefix they want and include yy-remap.h, which does the dirty job. Note this renames the c_error, ada_error, etc. functions. Writing the remapping pattern as: #define yyerror GDB_YY_REMAP (error) instead of: #define yyerror GDB_YY_REMAP (yyerror) would have avoided the renaming. However, that would be problematic if we have a macro 'foo' in scope, when we write: #define yyfoo GDB_YY_REMAP (foo) as that would expand 'foo'. The c_yyerror etc. naming end ups indicating that this is a yacc related function more clearly, so feels like a good change, anyway. gdb/ChangeLog: 2016-04-22 Pedro Alves * ada-exp.y: Remove all yy symbol remappings. (GDB_YY_REMAP_PREFIX): Define. Include "yy-remap.h". * ada-lang.c (ada_language_defn): Adjust. * ada-lang.h (ada_error): Rename to ... (ada_yyerror): ... this. * c-exp.y: Remove all yy symbol remappings. (GDB_YY_REMAP_PREFIX): Define. Include "yy-remap.h". * c-lang.c (c_language_defn, cplus_language_defn) (asm_language_defn, minimal_language_defn): Adjust. * c-lang.h (c_error): Rename to ... (c_yyerror): ... this. * d-exp.y: Remove all yy symbol remappings. (GDB_YY_REMAP_PREFIX): Define. Include "yy-remap.h". * d-lang.c (d_language_defn): Adjust. * d-lang.h (d_error): Rename to ... (d_yyerror): ... this. * f-exp.y: Remove all yy symbol remappings. (GDB_YY_REMAP_PREFIX): Define. Include "yy-remap.h". * f-lang.c (f_language_defn): Adjust. * f-lang.h (f_error): Rename to ... (f_yyerror): ... this. * go-exp.y: Remove all yy symbol remappings. (GDB_YY_REMAP_PREFIX): Define. Include "yy-remap.h". * go-lang.c (go_language_defn): Adjust. * go-lang.h (go_error): Rename to ... (go_yyerror): ... this. * jv-exp.y: Remove all yy symbol remappings. (GDB_YY_REMAP_PREFIX): Define. Include "yy-remap.h". * jv-lang.c (java_language_defn): Adjust. * jv-lang.h (java_error): Rename to ... (java_yyerror): ... this. * m2-exp.y: Remove all yy symbol remappings. (GDB_YY_REMAP_PREFIX): Define. Include "yy-remap.h". * m2-lang.c (m2_language_defn): Adjust. * m2-lang.h (m2_error): Rename to ... (m2_yyerror): ... this. * objc-exp.y: Remove all yy symbol remappings. (GDB_YY_REMAP_PREFIX): Define. Include "yy-remap.h". * objc-lang.c (objc_language_defn): Adjust. * opencl-lang.c (opencl_language_defn): Adjust. * p-exp.y: Remove all yy symbol remappings. (GDB_YY_REMAP_PREFIX): Define. Include "yy-remap.h". * p-lang.c (pascal_language_defn): Adjust. * p-lang.h (pascal_error): Rename to ... (pascal_yyerror): ... this. * yy-remap.h: New file. --- gdb/ChangeLog | 58 ++++++++++++++++++++++++++++++ gdb/ada-exp.y | 60 +++---------------------------- gdb/ada-lang.c | 2 +- gdb/ada-lang.h | 2 +- gdb/c-exp.y | 63 +++----------------------------- gdb/c-lang.c | 8 ++--- gdb/c-lang.h | 2 +- gdb/d-exp.y | 63 +++----------------------------- gdb/d-lang.c | 2 +- gdb/d-lang.h | 2 +- gdb/f-exp.y | 63 +++----------------------------- gdb/f-lang.c | 2 +- gdb/f-lang.h | 2 +- gdb/go-exp.y | 57 +++-------------------------- gdb/go-lang.c | 2 +- gdb/go-lang.h | 2 +- gdb/jv-exp.y | 63 +++----------------------------- gdb/jv-lang.c | 2 +- gdb/jv-lang.h | 2 +- gdb/m2-exp.y | 63 +++----------------------------- gdb/m2-lang.c | 2 +- gdb/m2-lang.h | 2 +- gdb/objc-lang.c | 2 +- gdb/opencl-lang.c | 2 +- gdb/p-exp.y | 63 +++----------------------------- gdb/p-lang.c | 2 +- gdb/p-lang.h | 2 +- gdb/yy-remap.h | 92 +++++++++++++++++++++++++++++++++++++++++++++++ 28 files changed, 203 insertions(+), 484 deletions(-) create mode 100644 gdb/yy-remap.h diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 828d3909ea..512344c103 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,61 @@ +2016-04-22 Pedro Alves + + * ada-exp.y: Remove all yy symbol remappings. + (GDB_YY_REMAP_PREFIX): Define. + Include "yy-remap.h". + * ada-lang.c (ada_language_defn): Adjust. + * ada-lang.h (ada_error): Rename to ... + (ada_yyerror): ... this. + * c-exp.y: Remove all yy symbol remappings. + (GDB_YY_REMAP_PREFIX): Define. + Include "yy-remap.h". + * c-lang.c (c_language_defn, cplus_language_defn) + (asm_language_defn, minimal_language_defn): Adjust. + * c-lang.h (c_error): Rename to ... + (c_yyerror): ... this. + * d-exp.y: Remove all yy symbol remappings. + (GDB_YY_REMAP_PREFIX): Define. + Include "yy-remap.h". + * d-lang.c (d_language_defn): Adjust. + * d-lang.h (d_error): Rename to ... + (d_yyerror): ... this. + * f-exp.y: Remove all yy symbol remappings. + (GDB_YY_REMAP_PREFIX): Define. + Include "yy-remap.h". + * f-lang.c (f_language_defn): Adjust. + * f-lang.h (f_error): Rename to ... + (f_yyerror): ... this. + * go-exp.y: Remove all yy symbol remappings. + (GDB_YY_REMAP_PREFIX): Define. + Include "yy-remap.h". + * go-lang.c (go_language_defn): Adjust. + * go-lang.h (go_error): Rename to ... + (go_yyerror): ... this. + * jv-exp.y: Remove all yy symbol remappings. + (GDB_YY_REMAP_PREFIX): Define. + Include "yy-remap.h". + * jv-lang.c (java_language_defn): Adjust. + * jv-lang.h (java_error): Rename to ... + (java_yyerror): ... this. + * m2-exp.y: Remove all yy symbol remappings. + (GDB_YY_REMAP_PREFIX): Define. + Include "yy-remap.h". + * m2-lang.c (m2_language_defn): Adjust. + * m2-lang.h (m2_error): Rename to ... + (m2_yyerror): ... this. + * objc-exp.y: Remove all yy symbol remappings. + (GDB_YY_REMAP_PREFIX): Define. + Include "yy-remap.h". + * objc-lang.c (objc_language_defn): Adjust. + * opencl-lang.c (opencl_language_defn): Adjust. + * p-exp.y: Remove all yy symbol remappings. + (GDB_YY_REMAP_PREFIX): Define. + Include "yy-remap.h". + * p-lang.c (pascal_language_defn): Adjust. + * p-lang.h (pascal_error): Rename to ... + (pascal_yyerror): ... this. + * yy-remap.h: New file. + 2016-04-22 Pedro Alves * common/common-exceptions.h (GDB_XCPT_TRY): Remove mention of diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index a98bdbcedb..0a33e10485 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -50,62 +50,10 @@ #define parse_type(ps) builtin_type (parse_gdbarch (ps)) -/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), - as well as gratuitiously global symbol names, so we can have multiple - yacc generated parsers in gdb. These are only the variables - produced by yacc. If other parser generators (bison, byacc, etc) produce - additional global names that conflict at link time, then those parser - generators need to be fixed instead of adding those names to this list. */ - -/* NOTE: This is clumsy, especially since BISON and FLEX provide --prefix - options. I presume we are maintaining it to accommodate systems - without BISON? (PNH) */ - -#define yymaxdepth ada_maxdepth -/* ada_parse calls this after initialization */ -#define yyparse ada_parse_internal -#define yylex ada_lex -#define yyerror ada_error -#define yylval ada_lval -#define yychar ada_char -#define yydebug ada_debug -#define yypact ada_pact -#define yyr1 ada_r1 -#define yyr2 ada_r2 -#define yydef ada_def -#define yychk ada_chk -#define yypgo ada_pgo -#define yyact ada_act -#define yyexca ada_exca -#define yyerrflag ada_errflag -#define yynerrs ada_nerrs -#define yyps ada_ps -#define yypv ada_pv -#define yys ada_s -#define yy_yys ada_yys -#define yystate ada_state -#define yytmp ada_tmp -#define yyv ada_v -#define yy_yyv ada_yyv -#define yyval ada_val -#define yylloc ada_lloc -#define yyreds ada_reds /* With YYDEBUG defined */ -#define yytoks ada_toks /* With YYDEBUG defined */ -#define yyname ada_name /* With YYDEBUG defined */ -#define yyrule ada_rule /* With YYDEBUG defined */ -#define yydefred ada_yydefred -#define yyss ada_yyss -#define yysslim ada_yysslim -#define yyssp ada_yyssp -#define yystacksize ada_yystacksize -#define yyvs ada_yyvs -#define yyvsp ada_yyvsp - -#ifndef YYDEBUG -#define YYDEBUG 1 /* Default to yydebug support */ -#endif - -#define YYFPRINTF parser_fprintf +/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, + etc). */ +#define GDB_YY_REMAP_PREFIX ada_ +#include "yy-remap.h" struct name_info { struct symbol *sym; diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index d01660a29f..412aa972ca 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -14056,7 +14056,7 @@ const struct language_defn ada_language_defn = { macro_expansion_no, &ada_exp_descriptor, parse, - ada_error, + ada_yyerror, resolve, ada_printchar, /* Print a character constant */ ada_printstr, /* Function to print string constant */ diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h index 1480977f3b..7de71eb99e 100644 --- a/gdb/ada-lang.h +++ b/gdb/ada-lang.h @@ -159,7 +159,7 @@ extern int ada_get_field_index (const struct type *type, extern int ada_parse (struct parser_state *); /* Defined in ada-exp.y */ -extern void ada_error (char *); /* Defined in ada-exp.y */ +extern void ada_yyerror (char *); /* Defined in ada-exp.y */ /* Defined in ada-typeprint.c */ extern void ada_print_type (struct type *, const char *, struct ui_file *, int, diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 9f2a229faf..29f672f54c 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -56,65 +56,10 @@ #define parse_type(ps) builtin_type (parse_gdbarch (ps)) -/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), - as well as gratuitiously global symbol names, so we can have multiple - yacc generated parsers in gdb. Note that these are only the variables - produced by yacc. If other parser generators (bison, byacc, etc) produce - additional global names that conflict at link time, then those parser - generators need to be fixed instead of adding those names to this list. */ - -#define yymaxdepth c_maxdepth -#define yyparse c_parse_internal -#define yylex c_lex -#define yyerror c_error -#define yylval c_lval -#define yychar c_char -#define yydebug c_debug -#define yypact c_pact -#define yyr1 c_r1 -#define yyr2 c_r2 -#define yydef c_def -#define yychk c_chk -#define yypgo c_pgo -#define yyact c_act -#define yyexca c_exca -#define yyerrflag c_errflag -#define yynerrs c_nerrs -#define yyps c_ps -#define yypv c_pv -#define yys c_s -#define yy_yys c_yys -#define yystate c_state -#define yytmp c_tmp -#define yyv c_v -#define yy_yyv c_yyv -#define yyval c_val -#define yylloc c_lloc -#define yyreds c_reds /* With YYDEBUG defined */ -#define yytoks c_toks /* With YYDEBUG defined */ -#define yyname c_name /* With YYDEBUG defined */ -#define yyrule c_rule /* With YYDEBUG defined */ -#define yylhs c_yylhs -#define yylen c_yylen -#define yydefred c_yydefred -#define yydgoto c_yydgoto -#define yysindex c_yysindex -#define yyrindex c_yyrindex -#define yygindex c_yygindex -#define yytable c_yytable -#define yycheck c_yycheck -#define yyss c_yyss -#define yysslim c_yysslim -#define yyssp c_yyssp -#define yystacksize c_yystacksize -#define yyvs c_yyvs -#define yyvsp c_yyvsp - -#ifndef YYDEBUG -#define YYDEBUG 1 /* Default to yydebug support */ -#endif - -#define YYFPRINTF parser_fprintf +/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, + etc). */ +#define GDB_YY_REMAP_PREFIX c_ +#include "yy-remap.h" /* The state of the parser, used internally when we are parsing the expression. */ diff --git a/gdb/c-lang.c b/gdb/c-lang.c index d8d78fd711..8192e97942 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -835,7 +835,7 @@ const struct language_defn c_language_defn = macro_expansion_c, &exp_descriptor_c, c_parse, - c_error, + c_yyerror, null_post_parser, c_printchar, /* Print a character constant */ c_printstr, /* Function to print string constant */ @@ -962,7 +962,7 @@ const struct language_defn cplus_language_defn = macro_expansion_c, &exp_descriptor_c, c_parse, - c_error, + c_yyerror, null_post_parser, c_printchar, /* Print a character constant */ c_printstr, /* Function to print string constant */ @@ -1007,7 +1007,7 @@ const struct language_defn asm_language_defn = macro_expansion_c, &exp_descriptor_c, c_parse, - c_error, + c_yyerror, null_post_parser, c_printchar, /* Print a character constant */ c_printstr, /* Function to print string constant */ @@ -1057,7 +1057,7 @@ const struct language_defn minimal_language_defn = macro_expansion_c, &exp_descriptor_c, c_parse, - c_error, + c_yyerror, null_post_parser, c_printchar, /* Print a character constant */ c_printstr, /* Function to print string constant */ diff --git a/gdb/c-lang.h b/gdb/c-lang.h index 94861f52d5..bf50afc151 100644 --- a/gdb/c-lang.h +++ b/gdb/c-lang.h @@ -63,7 +63,7 @@ DEF_ENUM_FLAGS_TYPE (enum c_string_type_values, c_string_type); extern int c_parse (struct parser_state *); -extern void c_error (char *); +extern void c_yyerror (char *); extern int c_parse_escape (const char **, struct obstack *); diff --git a/gdb/d-exp.y b/gdb/d-exp.y index 54c01c5b4b..e7b11e75d8 100644 --- a/gdb/d-exp.y +++ b/gdb/d-exp.y @@ -55,65 +55,10 @@ #define parse_type(ps) builtin_type (parse_gdbarch (ps)) #define parse_d_type(ps) builtin_d_type (parse_gdbarch (ps)) -/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), - as well as gratuitiously global symbol names, so we can have multiple - yacc generated parsers in gdb. Note that these are only the variables - produced by yacc. If other parser generators (bison, byacc, etc) produce - additional global names that conflict at link time, then those parser - generators need to be fixed instead of adding those names to this list. */ - -#define yymaxdepth d_maxdepth -#define yyparse d_parse_internal -#define yylex d_lex -#define yyerror d_error -#define yylval d_lval -#define yychar d_char -#define yydebug d_debug -#define yypact d_pact -#define yyr1 d_r1 -#define yyr2 d_r2 -#define yydef d_def -#define yychk d_chk -#define yypgo d_pgo -#define yyact d_act -#define yyexca d_exca -#define yyerrflag d_errflag -#define yynerrs d_nerrs -#define yyps d_ps -#define yypv d_pv -#define yys d_s -#define yy_yys d_yys -#define yystate d_state -#define yytmp d_tmp -#define yyv d_v -#define yy_yyv d_yyv -#define yyval d_val -#define yylloc d_lloc -#define yyreds d_reds /* With YYDEBUG defined */ -#define yytoks d_toks /* With YYDEBUG defined */ -#define yyname d_name /* With YYDEBUG defined */ -#define yyrule d_rule /* With YYDEBUG defined */ -#define yylhs d_yylhs -#define yylen d_yylen -#define yydefre d_yydefred -#define yydgoto d_yydgoto -#define yysindex d_yysindex -#define yyrindex d_yyrindex -#define yygindex d_yygindex -#define yytable d_yytable -#define yycheck d_yycheck -#define yyss d_yyss -#define yysslim d_yysslim -#define yyssp d_yyssp -#define yystacksize d_yystacksize -#define yyvs d_yyvs -#define yyvsp d_yyvsp - -#ifndef YYDEBUG -#define YYDEBUG 1 /* Default to yydebug support */ -#endif - -#define YYFPRINTF parser_fprintf +/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, + etc). */ +#define GDB_YY_REMAP_PREFIX d_ +#include "yy-remap.h" /* The state of the parser, used internally when we are parsing the expression. */ diff --git a/gdb/d-lang.c b/gdb/d-lang.c index e8a08e19c4..0075fea9f6 100644 --- a/gdb/d-lang.c +++ b/gdb/d-lang.c @@ -201,7 +201,7 @@ static const struct language_defn d_language_defn = macro_expansion_no, &exp_descriptor_c, d_parse, - d_error, + d_yyerror, null_post_parser, c_printchar, /* Print a character constant. */ c_printstr, /* Function to print string constant. */ diff --git a/gdb/d-lang.h b/gdb/d-lang.h index 8f63f519df..74be7a5f61 100644 --- a/gdb/d-lang.h +++ b/gdb/d-lang.h @@ -58,7 +58,7 @@ struct builtin_d_type extern int d_parse (struct parser_state *); -extern void d_error (char *); +extern void d_yyerror (char *); /* Defined in d-lang.c */ diff --git a/gdb/f-exp.y b/gdb/f-exp.y index 4faac3233e..cd659a1e22 100644 --- a/gdb/f-exp.y +++ b/gdb/f-exp.y @@ -57,65 +57,10 @@ #define parse_type(ps) builtin_type (parse_gdbarch (ps)) #define parse_f_type(ps) builtin_f_type (parse_gdbarch (ps)) -/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), - as well as gratuitiously global symbol names, so we can have multiple - yacc generated parsers in gdb. Note that these are only the variables - produced by yacc. If other parser generators (bison, byacc, etc) produce - additional global names that conflict at link time, then those parser - generators need to be fixed instead of adding those names to this list. */ - -#define yymaxdepth f_maxdepth -#define yyparse f_parse_internal -#define yylex f_lex -#define yyerror f_error -#define yylval f_lval -#define yychar f_char -#define yydebug f_debug -#define yypact f_pact -#define yyr1 f_r1 -#define yyr2 f_r2 -#define yydef f_def -#define yychk f_chk -#define yypgo f_pgo -#define yyact f_act -#define yyexca f_exca -#define yyerrflag f_errflag -#define yynerrs f_nerrs -#define yyps f_ps -#define yypv f_pv -#define yys f_s -#define yy_yys f_yys -#define yystate f_state -#define yytmp f_tmp -#define yyv f_v -#define yy_yyv f_yyv -#define yyval f_val -#define yylloc f_lloc -#define yyreds f_reds /* With YYDEBUG defined */ -#define yytoks f_toks /* With YYDEBUG defined */ -#define yyname f_name /* With YYDEBUG defined */ -#define yyrule f_rule /* With YYDEBUG defined */ -#define yylhs f_yylhs -#define yylen f_yylen -#define yydefred f_yydefred -#define yydgoto f_yydgoto -#define yysindex f_yysindex -#define yyrindex f_yyrindex -#define yygindex f_yygindex -#define yytable f_yytable -#define yycheck f_yycheck -#define yyss f_yyss -#define yysslim f_yysslim -#define yyssp f_yyssp -#define yystacksize f_yystacksize -#define yyvs f_yyvs -#define yyvsp f_yyvsp - -#ifndef YYDEBUG -#define YYDEBUG 1 /* Default to yydebug support */ -#endif - -#define YYFPRINTF parser_fprintf +/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, + etc). */ +#define GDB_YY_REMAP_PREFIX f_ +#include "yy-remap.h" /* The state of the parser, used internally when we are parsing the expression. */ diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 9854eb9bda..22c308f921 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -246,7 +246,7 @@ const struct language_defn f_language_defn = macro_expansion_no, &exp_descriptor_standard, f_parse, /* parser */ - f_error, /* parser error function */ + f_yyerror, /* parser error function */ null_post_parser, f_printchar, /* Print character constant */ f_printstr, /* function to print string constant */ diff --git a/gdb/f-lang.h b/gdb/f-lang.h index eeca1070ab..45df770857 100644 --- a/gdb/f-lang.h +++ b/gdb/f-lang.h @@ -25,7 +25,7 @@ struct parser_state; extern int f_parse (struct parser_state *); -extern void f_error (char *); /* Defined in f-exp.y */ +extern void f_yyerror (char *); /* Defined in f-exp.y */ extern void f_print_type (struct type *, const char *, struct ui_file *, int, int, const struct type_print_options *); diff --git a/gdb/go-exp.y b/gdb/go-exp.y index c4ea0f0ace..1b0fe5b5f5 100644 --- a/gdb/go-exp.y +++ b/gdb/go-exp.y @@ -67,59 +67,10 @@ #define parse_type(ps) builtin_type (parse_gdbarch (ps)) -/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), - as well as gratuitiously global symbol names, so we can have multiple - yacc generated parsers in gdb. Note that these are only the variables - produced by yacc. If other parser generators (bison, byacc, etc) produce - additional global names that conflict at link time, then those parser - generators need to be fixed instead of adding those names to this list. */ - -#define yymaxdepth go_maxdepth -#define yyparse go_parse_internal -#define yylex go_lex -#define yyerror go_error -#define yylval go_lval -#define yychar go_char -#define yydebug go_debug -#define yypact go_pact -#define yyr1 go_r1 -#define yyr2 go_r2 -#define yydef go_def -#define yychk go_chk -#define yypgo go_pgo -#define yyact go_act -#define yyexca go_exca -#define yyerrflag go_errflag -#define yynerrs go_nerrs -#define yyps go_ps -#define yypv go_pv -#define yys go_s -#define yy_yys go_yys -#define yystate go_state -#define yytmp go_tmp -#define yyv go_v -#define yy_yyv go_yyv -#define yyval go_val -#define yylloc go_lloc -#define yyreds go_reds /* With YYDEBUG defined */ -#define yytoks go_toks /* With YYDEBUG defined */ -#define yyname go_name /* With YYDEBUG defined */ -#define yyrule go_rule /* With YYDEBUG defined */ -#define yylhs go_yylhs -#define yylen go_yylen -#define yydefred go_yydefred -#define yydgoto go_yydgoto -#define yysindex go_yysindex -#define yyrindex go_yyrindex -#define yygindex go_yygindex -#define yytable go_yytable -#define yycheck go_yycheck - -#ifndef YYDEBUG -#define YYDEBUG 1 /* Default to yydebug support */ -#endif - -#define YYFPRINTF parser_fprintf +/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, + etc). */ +#define GDB_YY_REMAP_PREFIX go_ +#include "yy-remap.h" /* The state of the parser, used internally when we are parsing the expression. */ diff --git a/gdb/go-lang.c b/gdb/go-lang.c index 96be458f35..84a366ac5a 100644 --- a/gdb/go-lang.c +++ b/gdb/go-lang.c @@ -567,7 +567,7 @@ static const struct language_defn go_language_defn = macro_expansion_no, &exp_descriptor_c, go_parse, - go_error, + go_yyerror, null_post_parser, c_printchar, /* Print a character constant. */ c_printstr, /* Function to print string constant. */ diff --git a/gdb/go-lang.h b/gdb/go-lang.h index 49a35805e8..5eb298e543 100644 --- a/gdb/go-lang.h +++ b/gdb/go-lang.h @@ -60,7 +60,7 @@ enum go_type extern int go_parse (struct parser_state *); -extern void go_error (char *); +extern void go_yyerror (char *); /* Defined in go-lang.c. */ diff --git a/gdb/jv-exp.y b/gdb/jv-exp.y index 951ef4929e..79b8127b59 100644 --- a/gdb/jv-exp.y +++ b/gdb/jv-exp.y @@ -51,65 +51,10 @@ #define parse_type(ps) builtin_type (parse_gdbarch (ps)) #define parse_java_type(ps) builtin_java_type (parse_gdbarch (ps)) -/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), - as well as gratuitiously global symbol names, so we can have multiple - yacc generated parsers in gdb. Note that these are only the variables - produced by yacc. If other parser generators (bison, byacc, etc) produce - additional global names that conflict at link time, then those parser - generators need to be fixed instead of adding those names to this list. */ - -#define yymaxdepth java_maxdepth -#define yyparse java_parse_internal -#define yylex java_lex -#define yyerror java_error -#define yylval java_lval -#define yychar java_char -#define yydebug java_debug -#define yypact java_pact -#define yyr1 java_r1 -#define yyr2 java_r2 -#define yydef java_def -#define yychk java_chk -#define yypgo java_pgo -#define yyact java_act -#define yyexca java_exca -#define yyerrflag java_errflag -#define yynerrs java_nerrs -#define yyps java_ps -#define yypv java_pv -#define yys java_s -#define yy_yys java_yys -#define yystate java_state -#define yytmp java_tmp -#define yyv java_v -#define yy_yyv java_yyv -#define yyval java_val -#define yylloc java_lloc -#define yyreds java_reds /* With YYDEBUG defined */ -#define yytoks java_toks /* With YYDEBUG defined */ -#define yyname java_name /* With YYDEBUG defined */ -#define yyrule java_rule /* With YYDEBUG defined */ -#define yylhs java_yylhs -#define yylen java_yylen -#define yydefred java_yydefred -#define yydgoto java_yydgoto -#define yysindex java_yysindex -#define yyrindex java_yyrindex -#define yygindex java_yygindex -#define yytable java_yytable -#define yycheck java_yycheck -#define yyss java_yyss -#define yysslim java_yysslim -#define yyssp java_yyssp -#define yystacksize java_yystacksize -#define yyvs java_yyvs -#define yyvsp java_yyvsp - -#ifndef YYDEBUG -#define YYDEBUG 1 /* Default to yydebug support */ -#endif - -#define YYFPRINTF parser_fprintf +/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, + etc). */ +#define GDB_YY_REMAP_PREFIX java_ +#include "yy-remap.h" /* The state of the parser, used internally when we are parsing the expression. */ diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c index 2355c1f863..14aa0e0295 100644 --- a/gdb/jv-lang.c +++ b/gdb/jv-lang.c @@ -1173,7 +1173,7 @@ const struct language_defn java_language_defn = macro_expansion_no, &exp_descriptor_java, java_parse, - java_error, + java_yyerror, null_post_parser, java_printchar, /* Print a character constant */ java_printstr, /* Function to print string constant */ diff --git a/gdb/jv-lang.h b/gdb/jv-lang.h index 63b257bd22..7183bd660c 100644 --- a/gdb/jv-lang.h +++ b/gdb/jv-lang.h @@ -26,7 +26,7 @@ struct parser_state; extern int java_parse (struct parser_state *); /* Defined in jv-exp.y */ -extern void java_error (char *); /* Defined in jv-exp.y */ +extern void java_yyerror (char *); /* Defined in jv-exp.y */ struct builtin_java_type { diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y index a52744001f..a8b431e366 100644 --- a/gdb/m2-exp.y +++ b/gdb/m2-exp.y @@ -51,65 +51,10 @@ #define parse_type(ps) builtin_type (parse_gdbarch (ps)) #define parse_m2_type(ps) builtin_m2_type (parse_gdbarch (ps)) -/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), - as well as gratuitiously global symbol names, so we can have multiple - yacc generated parsers in gdb. Note that these are only the variables - produced by yacc. If other parser generators (bison, byacc, etc) produce - additional global names that conflict at link time, then those parser - generators need to be fixed instead of adding those names to this list. */ - -#define yymaxdepth m2_maxdepth -#define yyparse m2_parse_internal -#define yylex m2_lex -#define yyerror m2_error -#define yylval m2_lval -#define yychar m2_char -#define yydebug m2_debug -#define yypact m2_pact -#define yyr1 m2_r1 -#define yyr2 m2_r2 -#define yydef m2_def -#define yychk m2_chk -#define yypgo m2_pgo -#define yyact m2_act -#define yyexca m2_exca -#define yyerrflag m2_errflag -#define yynerrs m2_nerrs -#define yyps m2_ps -#define yypv m2_pv -#define yys m2_s -#define yy_yys m2_yys -#define yystate m2_state -#define yytmp m2_tmp -#define yyv m2_v -#define yy_yyv m2_yyv -#define yyval m2_val -#define yylloc m2_lloc -#define yyreds m2_reds /* With YYDEBUG defined */ -#define yytoks m2_toks /* With YYDEBUG defined */ -#define yyname m2_name /* With YYDEBUG defined */ -#define yyrule m2_rule /* With YYDEBUG defined */ -#define yylhs m2_yylhs -#define yylen m2_yylen -#define yydefred m2_yydefred -#define yydgoto m2_yydgoto -#define yysindex m2_yysindex -#define yyrindex m2_yyrindex -#define yygindex m2_yygindex -#define yytable m2_yytable -#define yycheck m2_yycheck -#define yyss m2_yyss -#define yysslim m2_yysslim -#define yyssp m2_yyssp -#define yystacksize m2_yystacksize -#define yyvs m2_yyvs -#define yyvsp m2_yyvsp - -#ifndef YYDEBUG -#define YYDEBUG 1 /* Default to yydebug support */ -#endif - -#define YYFPRINTF parser_fprintf +/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, + etc). */ +#define GDB_YY_REMAP_PREFIX m2_ +#include "yy-remap.h" /* The state of the parser, used internally when we are parsing the expression. */ diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c index bbf3ac7b2b..917da15d80 100644 --- a/gdb/m2-lang.c +++ b/gdb/m2-lang.c @@ -365,7 +365,7 @@ const struct language_defn m2_language_defn = macro_expansion_no, &exp_descriptor_modula2, m2_parse, /* parser */ - m2_error, /* parser error function */ + m2_yyerror, /* parser error function */ null_post_parser, m2_printchar, /* Print character constant */ m2_printstr, /* function to print string constant */ diff --git a/gdb/m2-lang.h b/gdb/m2-lang.h index 7a03ee8a54..b749b21555 100644 --- a/gdb/m2-lang.h +++ b/gdb/m2-lang.h @@ -22,7 +22,7 @@ struct parser_state; extern int m2_parse (struct parser_state *); /* Defined in m2-exp.y */ -extern void m2_error (char *); /* Defined in m2-exp.y */ +extern void m2_yyerror (char *); /* Defined in m2-exp.y */ /* Defined in m2-typeprint.c */ extern void m2_print_type (struct type *, const char *, struct ui_file *, int, diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index f58b1c4e3d..34f90e872e 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -360,7 +360,7 @@ const struct language_defn objc_language_defn = { macro_expansion_c, &exp_descriptor_standard, c_parse, - c_error, + c_yyerror, null_post_parser, c_printchar, /* Print a character constant */ c_printstr, /* Function to print string constant */ diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index dfb68c0fa8..7799735790 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -1054,7 +1054,7 @@ const struct language_defn opencl_language_defn = macro_expansion_c, &exp_descriptor_opencl, c_parse, - c_error, + c_yyerror, null_post_parser, c_printchar, /* Print a character constant */ c_printstr, /* Function to print string constant */ diff --git a/gdb/p-exp.y b/gdb/p-exp.y index 8cbe5de067..fa6b22c03b 100644 --- a/gdb/p-exp.y +++ b/gdb/p-exp.y @@ -58,65 +58,10 @@ #define parse_type(ps) builtin_type (parse_gdbarch (ps)) -/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), - as well as gratuitiously global symbol names, so we can have multiple - yacc generated parsers in gdb. Note that these are only the variables - produced by yacc. If other parser generators (bison, byacc, etc) produce - additional global names that conflict at link time, then those parser - generators need to be fixed instead of adding those names to this list. */ - -#define yymaxdepth pascal_maxdepth -#define yyparse pascal_parse_internal -#define yylex pascal_lex -#define yyerror pascal_error -#define yylval pascal_lval -#define yychar pascal_char -#define yydebug pascal_debug -#define yypact pascal_pact -#define yyr1 pascal_r1 -#define yyr2 pascal_r2 -#define yydef pascal_def -#define yychk pascal_chk -#define yypgo pascal_pgo -#define yyact pascal_act -#define yyexca pascal_exca -#define yyerrflag pascal_errflag -#define yynerrs pascal_nerrs -#define yyps pascal_ps -#define yypv pascal_pv -#define yys pascal_s -#define yy_yys pascal_yys -#define yystate pascal_state -#define yytmp pascal_tmp -#define yyv pascal_v -#define yy_yyv pascal_yyv -#define yyval pascal_val -#define yylloc pascal_lloc -#define yyreds pascal_reds /* With YYDEBUG defined */ -#define yytoks pascal_toks /* With YYDEBUG defined */ -#define yyname pascal_name /* With YYDEBUG defined */ -#define yyrule pascal_rule /* With YYDEBUG defined */ -#define yylhs pascal_yylhs -#define yylen pascal_yylen -#define yydefred pascal_yydefred -#define yydgoto pascal_yydgoto -#define yysindex pascal_yysindex -#define yyrindex pascal_yyrindex -#define yygindex pascal_yygindex -#define yytable pascal_yytable -#define yycheck pascal_yycheck -#define yyss pascal_yyss -#define yysslim pascal_yysslim -#define yyssp pascal_yyssp -#define yystacksize pascal_yystacksize -#define yyvs pascal_yyvs -#define yyvsp pascal_yyvsp - -#ifndef YYDEBUG -#define YYDEBUG 1 /* Default to yydebug support */ -#endif - -#define YYFPRINTF parser_fprintf +/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, + etc). */ +#define GDB_YY_REMAP_PREFIX pascal_ +#include "yy-remap.h" /* The state of the parser, used internally when we are parsing the expression. */ diff --git a/gdb/p-lang.c b/gdb/p-lang.c index a7aeb369b5..8ff2682bf2 100644 --- a/gdb/p-lang.c +++ b/gdb/p-lang.c @@ -423,7 +423,7 @@ const struct language_defn pascal_language_defn = macro_expansion_no, &exp_descriptor_standard, pascal_parse, - pascal_error, + pascal_yyerror, null_post_parser, pascal_printchar, /* Print a character constant */ pascal_printstr, /* Function to print string constant */ diff --git a/gdb/p-lang.h b/gdb/p-lang.h index 5a65faadc8..d862b49380 100644 --- a/gdb/p-lang.h +++ b/gdb/p-lang.h @@ -27,7 +27,7 @@ extern const char *pascal_main_name (void); extern int pascal_parse (struct parser_state *); /* Defined in p-exp.y */ -extern void pascal_error (char *); /* Defined in p-exp.y */ +extern void pascal_yyerror (char *); /* Defined in p-exp.y */ /* Defined in p-typeprint.c */ extern void pascal_print_type (struct type *, const char *, struct ui_file *, diff --git a/gdb/yy-remap.h b/gdb/yy-remap.h new file mode 100644 index 0000000000..71fa946b54 --- /dev/null +++ b/gdb/yy-remap.h @@ -0,0 +1,92 @@ +/* Copyright (C) 1986-2016 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, + etc), as well as gratuitiously global symbol names, so we can have + multiple yacc generated parsers in gdb. Note that these are only + the variables produced by yacc. If other parser generators (bison, + byacc, etc) produce additional global names that conflict at link + time, then those parser generators need to be fixed instead of + adding those names to this list. */ + +/* NOTE: This is clumsy since BISON and FLEX provide --prefix options. + We are maintaining it to accommodate systems without BISON. */ + +/* Define GDB_YY_REMAP_PREFIX to the desired remapping prefix before + including this file. */ +#ifndef GDB_YY_REMAP_PREFIX +# error "GDB_YY_REMAP_PREFIX not defined" +#endif + +#define GDB_YY_REMAP_2(PREFIX, YYSYM) PREFIX ## YYSYM +#define GDB_YY_REMAP_1(PREFIX, YYSYM) GDB_YY_REMAP_2 (PREFIX, YYSYM) +#define GDB_YY_REMAP(YYSYM) GDB_YY_REMAP_1 (GDB_YY_REMAP_PREFIX, YYSYM) + +#define yymaxdepth GDB_YY_REMAP (yymaxdepth) +#define yyparse GDB_YY_REMAP (yyparse) +#define yylex GDB_YY_REMAP (yylex) +#define yyerror GDB_YY_REMAP (yyerror) +#define yylval GDB_YY_REMAP (yylval) +#define yychar GDB_YY_REMAP (yychar) +#define yydebug GDB_YY_REMAP (yydebug) +#define yypact GDB_YY_REMAP (yypact) +#define yyr1 GDB_YY_REMAP (yyr1) +#define yyr2 GDB_YY_REMAP (yyr2) +#define yydef GDB_YY_REMAP (yydef) +#define yychk GDB_YY_REMAP (yychk) +#define yypgo GDB_YY_REMAP (yypgo) +#define yyact GDB_YY_REMAP (yyact) +#define yyexca GDB_YY_REMAP (yyexca) +#define yyerrflag GDB_YY_REMAP (yyerrflag) +#define yynerrs GDB_YY_REMAP (yynerrs) +#define yyps GDB_YY_REMAP (yyps) +#define yypv GDB_YY_REMAP (yypv) +#define yys GDB_YY_REMAP (yys) +#define yy_yys GDB_YY_REMAP (yy_yys) +#define yystate GDB_YY_REMAP (yystate) +#define yytmp GDB_YY_REMAP (yytmp) +#define yyv GDB_YY_REMAP (yyv) +#define yy_yyv GDB_YY_REMAP (yy_yyv) +#define yyval GDB_YY_REMAP (yyval) +#define yylloc GDB_YY_REMAP (yylloc) +#define yyreds GDB_YY_REMAP (yyreds) /* With YYDEBUG defined */ +#define yytoks GDB_YY_REMAP (yytoks) /* With YYDEBUG defined */ +#define yyname GDB_YY_REMAP (yyname) /* With YYDEBUG defined */ +#define yyrule GDB_YY_REMAP (yyrule) /* With YYDEBUG defined */ +#define yylhs GDB_YY_REMAP (yylhs) +#define yylen GDB_YY_REMAP (yylen) +#define yydefred GDB_YY_REMAP (yydefred) +#define yydgoto GDB_YY_REMAP (yydgoto) +#define yysindex GDB_YY_REMAP (yysindex) +#define yyrindex GDB_YY_REMAP (yyrindex) +#define yygindex GDB_YY_REMAP (yygindex) +#define yytable GDB_YY_REMAP (yytable) +#define yycheck GDB_YY_REMAP (yycheck) +#define yyss GDB_YY_REMAP (yyss) +#define yysslim GDB_YY_REMAP (yysslim) +#define yyssp GDB_YY_REMAP (yyssp) +#define yystacksize GDB_YY_REMAP (yystacksize) +#define yyvs GDB_YY_REMAP (yyvs) +#define yyvsp GDB_YY_REMAP (yyvsp) + +/* The following are common to all parsers. */ + +#ifndef YYDEBUG +# define YYDEBUG 1 /* Default to yydebug support */ +#endif + +#define YYFPRINTF parser_fprintf