]> git.saurik.com Git - bison.git/blobdiff - data/c.m4
news: schedule the removal of the ";" hack
[bison.git] / data / c.m4
index 3c6c6f4dbd83d1c5894dcf7560fdb8144baf01e0..3954613bfb7c5e992678356315c110c156fcaf2a 100644 (file)
--- a/data/c.m4
+++ b/data/c.m4
@@ -417,13 +417,28 @@ m4_define([b4_case],
 $2
     break;])
 
+# b4_dollar_dollar_(NAME, FIELD, DEFAULT-FIELD)
+# ---------------------------------------------
+# If FIELD (or DEFAULT-FIELD) is non-null, read it in pointer NAME,
+# otherwise just dereference.
+m4_define([b4_dollar_dollar_],
+[m4_if([$2], [[]],
+       [m4_ifval([$3], [($1->$3)],
+                 [(*$1)])],
+       [($1->$2)])])
+
+
 # b4_symbol_actions(FILENAME, LINENO,
 #                   SYMBOL-TAG, SYMBOL-NUM,
 #                   SYMBOL-ACTION, SYMBOL-TYPENAME)
 # -------------------------------------------------
+# Issue the code for a symbol action (e.g., %printer).
+#
+# Define b4_dollar_dollar([TYPE-NAME]), and b4_at_dollar, which are
+# invoked where $<TYPE-NAME>$ and @$ were specified by the user.
 m4_define([b4_symbol_actions],
 [m4_pushdef([b4_dollar_dollar],
-   [m4_ifval([$6], [(yyvaluep->$6)], [(*yyvaluep)])])dnl
+   [b4_dollar_dollar_([yyvaluep], m4_dquote($][1), [$6])])dnl
 m4_pushdef([b4_at_dollar], [(*yylocationp)])dnl
       case $4: /* $3 */
 b4_syncline([$2], [$1])
@@ -610,3 +625,32 @@ m4_define([b4_declare_yydebug],
 extern int ]b4_prefix[debug;
 #endif][]dnl
 ])
+
+# b4_yylloc_default_define
+# ------------------------
+# Define YYLLOC_DEFAULT.
+m4_define([b4_yylloc_default_define],
+[[/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
+   If N is 0, then set CURRENT to the empty location which ends
+   the previous symbol: RHS[0] (always defined).  */
+
+#ifndef YYLLOC_DEFAULT
+# define YYLLOC_DEFAULT(Current, Rhs, N)                                \
+    do                                                                  \
+      if (YYID (N))                                                     \
+        {                                                               \
+          (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
+          (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
+          (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
+          (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
+        }                                                               \
+      else                                                              \
+        {                                                               \
+          (Current).first_line   = (Current).last_line   =              \
+            YYRHSLOC (Rhs, 0).last_line;                                \
+          (Current).first_column = (Current).last_column =              \
+            YYRHSLOC (Rhs, 0).last_column;                              \
+        }                                                               \
+    while (YYID (0))
+#endif
+]])