bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

06-glr-lex-param.patch


From: Akim Demaille
Subject: 06-glr-lex-param.patch
Date: Mon, 21 Oct 2002 09:23:43 +0200

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        * data/yacc.c, data/yacc.c (b4_location_if, b4_pure_if): Move to...
        * data/c.m4: here.
        
        
Index: data/yacc.c
--- data/yacc.c Sun, 20 Oct 2002 08:30:29 +0200 akim
+++ data/yacc.c Sun, 20 Oct 2002 09:50:27 +0200 akim
@@ -33,7 +33,12 @@ m4_define_default([b4_stack_depth_init],
 # Location type.
 m4_define_default([b4_location_type], [yyltype])
 
-
+# Accumule in b4_lex_param all the yylex arguments.
+# Yes, this is quite ugly...
+m4_define([b4_lex_param],
+m4_dquote(b4_pure_if([[[[YYSTYPE *]], [[&yylval]]][]dnl
+b4_location_if([, [[YYLTYPE *], [&yylloc]]])])dnl
+m4_ifdef([b4_lex_param], [, ]b4_lex_param)))
 
 
 ## ----------------- ##
@@ -61,15 +66,6 @@ m4_define([b4_rhs_value],
 ## Locations.  ##
 ## ----------- ##
 
-# b4_location_if(IF-TRUE, IF-FALSE)
-# ---------------------------------
-# Expand IF-TRUE, if locations are used, IF-FALSE otherwise.
-m4_define([b4_location_if],
-[m4_if(b4_locations_flag, [1],
-       [$1],
-       [$2])])
-
-
 # b4_lhs_location()
 # -----------------
 # Expansion of @$.
@@ -86,19 +82,6 @@ m4_define([b4_rhs_location],
 
 
 
-## -------------- ##
-## %pure-parser.  ##
-## -------------- ##
-
-# b4_pure_if(IF-TRUE, IF-FALSE)
-# -----------------------------
-# Expand IF-TRUE, if %pure-parser, IF-FALSE otherwise.
-m4_define([b4_pure_if],
-[m4_if(b4_pure, [1],
-       [$1],
-       [$2])])
-
-
 ## ------------------- ##
 ## Output file names.  ##
 ## ------------------- ##
@@ -530,10 +513,7 @@ m4_define([b4_symbol_actions],
 #ifdef YYLEX_PARAM
 # define YYLEX yylex (b4_pure_if([&yylval[]b4_location_if([, &yylloc]), 
])YYLEX_PARAM)
 #else
-# define YYLEX b4_c_function_call([yylex], [int],
-                   b4_pure_if([[[[]], [[&yylval]]],
-                               b4_location_if([[[], [&yylloc]],])])
-                   m4_fst(b4_lex_param))
+# define YYLEX b4_c_function_call([yylex], [int], b4_lex_param)
 #endif
 
 /* Enable debugging if requested.  */
Index: data/c.m4
--- data/c.m4 Sat, 19 Oct 2002 16:53:55 +0200 akim
+++ data/c.m4 Sun, 20 Oct 2002 09:11:32 +0200 akim
@@ -20,7 +20,7 @@
 
 
 ## ----------- ##
-## Copuright.  ##
+## Copyright.  ##
 ## ----------- ##
 
 # b4_copyright(TITLE, YEARS)
