Restore.
* src/scan-gram.l (last_string): Is global to the file, not to
yylex.
* src/parse-gram.y (input): Don't append the epilogue here,
(epilogue.opt): do it here, and free the scanner's obstack.
* src/reader.c (epilogue_set): Rename as...
(epilogue_augment): this.
* data/c.m4 (b4_epilogue): Defaults to empty.
+2002-11-12 Akim Demaille <akim@epita.fr>
+
+ * src/scan-gram.l, src/reader.h (scanner_last_string_free):
+ Restore.
+ * src/scan-gram.l (last_string): Is global to the file, not to
+ yylex.
+ * src/parse-gram.y (input): Don't append the epilogue here,
+ (epilogue.opt): do it here, and free the scanner's obstack.
+ * src/reader.c (epilogue_set): Rename as...
+ (epilogue_augment): this.
+ * data/c.m4 (b4_epilogue): Defaults to empty.
+
2002-11-12 Akim Demaille <akim@epita.fr>
* src/getargs.c (long_options): Remove duplicates.
+## ---------------- ##
+## Default values. ##
+## ---------------- ##
+
+m4_define_default([b4_epilogue], [])
+
+
+
## ------------------------ ##
## Pure/impure interfaces. ##
## ------------------------ ##
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const unsigned short yyrline[] =
{
- 0, 169, 169, 182, 184, 187, 189, 190, 191, 192,
+ 0, 170, 170, 182, 184, 187, 189, 190, 191, 192,
193, 194, 195, 196, 197, 199, 200, 201, 202, 203,
205, 206, 207, 208, 209, 212, 214, 215, 219, 226,
225, 236, 235, 248, 247, 253, 253, 258, 267, 282,
284, 285, 288, 290, 295, 297, 301, 306, 311, 317,
323, 333, 336, 345, 347, 353, 355, 360, 367, 366,
371, 373, 376, 379, 381, 383, 385, 387, 391, 393,
- 396, 402, 411, 419, 424, 430, 432
+ 396, 402, 411, 419, 421, 428, 430
};
#endif
switch (yyn)
{
case 2:
-#line 171 "parse-gram.y"
+#line 172 "parse-gram.y"
{
yycontrol->errcode = 0;
- epilogue_set (yyvsp[0].string, yylsp[0]);
}
break;
}
break;
- case 73:
-#line 421 "parse-gram.y"
- {
- yyval.string = xstrdup ("");
- }
- break;
-
case 74:
-#line 425 "parse-gram.y"
+#line 422 "parse-gram.y"
{
- yyval.string = yyvsp[0].string;
+ epilogue_augment (yyvsp[0].string, yylsp[0]);
+ scanner_last_string_free ();
}
break;
}
/* Line 1056 of /usr/local/share/bison/yacc.c. */
-#line 1623 "parse-gram.c"
+#line 1616 "parse-gram.c"
\f
yyvsp -= yylen;
yyssp -= yylen;
}
-#line 434 "parse-gram.y"
+#line 432 "parse-gram.y"
/*------------------------------------------------------------------.
| When debugging the parser, display tokens' locations and values. |
case EPILOGUE:
fprintf (file, " = {{ %s }}", value->string);
break;
+
+ default:
+ fprintf (file, "unknown token type");
+ break;
}
}
%type <string> STRING string_content
- BRACED_CODE PROLOGUE EPILOGUE epilogue.opt action
+ BRACED_CODE action
+ PROLOGUE EPILOGUE
%type <struniq> TYPE
%type <integer> INT
%type <symbol> ID symbol string_as_id
declarations "%%" grammar epilogue.opt
{
yycontrol->errcode = 0;
- epilogue_set ($4, @4);
}
;
epilogue.opt:
/* Nothing. */
- {
- $$ = xstrdup ("");
- }
| "%%" EPILOGUE
{
- $$ = $2;
+ epilogue_augment ($2, @2);
+ scanner_last_string_free ();
}
;
case EPILOGUE:
fprintf (file, " = {{ %s }}", value->string);
break;
+
+ default:
+ fprintf (file, "unknown token type");
+ break;
}
}
`----------------------*/
void
-epilogue_set (const char *epilogue, location_t location)
+epilogue_augment (const char *epilogue, location_t location)
{
+ char *extension = NULL;
obstack_fgrow1 (&muscle_obstack, "]b4_syncline([[%d]], [[",
location.first_line);
MUSCLE_OBSTACK_SGROW (&muscle_obstack,
obstack_sgrow (&muscle_obstack, "]])[\n");
obstack_sgrow (&muscle_obstack, epilogue);
obstack_1grow (&muscle_obstack, 0);
- muscle_insert ("epilogue", obstack_finish (&muscle_obstack));
+ extension = obstack_finish (&muscle_obstack);
+ muscle_grow ("epilogue", extension, "");
+ obstack_free (&muscle_obstack, extension);
}
extern int gram__flex_debug;
void scanner_initialize (void);
void scanner_free (void);
+void scanner_last_string_free (void);
# define YY_DECL \
int gram_lex (yystype *yylval, location_t *yylloc, \
/* From reader.c. */
void grammar_start_symbol_set (symbol_t *s, location_t l);
void prologue_augment (const char *prologue, location_t location);
-void epilogue_set (const char *epilogue, location_t location);
+void epilogue_augment (const char *epilogue, location_t location);
void grammar_symbol_append (symbol_t *s, location_t l);
void grammar_rule_begin (symbol_t *lhs, location_t l);
void grammar_rule_end (location_t l);
static struct obstack string_obstack;
+/* A string representing the most recently saved token. */
+static char *last_string;
+
+
#define YY_OBS_GROW \
obstack_grow (&string_obstack, yytext, yyleng)
#define YY_OBS_FREE \
obstack_free (&string_obstack, last_string)
+void
+scanner_last_string_free (void)
+{
+ YY_OBS_FREE;
+}
/* Within well-formed rules, RULE_LENGTH is the number of values in
the current rule so far, which says where to find `$0' with respect
/* Scanner context when scanning C code. */
int c_context IF_LINT (= 0);
- /* A string representing the most recently saved token. */
- char *last_string;
-
/* At each yylex invocation, mark the current position as the
start of the next token. */
YY_STEP;