* data/yacc.c, data/yacc.c (b4_location_if, b4_pure_if): Move to...
authorAkim Demaille <akim@epita.fr>
Sun, 20 Oct 2002 11:17:20 +0000 (11:17 +0000)
committerAkim Demaille <akim@epita.fr>
Sun, 20 Oct 2002 11:17:20 +0000 (11:17 +0000)
* data/c.m4: here.

ChangeLog
data/c.m4
data/glr.c
data/yacc.c
tests/calc.at

index 505838a..8aba48e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2002-10-20  Akim Demaille  <akim@epita.fr>
 
+       * data/yacc.c, data/yacc.c (b4_location_if, b4_pure_if): Move to...
+       * data/c.m4: here.
+
+2002-10-20  Akim Demaille  <akim@epita.fr>
+
        * src/output.c (prepare): Use MUSCLE_INSERT_STRING.
        * src/muscle_tab.c (muscle_pair_list_grow): Rename `val as
        `pair'.
index d2684fb..370d8e4 100644 (file)
--- a/data/c.m4
+++ b/data/c.m4
@@ -20,7 +20,7 @@ m4_divert(-1)                                               -*- Autoconf -*-
 
 
 ## ----------- ##
-## 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 45e2540..94e033c 100644 (file)
@@ -31,6 +31,14 @@ m4_define_default([b4_stack_depth_init],  [200])
 # 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 @@ int yyparse (void);
 #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 @@ yyparse (YYPARSE_PARAM_ARG)
 
   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 7eb2ad9..75c194f 100644 (file)
@@ -33,7 +33,12 @@ m4_define_default([b4_stack_depth_init],  [200])
 # 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 @@ while (0)
 #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 f09e524..149abb2 100644 (file)
@@ -237,8 +237,8 @@ yylex (LEX_FORMALS)
     {
       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 @@ AT_CHECK_CALC_GLR([%error-verbose %locations --defines --name-prefix=calc --verb
 
 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])