]> git.saurik.com Git - bison.git/commitdiff
* data/c.m4 (b4_token_enums): New.
authorAkim Demaille <akim@epita.fr>
Fri, 16 Sep 2005 19:26:40 +0000 (19:26 +0000)
committerAkim Demaille <akim@epita.fr>
Fri, 16 Sep 2005 19:26:40 +0000 (19:26 +0000)
(b4_token_defines): Rename as...
(b4_token_enums_defines): this.
(b4_token_defines): New, output only the #defines.
* data/yacc.c, data/glr.c: Adjust.
* data/lalr1.cc: Use b4_token_enums instead of b4_token_enums_defines.
* data/c.m4 (b4_yydestruct_generate, b4_yysymprint_generate): Define
as default values.

ChangeLog
data/Makefile.am
data/c++.m4 [new file with mode: 0644]
data/c.m4
data/glr.c
data/lalr1.cc
data/yacc.c
src/output.c

index c619d4d39d6fd8220e1ccfca0928d0363a65b070..5864bb7d1437ba16b54165c28533cbf604a4c611 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2005-09-16  Akim  <akim@epita.fr>
+
+       * data/c.m4 (b4_token_enums): New.
+       (b4_token_defines): Rename as...
+       (b4_token_enums_defines): this.
+       (b4_token_defines): New, output only the #defines.
+       * data/yacc.c, data/glr.c: Adjust.
+       * data/lalr1.cc: Use b4_token_enums instead of b4_token_enums_defines.
+       * data/c.m4 (b4_yydestruct_generate, b4_yysymprint_generate): Define
+       as default values.
+
 2005-09-16  Akim Demaille  <akim@epita.fr>
 
        * data/lalr1.cc (yylex_): Remove, inline its code.
 2005-09-16  Akim Demaille  <akim@epita.fr>
 
        * data/lalr1.cc (yylex_): Remove, inline its code.
index a9b599557d52cc3501680febf52c14356f6cfc28..26e0a001788026b902d22f49d83207fd3bca88c9 100644 (file)
@@ -1,4 +1,4 @@
-## Copyright (C) 2002 Free Software Foundation, Inc.
+## Copyright (C) 2002, 2005 Free Software Foundation, Inc.
 
 ## 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
 
 ## 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
@@ -15,7 +15,9 @@
 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 ## 02110-1301  USA
 
 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 ## 02110-1301  USA
 
-dist_pkgdata_DATA = README c.m4 yacc.c lalr1.cc glr.c
+dist_pkgdata_DATA = README \
+   c.m4 yacc.c glr.c \
+   c++.m4 lalr1.cc
 
 m4sugardir = $(pkgdatadir)/m4sugar
 dist_m4sugar_DATA = m4sugar/m4sugar.m4
 
 m4sugardir = $(pkgdatadir)/m4sugar
 dist_m4sugar_DATA = m4sugar/m4sugar.m4
