]> git.saurik.com Git - bison.git/blobdiff - data/c.m4
tests: AT_YYERROR_DEFINE: prepare for list of ints.
[bison.git] / data / c.m4
index b49d6dc9378252686199ac3717a1f4fe868538ab..1f266a4713f361a82e5938f7c96a6a4af11e2fed 100644 (file)
--- a/data/c.m4
+++ b/data/c.m4
@@ -77,9 +77,6 @@ m4_define([b4_identification],
 
 /* Pull parsers.  */
 #define YYPULL ]b4_pull_flag])[
-
-/* Using locations.  */
-#define YYLSP_NEEDED ]b4_locations_flag[
 ]])
 
 
@@ -530,3 +527,55 @@ b4_locations_if([, yylocationp])[]b4_user_args[);
   YYFPRINTF (yyoutput, ")");
 }]dnl
 ])
+
+## -------------- ##
+## Declarations.  ##
+## -------------- ##
+
+# b4_declare_yylstype
+# ------------------
+# Declarations that might either go into the header (if --defines) or
+# in the parser body.  Declare YYSTYPE/YYLTYPE, and yylval/yylloc.
+m4_define([b4_declare_yylstype],
+[[#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+]m4_ifdef([b4_stype],
+[[typedef union ]b4_union_name[
+{
+]b4_user_stype[
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1]],
+[m4_if(b4_tag_seen_flag, 0,
+[[typedef int YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1]])])[
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+#endif]b4_locations_if([[
+
+#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
+typedef struct YYLTYPE
+{
+  int first_line;
+  int first_column;
+  int last_line;
+  int last_column;
+} YYLTYPE;
+# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
+# define YYLTYPE_IS_DECLARED 1
+# define YYLTYPE_IS_TRIVIAL 1
+#endif]])
+
+b4_pure_if([], [[extern YYSTYPE ]b4_prefix[lval;
+]b4_locations_if([[extern YYLTYPE ]b4_prefix[lloc;]])])[]dnl
+])
+
+# b4_declare_yydebug
+# ------------------
+m4_define([b4_declare_yydebug],
+[[/* Enabling traces.  */
+#ifndef YYDEBUG
+# define YYDEBUG ]b4_debug_flag[
+#endif
+#if YYDEBUG
+extern int ]b4_prefix[debug;
+#endif][]dnl
+])