mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-15 15:23:02 +00:00
* 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.
This commit is contained in:
12
ChangeLog
12
ChangeLog
@@ -1,3 +1,15 @@
|
|||||||
|
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>
|
2002-11-12 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* src/getargs.c (long_options): Remove duplicates.
|
* src/getargs.c (long_options): Remove duplicates.
|
||||||
|
|||||||
@@ -65,6 +65,14 @@ m4_define([b4_identification],
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## ---------------- ##
|
||||||
|
## Default values. ##
|
||||||
|
## ---------------- ##
|
||||||
|
|
||||||
|
m4_define_default([b4_epilogue], [])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## ------------------------ ##
|
## ------------------------ ##
|
||||||
## Pure/impure interfaces. ##
|
## Pure/impure interfaces. ##
|
||||||
## ------------------------ ##
|
## ------------------------ ##
|
||||||
|
|||||||
@@ -458,14 +458,14 @@ static const yysigned_char yyrhs[] =
|
|||||||
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
|
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
|
||||||
static const unsigned short yyrline[] =
|
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,
|
193, 194, 195, 196, 197, 199, 200, 201, 202, 203,
|
||||||
205, 206, 207, 208, 209, 212, 214, 215, 219, 226,
|
205, 206, 207, 208, 209, 212, 214, 215, 219, 226,
|
||||||
225, 236, 235, 248, 247, 253, 253, 258, 267, 282,
|
225, 236, 235, 248, 247, 253, 253, 258, 267, 282,
|
||||||
284, 285, 288, 290, 295, 297, 301, 306, 311, 317,
|
284, 285, 288, 290, 295, 297, 301, 306, 311, 317,
|
||||||
323, 333, 336, 345, 347, 353, 355, 360, 367, 366,
|
323, 333, 336, 345, 347, 353, 355, 360, 367, 366,
|
||||||
371, 373, 376, 379, 381, 383, 385, 387, 391, 393,
|
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
|
#endif
|
||||||
|
|
||||||
@@ -1216,10 +1216,9 @@ yyreduce:
|
|||||||
switch (yyn)
|
switch (yyn)
|
||||||
{
|
{
|
||||||
case 2:
|
case 2:
|
||||||
#line 171 "parse-gram.y"
|
#line 172 "parse-gram.y"
|
||||||
{
|
{
|
||||||
yycontrol->errcode = 0;
|
yycontrol->errcode = 0;
|
||||||
epilogue_set (yyvsp[0].string, yylsp[0]);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1601,17 +1600,11 @@ yyreduce:
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 73:
|
|
||||||
#line 421 "parse-gram.y"
|
|
||||||
{
|
|
||||||
yyval.string = xstrdup ("");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 74:
|
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;
|
break;
|
||||||
|
|
||||||
@@ -1619,7 +1612,7 @@ yyreduce:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Line 1056 of /usr/local/share/bison/yacc.c. */
|
/* Line 1056 of /usr/local/share/bison/yacc.c. */
|
||||||
#line 1623 "parse-gram.c"
|
#line 1616 "parse-gram.c"
|
||||||
|
|
||||||
yyvsp -= yylen;
|
yyvsp -= yylen;
|
||||||
yyssp -= yylen;
|
yyssp -= yylen;
|
||||||
@@ -1838,7 +1831,7 @@ yyreturn:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#line 434 "parse-gram.y"
|
#line 432 "parse-gram.y"
|
||||||
|
|
||||||
/*------------------------------------------------------------------.
|
/*------------------------------------------------------------------.
|
||||||
| When debugging the parser, display tokens' locations and values. |
|
| When debugging the parser, display tokens' locations and values. |
|
||||||
@@ -1872,6 +1865,10 @@ yyprint (FILE *file,
|
|||||||
case EPILOGUE:
|
case EPILOGUE:
|
||||||
fprintf (file, " = {{ %s }}", value->string);
|
fprintf (file, " = {{ %s }}", value->string);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
fprintf (file, "unknown token type");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -158,7 +158,8 @@ braced_code_t current_braced_code = action_braced_code;
|
|||||||
|
|
||||||
|
|
||||||
%type <string> STRING string_content
|
%type <string> STRING string_content
|
||||||
BRACED_CODE PROLOGUE EPILOGUE epilogue.opt action
|
BRACED_CODE action
|
||||||
|
PROLOGUE EPILOGUE
|
||||||
%type <struniq> TYPE
|
%type <struniq> TYPE
|
||||||
%type <integer> INT
|
%type <integer> INT
|
||||||
%type <symbol> ID symbol string_as_id
|
%type <symbol> ID symbol string_as_id
|
||||||
@@ -170,7 +171,6 @@ input:
|
|||||||
declarations "%%" grammar epilogue.opt
|
declarations "%%" grammar epilogue.opt
|
||||||
{
|
{
|
||||||
yycontrol->errcode = 0;
|
yycontrol->errcode = 0;
|
||||||
epilogue_set ($4, @4);
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -418,12 +418,10 @@ string_content:
|
|||||||
|
|
||||||
epilogue.opt:
|
epilogue.opt:
|
||||||
/* Nothing. */
|
/* Nothing. */
|
||||||
{
|
|
||||||
$$ = xstrdup ("");
|
|
||||||
}
|
|
||||||
| "%%" EPILOGUE
|
| "%%" EPILOGUE
|
||||||
{
|
{
|
||||||
$$ = $2;
|
epilogue_augment ($2, @2);
|
||||||
|
scanner_last_string_free ();
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -464,6 +462,10 @@ yyprint (FILE *file,
|
|||||||
case EPILOGUE:
|
case EPILOGUE:
|
||||||
fprintf (file, " = {{ %s }}", value->string);
|
fprintf (file, " = {{ %s }}", value->string);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
fprintf (file, "unknown token type");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,8 +84,9 @@ prologue_augment (const char *prologue, location_t location)
|
|||||||
`----------------------*/
|
`----------------------*/
|
||||||
|
|
||||||
void
|
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]], [[",
|
obstack_fgrow1 (&muscle_obstack, "]b4_syncline([[%d]], [[",
|
||||||
location.first_line);
|
location.first_line);
|
||||||
MUSCLE_OBSTACK_SGROW (&muscle_obstack,
|
MUSCLE_OBSTACK_SGROW (&muscle_obstack,
|
||||||
@@ -93,7 +94,9 @@ epilogue_set (const char *epilogue, location_t location)
|
|||||||
obstack_sgrow (&muscle_obstack, "]])[\n");
|
obstack_sgrow (&muscle_obstack, "]])[\n");
|
||||||
obstack_sgrow (&muscle_obstack, epilogue);
|
obstack_sgrow (&muscle_obstack, epilogue);
|
||||||
obstack_1grow (&muscle_obstack, 0);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ extern FILE *gram_in;
|
|||||||
extern int gram__flex_debug;
|
extern int gram__flex_debug;
|
||||||
void scanner_initialize (void);
|
void scanner_initialize (void);
|
||||||
void scanner_free (void);
|
void scanner_free (void);
|
||||||
|
void scanner_last_string_free (void);
|
||||||
|
|
||||||
# define YY_DECL \
|
# define YY_DECL \
|
||||||
int gram_lex (yystype *yylval, location_t *yylloc, \
|
int gram_lex (yystype *yylval, location_t *yylloc, \
|
||||||
@@ -69,7 +70,7 @@ extern braced_code_t current_braced_code;
|
|||||||
/* From reader.c. */
|
/* From reader.c. */
|
||||||
void grammar_start_symbol_set (symbol_t *s, location_t l);
|
void grammar_start_symbol_set (symbol_t *s, location_t l);
|
||||||
void prologue_augment (const char *prologue, location_t location);
|
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_symbol_append (symbol_t *s, location_t l);
|
||||||
void grammar_rule_begin (symbol_t *lhs, location_t l);
|
void grammar_rule_begin (symbol_t *lhs, location_t l);
|
||||||
void grammar_rule_end (location_t l);
|
void grammar_rule_end (location_t l);
|
||||||
|
|||||||
@@ -142,6 +142,10 @@ extend_location (location_t *loc, char const *token, int size)
|
|||||||
|
|
||||||
static struct obstack string_obstack;
|
static struct obstack string_obstack;
|
||||||
|
|
||||||
|
/* A string representing the most recently saved token. */
|
||||||
|
static char *last_string;
|
||||||
|
|
||||||
|
|
||||||
#define YY_OBS_GROW \
|
#define YY_OBS_GROW \
|
||||||
obstack_grow (&string_obstack, yytext, yyleng)
|
obstack_grow (&string_obstack, yytext, yyleng)
|
||||||
|
|
||||||
@@ -154,6 +158,11 @@ static struct obstack string_obstack;
|
|||||||
#define YY_OBS_FREE \
|
#define YY_OBS_FREE \
|
||||||
obstack_free (&string_obstack, last_string)
|
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
|
/* 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
|
the current rule so far, which says where to find `$0' with respect
|
||||||
@@ -199,9 +208,6 @@ splice (\\[ \f\t\v]*\n)*
|
|||||||
/* Scanner context when scanning C code. */
|
/* Scanner context when scanning C code. */
|
||||||
int c_context IF_LINT (= 0);
|
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
|
/* At each yylex invocation, mark the current position as the
|
||||||
start of the next token. */
|
start of the next token. */
|
||||||
YY_STEP;
|
YY_STEP;
|
||||||
|
|||||||
Reference in New Issue
Block a user