diff --git a/data/c++.m4 b/data/c++.m4
new file mode 100644 (file)
index 0000000..0f127b9
--- /dev/null
@@ -0,0 +1,121 @@
+m4_divert(-1)
+
+# C++ skeleton for Bison
+
+# Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+# 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 2 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, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301  USA
+
+## ---------------- ##
+## Default values.  ##
+## ---------------- ##
+
+# Default parser class name.
+m4_define_default([b4_parser_class_name], [parser])
+m4_define_default([b4_location_type], [location])
+m4_define_default([b4_filename_type], [std::string])
+
+
+
+# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
+# -----------------------------------------------------
+# Output the definition of the tokens (if there are) as enums.
+m4_define([b4_token_enums],
+[m4_if([$@], [[]], [],
+[/* Tokens.  */
+   enum yytokentype {
+m4_map_sep([     b4_token_enum], [,
+],
+           [$@])
+   };
+])])
+
+
+## ----------------- ##
+## Semantic Values.  ##
+## ----------------- ##
+
+
+# b4_lhs_value([TYPE])
+# --------------------
+# Expansion of $<TYPE>$.
+m4_define([b4_lhs_value],
+[(yyval[]m4_ifval([$1], [.$1]))])
+
+
+# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
+# --------------------------------------
+# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
+# symbols on RHS.
+m4_define([b4_rhs_value],
+[(yysemantic_stack_@{m4_eval([$1 - $2])@}m4_ifval([$3], [.$3]))])
+
+# b4_lhs_location()
+# -----------------
+# Expansion of @$.
+m4_define([b4_lhs_location],
+[(yyloc)])
+
+
+# b4_rhs_location(RULE-LENGTH, NUM)
+# ---------------------------------
+# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
+# on RHS.
+m4_define([b4_rhs_location],
+[(yylocation_stack_@{m4_eval([$1 - $2])@})])
+
+
+# b4_parse_param_decl
+# -------------------
+# Extra formal arguments of the constructor.
+# Change the parameter names from "foo" into "foo_yyarg", so that
+# there is no collision bw the user chosen attribute name, and the
+# argument name in the constructor.
+m4_define([b4_parse_param_decl],
+[m4_ifset([b4_parse_param],
+          [m4_map_sep([b4_parse_param_decl_1], [, ], [b4_parse_param])])])
+
+m4_define([b4_parse_param_decl_1],
+[$1_yyarg])
+
+
+
+# b4_parse_param_cons
+# -------------------
+# Extra initialisations of the constructor.
+m4_define([b4_parse_param_cons],
+          [m4_ifset([b4_parse_param],
+                   [,
+      b4_cc_constructor_calls(b4_parse_param)])])
+m4_define([b4_cc_constructor_calls],
+         [m4_map_sep([b4_cc_constructor_call], [,
+      ], [$@])])
+m4_define([b4_cc_constructor_call],
+         [$2 ($2_yyarg)])
+
+# b4_parse_param_vars
+# -------------------
+# Extra instance variables.
+m4_define([b4_parse_param_vars],
+          [m4_ifset([b4_parse_param],
+                   [
+    /* User arguments.  */
+b4_cc_var_decls(b4_parse_param)])])
+m4_define([b4_cc_var_decls],
+         [m4_map_sep([b4_cc_var_decl], [
+], [$@])])
+m4_define([b4_cc_var_decl],
+         [    $1;])
index 2a3218bf07de67f88d9313de99b24086ca4ba856..d8dc6bc4bc589775db0790b7bb91f21382630a45 100644 (file)
--- a/data/c.m4
+++ b/data/c.m4
@@ -169,6 +169,16 @@ m4_define([b4_token_define],
 ])
 
 
 ])
 
 
+# b4_token_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
+# -------------------------------------------------------
+# Output the definition of the tokens (if there are) as #defines.
+m4_define([b4_token_defines],
+[m4_if([$@], [[]], [],
+[/* Tokens.  */
+m4_map([b4_token_define], [$@])])
+])
+
+
 # b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
 # ---------------------------------------
 # Output the definition of this token as an enum.
 # b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
 # ---------------------------------------
 # Output the definition of this token as an enum.
@@ -176,10 +186,10 @@ m4_define([b4_token_enum],
 [$1 = $2])
 
 
 [$1 = $2])
 
 
-# b4_token_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
-# -------------------------------------------------------
-# Output the definition of the tokens (if there are) as enums and #define.
-m4_define([b4_token_defines],
+# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
+# -----------------------------------------------------
+# Output the definition of the tokens (if there are) as enums.
+m4_define([b4_token_enums],
 [m4_if([$@], [[]], [],
 [/* Tokens.  */
 #ifndef YYTOKENTYPE
 [m4_if([$@], [[]], [],
 [/* Tokens.  */
 #ifndef YYTOKENTYPE
@@ -192,8 +202,14 @@ m4_map_sep([     b4_token_enum], [,
            [$@])
    };
 #endif
            [$@])
    };
 #endif
-m4_map([b4_token_define], [$@])
-])
+])])
+
+
+# b4_token_enums_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
+# -------------------------------------------------------------
+# Output the definition of the tokens (if there are) as enums and #defines.
+m4_define([b4_token_enums_defines],
+[b4_token_enums($@)b4_token_defines($@)
 ])
 
 
 ])
 
 
