aboutsummaryrefslogtreecommitdiff
path: root/gdb/yy-remap.h
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2016-04-22 16:40:33 +0100
committerPedro Alves <palves@redhat.com>2016-04-22 16:40:33 +0100
commitb3f11165aad39586cca0352ed5fe32b721699c76 (patch)
treead558eff00c2bdc9d3d75a1adc2d5397b98e5cbc /gdb/yy-remap.h
parent6290672f89d5638a9da5ce10b2f4ba793dcc6396 (diff)
downloadgdb-b3f11165aad39586cca0352ed5fe32b721699c76.zip
gdb-b3f11165aad39586cca0352ed5fe32b721699c76.tar.gz
gdb-b3f11165aad39586cca0352ed5fe32b721699c76.tar.bz2
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 <palves@redhat.com> * 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.
Diffstat (limited to 'gdb/yy-remap.h')
-rw-r--r--gdb/yy-remap.h92
1 files changed, 92 insertions, 0 deletions
diff --git a/gdb/yy-remap.h b/gdb/yy-remap.h
new file mode 100644
index 0000000..71fa946
--- /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 <http://www.gnu.org/licenses/>. */
+
+/* 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