@@ -195,3 +195,27 @@ m4_define([b4_c_knr_arg_decls],
 
 m4_define([b4_c_knr_arg_decl],
 [    $1 $2;])
+
+
+
+## ------------------ ##
+## Decoding options.  ##
+## ------------------ ##
+
+
+# b4_location_if(IF-TRUE, IF-FALSE)
+# ---------------------------------
+# Expand IF-TRUE, if locations are used, IF-FALSE otherwise.
+m4_define([b4_location_if],
+[m4_if(b4_locations_flag, [1],
+       [$1],
+       [$2])])
+
+
+# b4_pure_if(IF-TRUE, IF-FALSE)
+# -----------------------------
+# Expand IF-TRUE, if %pure-parser, IF-FALSE otherwise.
+m4_define([b4_pure_if],
+[m4_if(b4_pure, [1],
+       [$1],
+       [$2])])
Index: data/glr.c
--- data/glr.c Sun, 20 Oct 2002 08:30:29 +0200 akim
+++ data/glr.c Sun, 20 Oct 2002 09:44:40 +0200 akim
@@ -31,6 +31,14 @@ m4_define_default([b4_stack_depth_init],
 # Location type.
 m4_define_default([b4_location_type], [yyltype])
 
+# Accumule in b4_lex_param all the yylex arguments.
+# Yes, this is quite ugly...
+m4_define([b4_lex_param],
+m4_dquote(b4_pure_if([[[[YYSTYPE *]], [[yylvalp]]][]dnl
+b4_location_if([, [[YYLTYPE *], [yyllocp]]])])dnl
+m4_ifdef([b4_lex_param], [, ]b4_lex_param)))
+
+m4_define_default([b4_parse_param])
 
 
 ## ----------------- ##
@@ -58,15 +66,6 @@ m4_define([b4_rhs_value],
 ## Locations.  ##
 ## ----------- ##
 
-# b4_location_if(IF-TRUE, IF-FALSE)
-# ---------------------------------
-# Expand IF-TRUE, if locations are used, IF-FALSE otherwise.
-m4_define([b4_location_if],
-[m4_if(b4_locations_flag, [1],
-       [$1],
-       [$2])])
-
-
 # b4_lhs_location()
 # -----------------
 # Expansion of @$.
@@ -83,19 +82,6 @@ m4_define([b4_rhs_location],
 
 
 
-## -------------- ##
-## %pure-parser.  ##
-## -------------- ##
-
-# b4_pure_if(IF-TRUE, IF-FALSE)
-# -----------------------------
-# Expand IF-TRUE, if %pure-parser, IF-FALSE otherwise.
-m4_define([b4_pure_if],
-[m4_if(b4_pure, [1],
-       [$1],
-       [$2])])
-
-
 ## ------------------- ##
 ## Output file names.  ##
 ## ------------------- ##
@@ -428,18 +414,10 @@ m4_define_default([b4_header_guard],
 #endif
 
 /* YYLEX -- calling `yylex' with the right arguments.  */
+#define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[
 
 ]b4_pure_if(
 [
-#ifdef YYLEX_PARAM
-# define YYLEX yylex (yylvalp, b4_location_if([yyllocp, ])YYLEX_PARAM)
-#else
-# define YYLEX yylex (yylvalp[]b4_location_if([, yyllocp]))
-#endif],
-[#define YYLEX  yylex ()])
-
-b4_pure_if(
-[
 #undef yynerrs
 #define yynerrs (yystack->yyerrcnt)
 #undef yychar
@@ -1712,9 +1690,9 @@ m4_define_default([b4_header_guard],
 
   while (yytrue)
     {
-      /* For efficiency, we have two loops, of which the first of which
-       * is specialized to deterministic operation (single stack, no
-       * potential ambiguity). */
+      /* For efficiency, we have two loops, the first of which is
+        specialized to deterministic operation (single stack, no
+        potential ambiguity).  */
 
       /* Standard mode */
       while (yytrue)
Index: tests/calc.at
--- tests/calc.at Sat, 19 Oct 2002 16:53:55 +0200 akim
+++ tests/calc.at Sun, 20 Oct 2002 09:48:36 +0200 akim
@@ -237,8 +237,8 @@ exp:
     {
       init = 0;
 #if YYLSP_NEEDED
-      yylloc.last_column = 1;
-      yylloc.last_line = 1;
+      LOC.last_column = 1;
+      LOC.last_line = 1;
 #endif
     }
 
@@ -536,3 +536,5 @@ m4_define([AT_CHECK_CALC_GLR],
 
 AT_CHECK_CALC_GLR([%debug])
 AT_CHECK_CALC_GLR([%error-verbose %debug %locations --defines 
--name-prefix=calc --verbose --yacc])
+
+# AT_CHECK_CALC_GLR([%pure-parser %error-verbose %debug %locations --defines 
--name-prefix=calc --verbose --yacc])




reply via email to

[Prev in Thread] Current Thread [Next in Thread]