@@ -348,7 +364,7 @@ m4_popdef([b4_dollar_dollar])dnl
 # Generate the "yydestruct" function, which declaration is issued using
 # FUNCTION-DECLARATOR, which may be "b4_c_ansi_function_def" for ISO C
 # or "b4_c_function_def" for K&R.
 # Generate the "yydestruct" function, which declaration is issued using
 # FUNCTION-DECLARATOR, which may be "b4_c_ansi_function_def" for ISO C
 # or "b4_c_function_def" for K&R.
-m4_define([b4_yydestruct_generate],
+m4_define_default([b4_yydestruct_generate],
 [[/*-----------------------------------------------.
 | Release the memory associated to this symbol.  |
 `-----------------------------------------------*/
 [[/*-----------------------------------------------.
 | Release the memory associated to this symbol.  |
 `-----------------------------------------------*/
@@ -383,7 +399,7 @@ m4_define([b4_yydestruct_generate],
 # Generate the "yysymprint" function, which declaration is issued using
 # FUNCTION-DECLARATOR, which may be "b4_c_ansi_function_def" for ISO C
 # or "b4_c_function_def" for K&R.
 # Generate the "yysymprint" function, which declaration is issued using
 # FUNCTION-DECLARATOR, which may be "b4_c_ansi_function_def" for ISO C
 # or "b4_c_function_def" for K&R.
-m4_define([b4_yysymprint_generate],
+m4_define_default([b4_yysymprint_generate],
 [[/*--------------------------------.
 | Print this symbol on YYOUTPUT.  |
 `--------------------------------*/
 [[/*--------------------------------.
 | Print this symbol on YYOUTPUT.  |
 `--------------------------------*/
index c6e845385265b0e13092772f3e15597cedcb1d89..244c43081a8d6d016f9de177393a791bb64645c7 100644 (file)
@@ -154,7 +154,7 @@ m4_if(b4_prefix[], [yy], [],
 #define yynerrs b4_prefix[]nerrs
 #define yylloc b4_prefix[]lloc])
 
 #define yynerrs b4_prefix[]nerrs
 #define yylloc b4_prefix[]lloc])
 
-b4_token_defines(b4_tokens)
+b4_token_enums_defines(b4_tokens)
 
 /* Copy the first part of user declarations.  */
 b4_pre_prologue[
 
 /* Copy the first part of user declarations.  */
 b4_pre_prologue[
@@ -2321,7 +2321,7 @@ m4_if(b4_defines_flag, 0, [],
 b4_copyright([Skeleton parser for GLR parsing with Bison],
   [2002, 2003, 2004, 2005])
 
 b4_copyright([Skeleton parser for GLR parsing with Bison],
   [2002, 2003, 2004, 2005])
 
-b4_token_defines(b4_tokens)
+b4_token_enums_defines(b4_tokens)
 
 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
 m4_ifdef([b4_stype],
 
 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
 m4_ifdef([b4_stype],
index c8c702a633ef8287de8351b52121a45b2d537c8e..043b082ad8b9539d2561b2394e10e3b337711465 100644 (file)
@@ -19,95 +19,7 @@ m4_divert(-1)
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 # 02110-1301  USA
 
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 # 02110-1301  USA
 
-## ---------------- ##
-## Default values.  ##
-## ---------------- ##
-
-# Default parser class name.
-m4_define_default([b4_parser_class_name], [parser])
-
-
-
-## ----------------- ##
-## Semantic Values.  ##
-## ----------------- ##
-
-
-# b4_lhs_value([TYPE])
-# --------------------
-# Expansion of $<TYPE>$.
-m4_define([b4_lhs_value],
-[(yyval[]m4_ifval([$1], [.$1]))])
-
-
-# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
-# --------------------------------------
-# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
-# symbols on RHS.
-m4_define([b4_rhs_value],
-[(yysemantic_stack_@{m4_eval([$1 - $2])@}m4_ifval([$3], [.$3]))])
-
-m4_define_default([b4_location_type], [location])
-m4_define_default([b4_filename_type], [std::string])
-
-# b4_lhs_location()
-# -----------------
-# Expansion of @$.
-m4_define([b4_lhs_location],
-[(yyloc)])
-
-
-# b4_rhs_location(RULE-LENGTH, NUM)
-# ---------------------------------
-# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
-# on RHS.
-m4_define([b4_rhs_location],
-[(yylocation_stack_@{m4_eval([$1 - $2])@})])
-
-
-# b4_parse_param_decl
-# -------------------
-# Extra formal arguments of the constructor.
-# Change the parameter names from "foo" into "foo_yyarg", so that
-# there is no collision bw the user chosen attribute name, and the
-# argument name in the constructor.
-m4_define([b4_parse_param_decl],
-[m4_ifset([b4_parse_param],
-          [m4_map_sep([b4_parse_param_decl_1], [, ], [b4_parse_param])])])
-
-m4_define([b4_parse_param_decl_1],
-[$1_yyarg])
-
-
-
-# b4_parse_param_cons
-# -------------------
-# Extra initialisations of the constructor.
-m4_define([b4_parse_param_cons],
-          [m4_ifset([b4_parse_param],
-                   [,
-      b4_cc_constructor_calls(b4_parse_param)])])
-m4_define([b4_cc_constructor_calls],
-         [m4_map_sep([b4_cc_constructor_call], [,
-      ], [$@])])
-m4_define([b4_cc_constructor_call],
-         [$2 ($2_yyarg)])
-
-# b4_parse_param_vars
-# -------------------
-# Extra instance variables.
-m4_define([b4_parse_param_vars],
-          [m4_ifset([b4_parse_param],
-                   [
-    /* User arguments.  */
-b4_cc_var_decls(b4_parse_param)])])
-m4_define([b4_cc_var_decls],
-         [m4_map_sep([b4_cc_var_decl], [
-], [$@])])
-m4_define([b4_cc_var_decl],
-         [    $1;])
-
-
+m4_include(b4_pkgdatadir/[c++.m4])
 
 # We do want M4 expansion after # for CPP macros.
 m4_changecom()
 
 # We do want M4 expansion after # for CPP macros.
 m4_changecom()
index 4f9e7a37c0fff551e2b6dd6d72771788e63cfe59..7e7c44ac406a583cafba3433bfb2f85e6180ff5c 100644 (file)
@@ -164,7 +164,7 @@ m4_if(b4_prefix[], [yy], [],
 #define yynerrs b4_prefix[]nerrs
 b4_location_if([#define yylloc b4_prefix[]lloc])])[
 
 #define yynerrs b4_prefix[]nerrs
 b4_location_if([#define yylloc b4_prefix[]lloc])])[
 
-]b4_token_defines(b4_tokens)[
+]b4_token_enums_defines(b4_tokens)[
 
 /* Copy the first part of user declarations.  */
 ]b4_pre_prologue[
 
 /* Copy the first part of user declarations.  */
 ]b4_pre_prologue[
@@ -1410,7 +1410,7 @@ b4_copyright([Skeleton parser for Yacc-like parsing with Bison],
    This special exception was added by the Free Software Foundation
    in version 1.24 of Bison.  */
 
    This special exception was added by the Free Software Foundation
    in version 1.24 of Bison.  */
 
-b4_token_defines(b4_tokens)
+b4_token_enums_defines(b4_tokens)
 
 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
 m4_ifdef([b4_stype],
 
 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
 m4_ifdef([b4_stype],
index 9bc806f14e4cc529e5e33c96cc20b6acac104d13..3839412e885808dcf86d5874d61f3b34a1a65fee 100644 (file)
@@ -616,8 +616,12 @@ prepare (void)
        skeleton = "yacc.c";
     }
 
        skeleton = "yacc.c";
     }
 
-  /* Parse the skeleton file and output the needed parsers.  */
-  MUSCLE_INSERT_C_STRING ("skeleton", skeleton);
+  /* About the skeletons. */
+  {
+    char const* p = getenv ("BISON_PKGDATADIR");
+    MUSCLE_INSERT_STRING ("pkgdatadir", p ? p : PKGDATADIR);
+    MUSCLE_INSERT_C_STRING ("skeleton", skeleton);
+  }
 }
 
 
 }