mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-18 16:53:02 +00:00
Remove last commit at the request of Paul Eggert.
This commit is contained in:
76
ChangeLog
76
ChangeLog
@@ -1,79 +1,3 @@
|
|||||||
2006-11-10 Joel E. Denny <jdenny@ces.clemson.edu>
|
|
||||||
|
|
||||||
Encapsulate code properties and related functionality for the various
|
|
||||||
destructors, printers, and actions into a code_props structure and
|
|
||||||
interface.
|
|
||||||
* src/location.h (EMPTY_LOCATION_INIT): Define so that it's easier to
|
|
||||||
consistently initialize const structs that have an empty location field.
|
|
||||||
* src/location.c (empty_location): Initialize with EMPTY_LOCATION_INIT
|
|
||||||
to ensure consistency.
|
|
||||||
* src/output.c (symbol_destructors_output, symbol_printers_output):
|
|
||||||
Replace with...
|
|
||||||
(symbol_code_props_output): ... this to eliminate duplicate code.
|
|
||||||
(output_skeleton): Update to use symbol_code_props_output.
|
|
||||||
* src/parse-gram.y (prologue_declaration, braceless, epilogue.opt):
|
|
||||||
Update all uses of translate_* functions to use the new code_props
|
|
||||||
interface and to use gram_scanner_last_string_free and
|
|
||||||
code_scanner_last_string_free where possible.
|
|
||||||
(grammar_declaration): symbol_list_destructor_set and
|
|
||||||
symbol_list_printer_set now perform the translation, so don't do it
|
|
||||||
here. Use gram_scanner_last_string_free where possible.
|
|
||||||
* src/reader.c: Update to use code_props interface for destructors and
|
|
||||||
rule actions.
|
|
||||||
* src/scan-code.h (code_props): New structure.
|
|
||||||
(code_props_none_init, CODE_PROPS_NONE_INIT, code_props_none): New
|
|
||||||
function, macro, and const global variable for initializing a
|
|
||||||
code_props with no code.
|
|
||||||
(code_props_plain_init, code_props_symbol_action_init,
|
|
||||||
code_props_rule_action_init, code_props_translate_code,
|
|
||||||
code_props_code_get, code_props_location_get,
|
|
||||||
code_props_is_value_used): The rest of the new code_props interface.
|
|
||||||
(translate_rule_action, translate_symbol_action, translate_code):
|
|
||||||
Remove as these are now just special cases within
|
|
||||||
code_props_translate_code, which is switched on the code_props kind.
|
|
||||||
(code_scanner_last_string_free): New function similar to
|
|
||||||
gram_scanner_last_string_free.
|
|
||||||
* src/scan-code.l: Implement the new interface.
|
|
||||||
(last_string): New static global similar to the one in scan-gram.l.
|
|
||||||
(SC_SYMBOL_ACTION): For $$, set the is_value_used member of the
|
|
||||||
code_props since Bison will one day use this information for
|
|
||||||
destructors and printers.
|
|
||||||
(<*><<EOF>>): Use STRING_FINISH so that last_string is set.
|
|
||||||
(handle_action_dollar): Update to use the code_props interface of rule
|
|
||||||
actions. Use symbol_list_n_get and set is_value_used directly since
|
|
||||||
symbol_list_n_used_set is removed.
|
|
||||||
* src/symlist.h, src/symlist.c (symbol_list): Replace action,
|
|
||||||
action_location, and used members with a code_props member, and update
|
|
||||||
all uses.
|
|
||||||
(symbol_list_n_used_set): Remove since it would need to break the
|
|
||||||
encapsulation of code_props.
|
|
||||||
(symbol_list_destructor_set, symbol_list_printer_set): Perform code
|
|
||||||
translation here rather than depending on the caller to do so.
|
|
||||||
* src/symtab.h (symbol, semantic_type): Remove destructor_location and
|
|
||||||
printer_location members and change the type of the destructor and
|
|
||||||
printer members to code_props.
|
|
||||||
(symbol_destructor_location_get, symbol_printer_location_get): Remove
|
|
||||||
unneeded.
|
|
||||||
(symbol_destructor_set, symbol_destructor_get, symbol_printer_set,
|
|
||||||
symbol_printer_get, semantic_type_destructor_set,
|
|
||||||
semantic_type_printer_set, default_tagged_destructor_set,
|
|
||||||
default_tagless_destructor_set, default_tagged_printer_set,
|
|
||||||
default_tagless_printer_set): Use code_props in arguments and return
|
|
||||||
types in place of const char * and location.
|
|
||||||
* src/symtab.c: Update implementation for interface and struct changes.
|
|
||||||
(default_tagged_destructor_location,
|
|
||||||
default_tagless_destructor_location, default_tagged_printer_location,
|
|
||||||
default_tagless_printer_location): Remove since we...
|
|
||||||
(default_tagged_destructor, default_tagless_destructor,
|
|
||||||
default_tagged_printer, default_tagless_printer): ... change the type
|
|
||||||
of these to code_props.
|
|
||||||
(SYMBOL_CODE_PRINT): New similar to SYMBOL_ATTR_PRINT but for
|
|
||||||
code_props members.
|
|
||||||
(symbol_print): Use SYMBOL_CODE_PRINT.
|
|
||||||
|
|
||||||
* src/scan-gram.h (gram_last_string): Remove declaration.
|
|
||||||
* src/scan-gram.l (last_string): Declare it static.
|
|
||||||
|
|
||||||
2006-11-10 Joel E. Denny <jdenny@ces.clemson.edu>
|
2006-11-10 Joel E. Denny <jdenny@ces.clemson.edu>
|
||||||
|
|
||||||
* tests/testsuite.at (AT_CHECK): Don't miss an exit value of 0 because
|
* tests/testsuite.at (AT_CHECK): Don't miss an exit value of 0 because
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
#include "complain.h"
|
#include "complain.h"
|
||||||
#include "location.h"
|
#include "location.h"
|
||||||
|
|
||||||
location const empty_location = EMPTY_LOCATION_INIT;
|
location const empty_location;
|
||||||
|
|
||||||
/* If BUF is null, add BUFSIZE (which in this case must be less than
|
/* If BUF is null, add BUFSIZE (which in this case must be less than
|
||||||
INT_MAX) to COLUMN; otherwise, add mbsnwidth (BUF, BUFSIZE, 0) to
|
INT_MAX) to COLUMN; otherwise, add mbsnwidth (BUF, BUFSIZE, 0) to
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ typedef struct
|
|||||||
|
|
||||||
#define YYLTYPE location
|
#define YYLTYPE location
|
||||||
|
|
||||||
#define EMPTY_LOCATION_INIT {{NULL, 0, 0}, {NULL, 0, 0}}
|
|
||||||
extern location const empty_location;
|
extern location const empty_location;
|
||||||
|
|
||||||
/* Set *LOC and adjust scanner cursor to account for token TOKEN of
|
/* Set *LOC and adjust scanner cursor to account for token TOKEN of
|
||||||
|
|||||||
89
src/output.c
89
src/output.c
@@ -373,41 +373,70 @@ token_definitions_output (FILE *out)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------.
|
/*---------------------------------------.
|
||||||
| Output the symbol destructors and printers to OUT. |
|
| Output the symbol destructors to OUT. |
|
||||||
`----------------------------------------------------*/
|
`---------------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
symbol_code_props_output (FILE *out, char const *what,
|
symbol_destructors_output (FILE *out)
|
||||||
code_props (*get)(symbol *))
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char const *sep = "";
|
char const *sep = "";
|
||||||
|
|
||||||
fputs ("m4_define([b4_symbol_", out);
|
fputs ("m4_define([b4_symbol_destructors], \n[", out);
|
||||||
fputs (what, out);
|
|
||||||
fputs ("], \n[", out);
|
|
||||||
for (i = 0; i < nsyms; ++i)
|
for (i = 0; i < nsyms; ++i)
|
||||||
{
|
if (symbol_destructor_get (symbols[i]))
|
||||||
symbol *sym = symbols[i];
|
{
|
||||||
char const *code = code_props_code_get ((*get) (sym));
|
symbol *sym = symbols[i];
|
||||||
if (code)
|
|
||||||
{
|
/* Filename, lineno,
|
||||||
location loc = code_props_location_get ((*get) (sym));
|
Symbol-name, Symbol-number,
|
||||||
/* Filename, lineno,
|
destructor, optional typename. */
|
||||||
Symbol-name, Symbol-number,
|
fprintf (out, "%s[", sep);
|
||||||
code, optional typename. */
|
sep = ",\n";
|
||||||
fprintf (out, "%s[", sep);
|
escaped_output (out, symbol_destructor_location_get (sym).start.file);
|
||||||
sep = ",\n";
|
fprintf (out, ", %d, ",
|
||||||
escaped_output (out, loc.start.file);
|
symbol_destructor_location_get (sym).start.line);
|
||||||
fprintf (out, ", %d, ", loc.start.line);
|
escaped_output (out, sym->tag);
|
||||||
escaped_output (out, sym->tag);
|
fprintf (out, ", %d, [[%s]]", sym->number,
|
||||||
fprintf (out, ", %d, [[%s]]", sym->number, code);
|
symbol_destructor_get (sym));
|
||||||
if (sym->type_name)
|
if (sym->type_name)
|
||||||
fprintf (out, ", [[%s]]", sym->type_name);
|
fprintf (out, ", [[%s]]", sym->type_name);
|
||||||
fputc (']', out);
|
fputc (']', out);
|
||||||
}
|
}
|
||||||
}
|
fputs ("])\n\n", out);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------.
|
||||||
|
| Output the symbol printers to OUT. |
|
||||||
|
`------------------------------------*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
symbol_printers_output (FILE *out)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char const *sep = "";
|
||||||
|
|
||||||
|
fputs ("m4_define([b4_symbol_printers], \n[", out);
|
||||||
|
for (i = 0; i < nsyms; ++i)
|
||||||
|
if (symbol_printer_get (symbols[i]))
|
||||||
|
{
|
||||||
|
symbol *sym = symbols[i];
|
||||||
|
|
||||||
|
/* Filename, lineno,
|
||||||
|
Symbol-name, Symbol-number,
|
||||||
|
printer, optional typename. */
|
||||||
|
fprintf (out, "%s[", sep);
|
||||||
|
sep = ",\n";
|
||||||
|
escaped_output (out, symbol_printer_location_get (sym).start.file);
|
||||||
|
fprintf (out, ", %d, ", symbol_printer_location_get (sym).start.line);
|
||||||
|
escaped_output (out, sym->tag);
|
||||||
|
fprintf (out, ", %d, [[%s]]", sym->number, symbol_printer_get (sym));
|
||||||
|
if (sym->type_name)
|
||||||
|
fprintf (out, ", [[%s]]", sym->type_name);
|
||||||
|
fputc (']', out);
|
||||||
|
}
|
||||||
fputs ("])\n\n", out);
|
fputs ("])\n\n", out);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -532,8 +561,8 @@ output_skeleton (void)
|
|||||||
user_actions_output (out);
|
user_actions_output (out);
|
||||||
merger_output (out);
|
merger_output (out);
|
||||||
token_definitions_output (out);
|
token_definitions_output (out);
|
||||||
symbol_code_props_output (out, "destructors", &symbol_destructor_get);
|
symbol_destructors_output (out);
|
||||||
symbol_code_props_output (out, "printers", &symbol_printer_get);
|
symbol_printers_output (out);
|
||||||
|
|
||||||
muscles_m4_output (out);
|
muscles_m4_output (out);
|
||||||
|
|
||||||
|
|||||||
211
src/parse-gram.c
211
src/parse-gram.c
@@ -668,16 +668,16 @@ static const yytype_int8 yyrhs[] =
|
|||||||
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
|
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
|
||||||
static const yytype_uint16 yyrline[] =
|
static const yytype_uint16 yyrline[] =
|
||||||
{
|
{
|
||||||
0, 210, 210, 218, 220, 224, 225, 233, 234, 235,
|
0, 210, 210, 218, 220, 224, 225, 226, 227, 228,
|
||||||
236, 237, 238, 239, 240, 245, 254, 255, 256, 257,
|
229, 230, 231, 232, 233, 238, 242, 243, 244, 245,
|
||||||
258, 259, 260, 261, 262, 263, 264, 265, 266, 267,
|
246, 247, 248, 249, 250, 251, 252, 253, 254, 255,
|
||||||
268, 272, 273, 274, 278, 285, 292, 296, 300, 301,
|
256, 260, 261, 262, 266, 274, 282, 286, 290, 291,
|
||||||
302, 303, 314, 315, 319, 348, 348, 353, 353, 358,
|
292, 293, 304, 305, 309, 337, 337, 342, 342, 347,
|
||||||
369, 384, 385, 386, 390, 391, 396, 398, 403, 404,
|
358, 373, 374, 375, 379, 380, 385, 387, 392, 393,
|
||||||
408, 409, 410, 411, 416, 421, 426, 432, 438, 449,
|
397, 398, 399, 400, 405, 410, 415, 421, 427, 438,
|
||||||
450, 459, 460, 466, 467, 468, 475, 475, 479, 480,
|
439, 448, 449, 455, 456, 457, 464, 464, 468, 469,
|
||||||
481, 486, 487, 489, 491, 493, 495, 505, 506, 512,
|
470, 475, 476, 478, 480, 482, 484, 494, 495, 501,
|
||||||
516, 521, 541, 543, 552, 557, 558, 563, 570, 572
|
505, 510, 526, 528, 537, 542, 543, 548, 555, 557
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1887,69 +1887,62 @@ yyreduce:
|
|||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 225 "parse-gram.y"
|
#line 225 "parse-gram.y"
|
||||||
{
|
{ prologue_augment (translate_code ((yyvsp[(1) - (1)].chars), (yylsp[(1) - (1)])), (yylsp[(1) - (1)]), union_seen); }
|
||||||
code_props plain_code;
|
|
||||||
code_props_plain_init (&plain_code, (yyvsp[(1) - (1)].chars), (yylsp[(1) - (1)]));
|
|
||||||
code_props_translate_code (&plain_code);
|
|
||||||
gram_scanner_last_string_free ();
|
|
||||||
prologue_augment (code_props_code_get (plain_code), (yylsp[(1) - (1)]), union_seen);
|
|
||||||
code_scanner_last_string_free ();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7:
|
case 7:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 233 "parse-gram.y"
|
#line 226 "parse-gram.y"
|
||||||
{ debug_flag = true; }
|
{ debug_flag = true; }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 234 "parse-gram.y"
|
#line 227 "parse-gram.y"
|
||||||
{ muscle_insert ((yyvsp[(2) - (3)].chars), (yyvsp[(3) - (3)].chars)); }
|
{ muscle_insert ((yyvsp[(2) - (3)].chars), (yyvsp[(3) - (3)].chars)); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 9:
|
case 9:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 235 "parse-gram.y"
|
#line 228 "parse-gram.y"
|
||||||
{ defines_flag = true; }
|
{ defines_flag = true; }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 10:
|
case 10:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 236 "parse-gram.y"
|
#line 229 "parse-gram.y"
|
||||||
{ error_verbose = true; }
|
{ error_verbose = true; }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 11:
|
case 11:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 237 "parse-gram.y"
|
#line 230 "parse-gram.y"
|
||||||
{ expected_sr_conflicts = (yyvsp[(2) - (2)].integer); }
|
{ expected_sr_conflicts = (yyvsp[(2) - (2)].integer); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 12:
|
case 12:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 238 "parse-gram.y"
|
#line 231 "parse-gram.y"
|
||||||
{ expected_rr_conflicts = (yyvsp[(2) - (2)].integer); }
|
{ expected_rr_conflicts = (yyvsp[(2) - (2)].integer); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 13:
|
case 13:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 239 "parse-gram.y"
|
#line 232 "parse-gram.y"
|
||||||
{ spec_file_prefix = (yyvsp[(3) - (3)].chars); }
|
{ spec_file_prefix = (yyvsp[(3) - (3)].chars); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 14:
|
case 14:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 241 "parse-gram.y"
|
#line 234 "parse-gram.y"
|
||||||
{
|
{
|
||||||
nondeterministic_parser = true;
|
nondeterministic_parser = true;
|
||||||
glr_parser = true;
|
glr_parser = true;
|
||||||
@@ -1959,119 +1952,114 @@ yyreduce:
|
|||||||
case 15:
|
case 15:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 246 "parse-gram.y"
|
#line 239 "parse-gram.y"
|
||||||
{
|
{
|
||||||
code_props action;
|
muscle_code_grow ("initial_action", translate_symbol_action ((yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])), (yylsp[(2) - (2)]));
|
||||||
code_props_symbol_action_init (&action, (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)]));
|
|
||||||
code_props_translate_code (&action);
|
|
||||||
gram_scanner_last_string_free ();
|
|
||||||
muscle_code_grow ("initial_action", code_props_code_get (action), (yylsp[(2) - (2)]));
|
|
||||||
code_scanner_last_string_free ();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 16:
|
case 16:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 254 "parse-gram.y"
|
#line 242 "parse-gram.y"
|
||||||
{ add_param ("lex_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); }
|
{ add_param ("lex_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 17:
|
case 17:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 255 "parse-gram.y"
|
#line 243 "parse-gram.y"
|
||||||
{ locations_flag = true; }
|
{ locations_flag = true; }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 18:
|
case 18:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 256 "parse-gram.y"
|
#line 244 "parse-gram.y"
|
||||||
{ spec_name_prefix = (yyvsp[(3) - (3)].chars); }
|
{ spec_name_prefix = (yyvsp[(3) - (3)].chars); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 19:
|
case 19:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 257 "parse-gram.y"
|
#line 245 "parse-gram.y"
|
||||||
{ no_lines_flag = true; }
|
{ no_lines_flag = true; }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 20:
|
case 20:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 258 "parse-gram.y"
|
#line 246 "parse-gram.y"
|
||||||
{ nondeterministic_parser = true; }
|
{ nondeterministic_parser = true; }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 21:
|
case 21:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 259 "parse-gram.y"
|
#line 247 "parse-gram.y"
|
||||||
{ spec_outfile = (yyvsp[(3) - (3)].chars); }
|
{ spec_outfile = (yyvsp[(3) - (3)].chars); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 22:
|
case 22:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 260 "parse-gram.y"
|
#line 248 "parse-gram.y"
|
||||||
{ add_param ("parse_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); }
|
{ add_param ("parse_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 23:
|
case 23:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 261 "parse-gram.y"
|
#line 249 "parse-gram.y"
|
||||||
{ pure_parser = true; }
|
{ pure_parser = true; }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 24:
|
case 24:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 262 "parse-gram.y"
|
#line 250 "parse-gram.y"
|
||||||
{ push_parser = true; }
|
{ push_parser = true; }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 25:
|
case 25:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 263 "parse-gram.y"
|
#line 251 "parse-gram.y"
|
||||||
{ version_check (&(yylsp[(2) - (2)]), (yyvsp[(2) - (2)].chars)); }
|
{ version_check (&(yylsp[(2) - (2)]), (yyvsp[(2) - (2)].chars)); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 26:
|
case 26:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 264 "parse-gram.y"
|
#line 252 "parse-gram.y"
|
||||||
{ skeleton = (yyvsp[(2) - (2)].chars); }
|
{ skeleton = (yyvsp[(2) - (2)].chars); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 27:
|
case 27:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 265 "parse-gram.y"
|
#line 253 "parse-gram.y"
|
||||||
{ token_table_flag = true; }
|
{ token_table_flag = true; }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 28:
|
case 28:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 266 "parse-gram.y"
|
#line 254 "parse-gram.y"
|
||||||
{ report_flag = report_states; }
|
{ report_flag = report_states; }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 29:
|
case 29:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 267 "parse-gram.y"
|
#line 255 "parse-gram.y"
|
||||||
{ yacc_flag = true; }
|
{ yacc_flag = true; }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 33:
|
case 33:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 275 "parse-gram.y"
|
#line 263 "parse-gram.y"
|
||||||
{
|
{
|
||||||
grammar_start_symbol_set ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)]));
|
grammar_start_symbol_set ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)]));
|
||||||
}
|
}
|
||||||
@@ -2080,11 +2068,12 @@ yyreduce:
|
|||||||
case 34:
|
case 34:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 279 "parse-gram.y"
|
#line 267 "parse-gram.y"
|
||||||
{
|
{
|
||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
|
const char *action = translate_symbol_action ((yyvsp[(2) - (3)].code), (yylsp[(2) - (3)]));
|
||||||
for (list = (yyvsp[(3) - (3)].list); list; list = list->next)
|
for (list = (yyvsp[(3) - (3)].list); list; list = list->next)
|
||||||
symbol_list_destructor_set (list, (yyvsp[(2) - (3)].code), (yylsp[(2) - (3)]));
|
symbol_list_destructor_set (list, action, (yylsp[(2) - (3)]));
|
||||||
symbol_list_free ((yyvsp[(3) - (3)].list));
|
symbol_list_free ((yyvsp[(3) - (3)].list));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -2092,11 +2081,12 @@ yyreduce:
|
|||||||
case 35:
|
case 35:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 286 "parse-gram.y"
|
#line 275 "parse-gram.y"
|
||||||
{
|
{
|
||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
|
const char *action = translate_symbol_action ((yyvsp[(2) - (3)].code), (yylsp[(2) - (3)]));
|
||||||
for (list = (yyvsp[(3) - (3)].list); list; list = list->next)
|
for (list = (yyvsp[(3) - (3)].list); list; list = list->next)
|
||||||
symbol_list_printer_set (list, (yyvsp[(2) - (3)].code), (yylsp[(2) - (3)]));
|
symbol_list_printer_set (list, action, (yylsp[(2) - (3)]));
|
||||||
symbol_list_free ((yyvsp[(3) - (3)].list));
|
symbol_list_free ((yyvsp[(3) - (3)].list));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -2104,7 +2094,7 @@ yyreduce:
|
|||||||
case 36:
|
case 36:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 293 "parse-gram.y"
|
#line 283 "parse-gram.y"
|
||||||
{
|
{
|
||||||
default_prec = true;
|
default_prec = true;
|
||||||
}
|
}
|
||||||
@@ -2113,7 +2103,7 @@ yyreduce:
|
|||||||
case 37:
|
case 37:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 297 "parse-gram.y"
|
#line 287 "parse-gram.y"
|
||||||
{
|
{
|
||||||
default_prec = false;
|
default_prec = false;
|
||||||
}
|
}
|
||||||
@@ -2122,49 +2112,49 @@ yyreduce:
|
|||||||
case 38:
|
case 38:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 300 "parse-gram.y"
|
#line 290 "parse-gram.y"
|
||||||
{ prologue_augment ((yyvsp[(2) - (2)].chars), (yylsp[(2) - (2)]), true); }
|
{ prologue_augment ((yyvsp[(2) - (2)].chars), (yylsp[(2) - (2)]), true); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 39:
|
case 39:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 301 "parse-gram.y"
|
#line 291 "parse-gram.y"
|
||||||
{ prologue_augment ((yyvsp[(2) - (2)].chars), (yylsp[(2) - (2)]), false); }
|
{ prologue_augment ((yyvsp[(2) - (2)].chars), (yylsp[(2) - (2)]), false); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 40:
|
case 40:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 302 "parse-gram.y"
|
#line 292 "parse-gram.y"
|
||||||
{ muscle_code_grow ("provides", (yyvsp[(2) - (2)].chars), (yylsp[(2) - (2)])); }
|
{ muscle_code_grow ("provides", (yyvsp[(2) - (2)].chars), (yylsp[(2) - (2)])); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 41:
|
case 41:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 303 "parse-gram.y"
|
#line 293 "parse-gram.y"
|
||||||
{ muscle_code_grow ("requires", (yyvsp[(2) - (2)].chars), (yylsp[(2) - (2)])); }
|
{ muscle_code_grow ("requires", (yyvsp[(2) - (2)].chars), (yylsp[(2) - (2)])); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 42:
|
case 42:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 314 "parse-gram.y"
|
#line 304 "parse-gram.y"
|
||||||
{}
|
{}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 43:
|
case 43:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 315 "parse-gram.y"
|
#line 305 "parse-gram.y"
|
||||||
{ muscle_code_grow ("union_name", (yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); }
|
{ muscle_code_grow ("union_name", (yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 44:
|
case 44:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 320 "parse-gram.y"
|
#line 310 "parse-gram.y"
|
||||||
{
|
{
|
||||||
char const *body = (yyvsp[(3) - (3)].code);
|
char const *body = (yyvsp[(3) - (3)].code);
|
||||||
|
|
||||||
@@ -2185,21 +2175,20 @@ yyreduce:
|
|||||||
|
|
||||||
union_seen = true;
|
union_seen = true;
|
||||||
muscle_code_grow ("stype", body, (yylsp[(3) - (3)]));
|
muscle_code_grow ("stype", body, (yylsp[(3) - (3)]));
|
||||||
gram_scanner_last_string_free ();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 45:
|
case 45:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 348 "parse-gram.y"
|
#line 337 "parse-gram.y"
|
||||||
{ current_class = nterm_sym; }
|
{ current_class = nterm_sym; }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 46:
|
case 46:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 349 "parse-gram.y"
|
#line 338 "parse-gram.y"
|
||||||
{
|
{
|
||||||
current_class = unknown_sym;
|
current_class = unknown_sym;
|
||||||
current_type = NULL;
|
current_type = NULL;
|
||||||
@@ -2209,14 +2198,14 @@ yyreduce:
|
|||||||
case 47:
|
case 47:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 353 "parse-gram.y"
|
#line 342 "parse-gram.y"
|
||||||
{ current_class = token_sym; }
|
{ current_class = token_sym; }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 48:
|
case 48:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 354 "parse-gram.y"
|
#line 343 "parse-gram.y"
|
||||||
{
|
{
|
||||||
current_class = unknown_sym;
|
current_class = unknown_sym;
|
||||||
current_type = NULL;
|
current_type = NULL;
|
||||||
@@ -2226,7 +2215,7 @@ yyreduce:
|
|||||||
case 49:
|
case 49:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 359 "parse-gram.y"
|
#line 348 "parse-gram.y"
|
||||||
{
|
{
|
||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
tag_seen = true;
|
tag_seen = true;
|
||||||
@@ -2239,7 +2228,7 @@ yyreduce:
|
|||||||
case 50:
|
case 50:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 370 "parse-gram.y"
|
#line 359 "parse-gram.y"
|
||||||
{
|
{
|
||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
++current_prec;
|
++current_prec;
|
||||||
@@ -2256,98 +2245,98 @@ yyreduce:
|
|||||||
case 51:
|
case 51:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 384 "parse-gram.y"
|
#line 373 "parse-gram.y"
|
||||||
{ (yyval.assoc) = left_assoc; }
|
{ (yyval.assoc) = left_assoc; }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 52:
|
case 52:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 385 "parse-gram.y"
|
#line 374 "parse-gram.y"
|
||||||
{ (yyval.assoc) = right_assoc; }
|
{ (yyval.assoc) = right_assoc; }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 53:
|
case 53:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 386 "parse-gram.y"
|
#line 375 "parse-gram.y"
|
||||||
{ (yyval.assoc) = non_assoc; }
|
{ (yyval.assoc) = non_assoc; }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 54:
|
case 54:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 390 "parse-gram.y"
|
#line 379 "parse-gram.y"
|
||||||
{ current_type = NULL; }
|
{ current_type = NULL; }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 55:
|
case 55:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 391 "parse-gram.y"
|
#line 380 "parse-gram.y"
|
||||||
{ current_type = (yyvsp[(1) - (1)].uniqstr); tag_seen = true; }
|
{ current_type = (yyvsp[(1) - (1)].uniqstr); tag_seen = true; }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 56:
|
case 56:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 397 "parse-gram.y"
|
#line 386 "parse-gram.y"
|
||||||
{ (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); }
|
{ (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 57:
|
case 57:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 399 "parse-gram.y"
|
#line 388 "parse-gram.y"
|
||||||
{ (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), symbol_list_sym_new ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)]))); }
|
{ (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), symbol_list_sym_new ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)]))); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 58:
|
case 58:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 403 "parse-gram.y"
|
#line 392 "parse-gram.y"
|
||||||
{ (yyval.list) = (yyvsp[(1) - (1)].list); }
|
{ (yyval.list) = (yyvsp[(1) - (1)].list); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 59:
|
case 59:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 404 "parse-gram.y"
|
#line 393 "parse-gram.y"
|
||||||
{ (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].list)); }
|
{ (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].list)); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 60:
|
case 60:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 408 "parse-gram.y"
|
#line 397 "parse-gram.y"
|
||||||
{ (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); }
|
{ (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 61:
|
case 61:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 409 "parse-gram.y"
|
#line 398 "parse-gram.y"
|
||||||
{ (yyval.list) = symbol_list_type_new ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); }
|
{ (yyval.list) = symbol_list_type_new ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 62:
|
case 62:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 410 "parse-gram.y"
|
#line 399 "parse-gram.y"
|
||||||
{ (yyval.list) = symbol_list_default_tagged_new ((yylsp[(1) - (1)])); }
|
{ (yyval.list) = symbol_list_default_tagged_new ((yylsp[(1) - (1)])); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 63:
|
case 63:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 411 "parse-gram.y"
|
#line 400 "parse-gram.y"
|
||||||
{ (yyval.list) = symbol_list_default_tagless_new ((yylsp[(1) - (1)])); }
|
{ (yyval.list) = symbol_list_default_tagless_new ((yylsp[(1) - (1)])); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 64:
|
case 64:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 417 "parse-gram.y"
|
#line 406 "parse-gram.y"
|
||||||
{
|
{
|
||||||
current_type = (yyvsp[(1) - (1)].uniqstr);
|
current_type = (yyvsp[(1) - (1)].uniqstr);
|
||||||
tag_seen = true;
|
tag_seen = true;
|
||||||
@@ -2357,7 +2346,7 @@ yyreduce:
|
|||||||
case 65:
|
case 65:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 422 "parse-gram.y"
|
#line 411 "parse-gram.y"
|
||||||
{
|
{
|
||||||
symbol_class_set ((yyvsp[(1) - (1)].symbol), current_class, (yylsp[(1) - (1)]), true);
|
symbol_class_set ((yyvsp[(1) - (1)].symbol), current_class, (yylsp[(1) - (1)]), true);
|
||||||
symbol_type_set ((yyvsp[(1) - (1)].symbol), current_type, (yylsp[(1) - (1)]));
|
symbol_type_set ((yyvsp[(1) - (1)].symbol), current_type, (yylsp[(1) - (1)]));
|
||||||
@@ -2367,7 +2356,7 @@ yyreduce:
|
|||||||
case 66:
|
case 66:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 427 "parse-gram.y"
|
#line 416 "parse-gram.y"
|
||||||
{
|
{
|
||||||
symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true);
|
symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true);
|
||||||
symbol_type_set ((yyvsp[(1) - (2)].symbol), current_type, (yylsp[(1) - (2)]));
|
symbol_type_set ((yyvsp[(1) - (2)].symbol), current_type, (yylsp[(1) - (2)]));
|
||||||
@@ -2378,7 +2367,7 @@ yyreduce:
|
|||||||
case 67:
|
case 67:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 433 "parse-gram.y"
|
#line 422 "parse-gram.y"
|
||||||
{
|
{
|
||||||
symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true);
|
symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true);
|
||||||
symbol_type_set ((yyvsp[(1) - (2)].symbol), current_type, (yylsp[(1) - (2)]));
|
symbol_type_set ((yyvsp[(1) - (2)].symbol), current_type, (yylsp[(1) - (2)]));
|
||||||
@@ -2389,7 +2378,7 @@ yyreduce:
|
|||||||
case 68:
|
case 68:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 439 "parse-gram.y"
|
#line 428 "parse-gram.y"
|
||||||
{
|
{
|
||||||
symbol_class_set ((yyvsp[(1) - (3)].symbol), current_class, (yylsp[(1) - (3)]), true);
|
symbol_class_set ((yyvsp[(1) - (3)].symbol), current_class, (yylsp[(1) - (3)]), true);
|
||||||
symbol_type_set ((yyvsp[(1) - (3)].symbol), current_type, (yylsp[(1) - (3)]));
|
symbol_type_set ((yyvsp[(1) - (3)].symbol), current_type, (yylsp[(1) - (3)]));
|
||||||
@@ -2401,7 +2390,7 @@ yyreduce:
|
|||||||
case 75:
|
case 75:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 469 "parse-gram.y"
|
#line 458 "parse-gram.y"
|
||||||
{
|
{
|
||||||
yyerrok;
|
yyerrok;
|
||||||
}
|
}
|
||||||
@@ -2410,70 +2399,70 @@ yyreduce:
|
|||||||
case 76:
|
case 76:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 475 "parse-gram.y"
|
#line 464 "parse-gram.y"
|
||||||
{ current_lhs = (yyvsp[(1) - (1)].symbol); current_lhs_location = (yylsp[(1) - (1)]); }
|
{ current_lhs = (yyvsp[(1) - (1)].symbol); current_lhs_location = (yylsp[(1) - (1)]); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 78:
|
case 78:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 479 "parse-gram.y"
|
#line 468 "parse-gram.y"
|
||||||
{ grammar_current_rule_end ((yylsp[(1) - (1)])); }
|
{ grammar_current_rule_end ((yylsp[(1) - (1)])); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 79:
|
case 79:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 480 "parse-gram.y"
|
#line 469 "parse-gram.y"
|
||||||
{ grammar_current_rule_end ((yylsp[(3) - (3)])); }
|
{ grammar_current_rule_end ((yylsp[(3) - (3)])); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 81:
|
case 81:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 486 "parse-gram.y"
|
#line 475 "parse-gram.y"
|
||||||
{ grammar_current_rule_begin (current_lhs, current_lhs_location); }
|
{ grammar_current_rule_begin (current_lhs, current_lhs_location); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 82:
|
case 82:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 488 "parse-gram.y"
|
#line 477 "parse-gram.y"
|
||||||
{ grammar_current_rule_symbol_append ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)])); }
|
{ grammar_current_rule_symbol_append ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)])); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 83:
|
case 83:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 490 "parse-gram.y"
|
#line 479 "parse-gram.y"
|
||||||
{ grammar_current_rule_action_append ((yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); }
|
{ grammar_current_rule_action_append ((yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 84:
|
case 84:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 492 "parse-gram.y"
|
#line 481 "parse-gram.y"
|
||||||
{ grammar_current_rule_prec_set ((yyvsp[(3) - (3)].symbol), (yylsp[(3) - (3)])); }
|
{ grammar_current_rule_prec_set ((yyvsp[(3) - (3)].symbol), (yylsp[(3) - (3)])); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 85:
|
case 85:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 494 "parse-gram.y"
|
#line 483 "parse-gram.y"
|
||||||
{ grammar_current_rule_dprec_set ((yyvsp[(3) - (3)].integer), (yylsp[(3) - (3)])); }
|
{ grammar_current_rule_dprec_set ((yyvsp[(3) - (3)].integer), (yylsp[(3) - (3)])); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 86:
|
case 86:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 496 "parse-gram.y"
|
#line 485 "parse-gram.y"
|
||||||
{ grammar_current_rule_merge_set ((yyvsp[(3) - (3)].uniqstr), (yylsp[(3) - (3)])); }
|
{ grammar_current_rule_merge_set ((yyvsp[(3) - (3)].uniqstr), (yylsp[(3) - (3)])); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 89:
|
case 89:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 512 "parse-gram.y"
|
#line 501 "parse-gram.y"
|
||||||
{
|
{
|
||||||
static char one[] = "1";
|
static char one[] = "1";
|
||||||
(yyval.chars) = one;
|
(yyval.chars) = one;
|
||||||
@@ -2483,28 +2472,24 @@ yyreduce:
|
|||||||
case 91:
|
case 91:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 522 "parse-gram.y"
|
#line 511 "parse-gram.y"
|
||||||
{
|
{
|
||||||
code_props plain_code;
|
|
||||||
(yyvsp[(1) - (1)].code)[strlen ((yyvsp[(1) - (1)].code)) - 1] = '\n';
|
(yyvsp[(1) - (1)].code)[strlen ((yyvsp[(1) - (1)].code)) - 1] = '\n';
|
||||||
code_props_plain_init (&plain_code, (yyvsp[(1) - (1)].code)+1, (yylsp[(1) - (1)]));
|
(yyval.chars) = translate_code ((yyvsp[(1) - (1)].code) + 1, (yylsp[(1) - (1)]));
|
||||||
code_props_translate_code (&plain_code);
|
|
||||||
gram_scanner_last_string_free ();
|
|
||||||
(yyval.chars) = code_props_code_get (plain_code);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 92:
|
case 92:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 542 "parse-gram.y"
|
#line 527 "parse-gram.y"
|
||||||
{ (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); }
|
{ (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 93:
|
case 93:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 544 "parse-gram.y"
|
#line 529 "parse-gram.y"
|
||||||
{
|
{
|
||||||
(yyval.symbol) = symbol_get (char_name ((yyvsp[(1) - (1)].character)), (yylsp[(1) - (1)]));
|
(yyval.symbol) = symbol_get (char_name ((yyvsp[(1) - (1)].character)), (yylsp[(1) - (1)]));
|
||||||
symbol_class_set ((yyval.symbol), token_sym, (yylsp[(1) - (1)]), false);
|
symbol_class_set ((yyval.symbol), token_sym, (yylsp[(1) - (1)]), false);
|
||||||
@@ -2515,14 +2500,14 @@ yyreduce:
|
|||||||
case 94:
|
case 94:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 552 "parse-gram.y"
|
#line 537 "parse-gram.y"
|
||||||
{ (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); }
|
{ (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 97:
|
case 97:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 564 "parse-gram.y"
|
#line 549 "parse-gram.y"
|
||||||
{
|
{
|
||||||
(yyval.symbol) = symbol_get (quotearg_style (c_quoting_style, (yyvsp[(1) - (1)].chars)), (yylsp[(1) - (1)]));
|
(yyval.symbol) = symbol_get (quotearg_style (c_quoting_style, (yyvsp[(1) - (1)].chars)), (yylsp[(1) - (1)]));
|
||||||
symbol_class_set ((yyval.symbol), token_sym, (yylsp[(1) - (1)]), false);
|
symbol_class_set ((yyval.symbol), token_sym, (yylsp[(1) - (1)]), false);
|
||||||
@@ -2532,21 +2517,17 @@ yyreduce:
|
|||||||
case 99:
|
case 99:
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 573 "parse-gram.y"
|
#line 558 "parse-gram.y"
|
||||||
{
|
{
|
||||||
code_props plain_code;
|
muscle_code_grow ("epilogue", translate_code ((yyvsp[(2) - (2)].chars), (yylsp[(2) - (2)])), (yylsp[(2) - (2)]));
|
||||||
code_props_plain_init (&plain_code, (yyvsp[(2) - (2)].chars), (yylsp[(2) - (2)]));
|
|
||||||
code_props_translate_code (&plain_code);
|
|
||||||
gram_scanner_last_string_free ();
|
gram_scanner_last_string_free ();
|
||||||
muscle_code_grow ("epilogue", code_props_code_get (plain_code), (yylsp[(2) - (2)]));
|
|
||||||
code_scanner_last_string_free ();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Line 1269 of yacc.c */
|
/* Line 1269 of yacc.c */
|
||||||
#line 2550 "parse-gram.c"
|
#line 2531 "parse-gram.c"
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
|
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
|
||||||
@@ -2765,7 +2746,7 @@ yyreturn:
|
|||||||
|
|
||||||
|
|
||||||
/* Line 1486 of yacc.c */
|
/* Line 1486 of yacc.c */
|
||||||
#line 583 "parse-gram.y"
|
#line 564 "parse-gram.y"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ static int current_prec = 0;
|
|||||||
%printer { fputs (char_name ($$), stderr); } CHAR
|
%printer { fputs (char_name ($$), stderr); } CHAR
|
||||||
|
|
||||||
/* braceless is not to be used for rule or symbol actions, as it
|
/* braceless is not to be used for rule or symbol actions, as it
|
||||||
calls code_props_plain_init. */
|
calls translate_code. */
|
||||||
%type <chars> STRING "%{...%}" EPILOGUE braceless content content.opt
|
%type <chars> STRING "%{...%}" EPILOGUE braceless content content.opt
|
||||||
%type <code> "{...}"
|
%type <code> "{...}"
|
||||||
%printer { fputs (quotearg_style (c_quoting_style, $$), stderr); }
|
%printer { fputs (quotearg_style (c_quoting_style, $$), stderr); }
|
||||||
@@ -222,14 +222,7 @@ prologue_declarations:
|
|||||||
|
|
||||||
prologue_declaration:
|
prologue_declaration:
|
||||||
grammar_declaration
|
grammar_declaration
|
||||||
| "%{...%}" {
|
| "%{...%}" { prologue_augment (translate_code ($1, @1), @1, union_seen); }
|
||||||
code_props plain_code;
|
|
||||||
code_props_plain_init (&plain_code, $1, @1);
|
|
||||||
code_props_translate_code (&plain_code);
|
|
||||||
gram_scanner_last_string_free ();
|
|
||||||
prologue_augment (code_props_code_get (plain_code), @1, union_seen);
|
|
||||||
code_scanner_last_string_free ();
|
|
||||||
}
|
|
||||||
| "%debug" { debug_flag = true; }
|
| "%debug" { debug_flag = true; }
|
||||||
| "%define" STRING content.opt { muscle_insert ($2, $3); }
|
| "%define" STRING content.opt { muscle_insert ($2, $3); }
|
||||||
| "%defines" { defines_flag = true; }
|
| "%defines" { defines_flag = true; }
|
||||||
@@ -244,12 +237,7 @@ prologue_declaration:
|
|||||||
}
|
}
|
||||||
| "%initial-action" "{...}"
|
| "%initial-action" "{...}"
|
||||||
{
|
{
|
||||||
code_props action;
|
muscle_code_grow ("initial_action", translate_symbol_action ($2, @2), @2);
|
||||||
code_props_symbol_action_init (&action, $2, @2);
|
|
||||||
code_props_translate_code (&action);
|
|
||||||
gram_scanner_last_string_free ();
|
|
||||||
muscle_code_grow ("initial_action", code_props_code_get (action), @2);
|
|
||||||
code_scanner_last_string_free ();
|
|
||||||
}
|
}
|
||||||
| "%lex-param" "{...}" { add_param ("lex_param", $2, @2); }
|
| "%lex-param" "{...}" { add_param ("lex_param", $2, @2); }
|
||||||
| "%locations" { locations_flag = true; }
|
| "%locations" { locations_flag = true; }
|
||||||
@@ -278,15 +266,17 @@ grammar_declaration:
|
|||||||
| "%destructor" "{...}" generic_symlist
|
| "%destructor" "{...}" generic_symlist
|
||||||
{
|
{
|
||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
|
const char *action = translate_symbol_action ($2, @2);
|
||||||
for (list = $3; list; list = list->next)
|
for (list = $3; list; list = list->next)
|
||||||
symbol_list_destructor_set (list, $2, @2);
|
symbol_list_destructor_set (list, action, @2);
|
||||||
symbol_list_free ($3);
|
symbol_list_free ($3);
|
||||||
}
|
}
|
||||||
| "%printer" "{...}" generic_symlist
|
| "%printer" "{...}" generic_symlist
|
||||||
{
|
{
|
||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
|
const char *action = translate_symbol_action ($2, @2);
|
||||||
for (list = $3; list; list = list->next)
|
for (list = $3; list; list = list->next)
|
||||||
symbol_list_printer_set (list, $2, @2);
|
symbol_list_printer_set (list, action, @2);
|
||||||
symbol_list_free ($3);
|
symbol_list_free ($3);
|
||||||
}
|
}
|
||||||
| "%default-prec"
|
| "%default-prec"
|
||||||
@@ -337,7 +327,6 @@ grammar_declaration:
|
|||||||
|
|
||||||
union_seen = true;
|
union_seen = true;
|
||||||
muscle_code_grow ("stype", body, @3);
|
muscle_code_grow ("stype", body, @3);
|
||||||
gram_scanner_last_string_free ();
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -520,12 +509,8 @@ content.opt:
|
|||||||
braceless:
|
braceless:
|
||||||
"{...}"
|
"{...}"
|
||||||
{
|
{
|
||||||
code_props plain_code;
|
|
||||||
$1[strlen ($1) - 1] = '\n';
|
$1[strlen ($1) - 1] = '\n';
|
||||||
code_props_plain_init (&plain_code, $1+1, @1);
|
$$ = translate_code ($1 + 1, @1);
|
||||||
code_props_translate_code (&plain_code);
|
|
||||||
gram_scanner_last_string_free ();
|
|
||||||
$$ = code_props_code_get (plain_code);
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -571,12 +556,8 @@ epilogue.opt:
|
|||||||
/* Nothing. */
|
/* Nothing. */
|
||||||
| "%%" EPILOGUE
|
| "%%" EPILOGUE
|
||||||
{
|
{
|
||||||
code_props plain_code;
|
muscle_code_grow ("epilogue", translate_code ($2, @2), @2);
|
||||||
code_props_plain_init (&plain_code, $2, @2);
|
|
||||||
code_props_translate_code (&plain_code);
|
|
||||||
gram_scanner_last_string_free ();
|
gram_scanner_last_string_free ();
|
||||||
muscle_code_grow ("epilogue", code_props_code_get (plain_code), @2);
|
|
||||||
code_scanner_last_string_free ();
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
67
src/reader.c
67
src/reader.c
@@ -253,21 +253,13 @@ grammar_current_rule_begin (symbol *lhs, location loc)
|
|||||||
static bool
|
static bool
|
||||||
symbol_should_be_used (symbol_list const *s)
|
symbol_should_be_used (symbol_list const *s)
|
||||||
{
|
{
|
||||||
if (code_props_code_get (symbol_destructor_get (s->content.sym)))
|
if (symbol_destructor_get (s->content.sym))
|
||||||
return true;
|
return true;
|
||||||
if (warnings_flag & warnings_midrule_values)
|
if (warnings_flag & warnings_midrule_values)
|
||||||
{
|
return ((s->midrule && s->midrule->used)
|
||||||
if (s->midrule && code_props_is_value_used (s->midrule->action_props))
|
|| (s->midrule_parent_rule
|
||||||
return true;
|
&& symbol_list_n_get (s->midrule_parent_rule,
|
||||||
if (s->midrule_parent_rule)
|
s->midrule_parent_rhs_index)->used));
|
||||||
{
|
|
||||||
symbol_list *rhs_node =
|
|
||||||
symbol_list_n_get (s->midrule_parent_rule,
|
|
||||||
s->midrule_parent_rhs_index);
|
|
||||||
if (code_props_is_value_used (rhs_node->action_props))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,7 +278,7 @@ grammar_rule_check (const symbol_list *r)
|
|||||||
|
|
||||||
Don't worry about the default action if $$ is untyped, since $$'s
|
Don't worry about the default action if $$ is untyped, since $$'s
|
||||||
value can't be used. */
|
value can't be used. */
|
||||||
if (!code_props_code_get (r->action_props) && r->content.sym->type_name)
|
if (!r->action && r->content.sym->type_name)
|
||||||
{
|
{
|
||||||
symbol *first_rhs = r->next->content.sym;
|
symbol *first_rhs = r->next->content.sym;
|
||||||
/* If $$ is being set in default way, report if any type mismatch. */
|
/* If $$ is being set in default way, report if any type mismatch. */
|
||||||
@@ -311,11 +303,10 @@ grammar_rule_check (const symbol_list *r)
|
|||||||
symbol_list const *l = r;
|
symbol_list const *l = r;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
for (; l && l->content.sym; l = l->next, ++n)
|
for (; l && l->content.sym; l = l->next, ++n)
|
||||||
if (! (code_props_is_value_used (l->action_props)
|
if (! (l->used
|
||||||
|| !symbol_should_be_used (l)
|
|| !symbol_should_be_used (l)
|
||||||
/* The default action, $$ = $1, `uses' both. */
|
/* The default action, $$ = $1, `uses' both. */
|
||||||
|| (!code_props_code_get (r->action_props)
|
|| (!r->action && (n == 0 || n == 1))))
|
||||||
&& (n == 0 || n == 1))))
|
|
||||||
{
|
{
|
||||||
if (n)
|
if (n)
|
||||||
warn_at (r->location, _("unused value: $%d"), n);
|
warn_at (r->location, _("unused value: $%d"), n);
|
||||||
@@ -355,8 +346,7 @@ grammar_midrule_action (void)
|
|||||||
|
|
||||||
/* Make a DUMMY nonterminal, whose location is that of the midrule
|
/* Make a DUMMY nonterminal, whose location is that of the midrule
|
||||||
action. Create the MIDRULE. */
|
action. Create the MIDRULE. */
|
||||||
location dummy_location =
|
location dummy_location = current_rule->action_location;
|
||||||
code_props_location_get (current_rule->action_props);
|
|
||||||
symbol *dummy = dummy_symbol_get (dummy_location);
|
symbol *dummy = dummy_symbol_get (dummy_location);
|
||||||
symbol_list *midrule = symbol_list_sym_new (dummy, dummy_location);
|
symbol_list *midrule = symbol_list_sym_new (dummy, dummy_location);
|
||||||
|
|
||||||
@@ -366,12 +356,12 @@ grammar_midrule_action (void)
|
|||||||
++nritems;
|
++nritems;
|
||||||
/* Attach its location and actions to that of the DUMMY. */
|
/* Attach its location and actions to that of the DUMMY. */
|
||||||
midrule->location = dummy_location;
|
midrule->location = dummy_location;
|
||||||
code_props_rule_action_init (
|
midrule->action = current_rule->action;
|
||||||
&midrule->action_props,
|
midrule->action_location = dummy_location;
|
||||||
code_props_code_get (current_rule->action_props),
|
current_rule->action = NULL;
|
||||||
code_props_location_get (current_rule->action_props),
|
/* The action has not been translated yet, so $$ use hasn't been
|
||||||
midrule);
|
detected yet. */
|
||||||
code_props_none_init (¤t_rule->action_props);
|
midrule->used = false;
|
||||||
|
|
||||||
if (previous_rule_end)
|
if (previous_rule_end)
|
||||||
previous_rule_end->next = midrule;
|
previous_rule_end->next = midrule;
|
||||||
@@ -436,7 +426,7 @@ grammar_current_rule_merge_set (uniqstr name, location loc)
|
|||||||
void
|
void
|
||||||
grammar_current_rule_symbol_append (symbol *sym, location loc)
|
grammar_current_rule_symbol_append (symbol *sym, location loc)
|
||||||
{
|
{
|
||||||
if (code_props_code_get (current_rule->action_props))
|
if (current_rule->action)
|
||||||
grammar_midrule_action ();
|
grammar_midrule_action ();
|
||||||
grammar_symbol_append (sym, loc);
|
grammar_symbol_append (sym, loc);
|
||||||
}
|
}
|
||||||
@@ -446,12 +436,12 @@ grammar_current_rule_symbol_append (symbol *sym, location loc)
|
|||||||
void
|
void
|
||||||
grammar_current_rule_action_append (const char *action, location loc)
|
grammar_current_rule_action_append (const char *action, location loc)
|
||||||
{
|
{
|
||||||
if (code_props_code_get (current_rule->action_props))
|
if (current_rule->action)
|
||||||
grammar_midrule_action ();
|
grammar_midrule_action ();
|
||||||
/* After all symbol declarations have been parsed, packgram invokes
|
/* After all symbol declarations have been parsed, packgram invokes
|
||||||
code_props_translate_code. */
|
translate_rule_action. */
|
||||||
code_props_rule_action_init (¤t_rule->action_props, action, loc,
|
current_rule->action = action;
|
||||||
current_rule);
|
current_rule->action_location = loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -482,7 +472,8 @@ packgram (void)
|
|||||||
`$' from any midrule symbol name. */
|
`$' from any midrule symbol name. */
|
||||||
while (p)
|
while (p)
|
||||||
{
|
{
|
||||||
code_props_translate_code (&p->action_props);
|
if (p->action)
|
||||||
|
p->action = translate_rule_action (p);
|
||||||
if (p)
|
if (p)
|
||||||
p = p->next;
|
p = p->next;
|
||||||
}
|
}
|
||||||
@@ -504,20 +495,16 @@ packgram (void)
|
|||||||
rules[ruleno].precsym = NULL;
|
rules[ruleno].precsym = NULL;
|
||||||
rules[ruleno].location = p->location;
|
rules[ruleno].location = p->location;
|
||||||
rules[ruleno].useful = true;
|
rules[ruleno].useful = true;
|
||||||
rules[ruleno].action = code_props_code_get (p->action_props);
|
rules[ruleno].action = p->action;
|
||||||
if (rules[ruleno].action)
|
rules[ruleno].action_location = p->action_location;
|
||||||
rules[ruleno].action_location =
|
|
||||||
code_props_location_get (p->action_props);
|
|
||||||
|
|
||||||
/* If the midrule's $$ is set or its $n is used, remove the `$' from the
|
/* If the midrule's $$ is set or its $n is used, remove the `$' from the
|
||||||
symbol name so that it's a user-defined symbol so that the default
|
symbol name so that it's a user-defined symbol so that the default
|
||||||
%destructor and %printer apply. */
|
%destructor and %printer apply. */
|
||||||
if (p->midrule_parent_rule
|
if (p->midrule_parent_rule
|
||||||
&& (code_props_is_value_used (p->action_props)
|
&& (p->used
|
||||||
|| code_props_is_value_used (
|
|| symbol_list_n_get (p->midrule_parent_rule,
|
||||||
symbol_list_n_get (
|
p->midrule_parent_rhs_index)->used))
|
||||||
p->midrule_parent_rule,
|
|
||||||
p->midrule_parent_rhs_index)->action_props)))
|
|
||||||
p->content.sym->tag += 1;
|
p->content.sym->tag += 1;
|
||||||
|
|
||||||
/* Don't check the generated rule 0. It has no action, so some rhs
|
/* Don't check the generated rule 0. It has no action, so some rhs
|
||||||
|
|||||||
218
src/scan-code.h
218
src/scan-code.h
@@ -1,4 +1,4 @@
|
|||||||
/* Bison Code Data Structure and Scanner.
|
/* Bison Action Scanner
|
||||||
|
|
||||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||||
|
|
||||||
@@ -24,210 +24,24 @@
|
|||||||
# define SCAN_CODE_H_
|
# define SCAN_CODE_H_
|
||||||
|
|
||||||
# include "location.h"
|
# include "location.h"
|
||||||
|
# include "symlist.h"
|
||||||
|
|
||||||
struct symbol_list;
|
/* Keeps track of the maximum number of semantic values to the left of
|
||||||
|
a handle (those referenced by $0, $-1, etc.) are required by the
|
||||||
/**
|
semantic actions of this grammar. */
|
||||||
* \brief
|
|
||||||
* Keeps track of the maximum number of semantic values to the left of a
|
|
||||||
* handle (those referenced by \c $0, \c $-1, etc.) that are required by the
|
|
||||||
* semantic actions of this grammar.
|
|
||||||
*/
|
|
||||||
extern int max_left_semantic_context;
|
extern int max_left_semantic_context;
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief
|
|
||||||
* A code passage captured from the grammar file and possibly translated,
|
|
||||||
* and/or properties associated with such a code passage.
|
|
||||||
* \note
|
|
||||||
* - Don't break encapsulation by accessing the fields directly. Use the
|
|
||||||
* provided interface functions.
|
|
||||||
*/
|
|
||||||
typedef struct code_props {
|
|
||||||
/**
|
|
||||||
* \brief
|
|
||||||
* What kind of \c code_props this is.
|
|
||||||
* \sa
|
|
||||||
* - \c code_props_none_init
|
|
||||||
* - \c code_props_plain_init
|
|
||||||
* - \c code_props_symbol_action_init
|
|
||||||
* - \c code_props_rule_action_init
|
|
||||||
*/
|
|
||||||
enum {
|
|
||||||
CODE_PROPS_NONE, CODE_PROPS_PLAIN,
|
|
||||||
CODE_PROPS_SYMBOL_ACTION, CODE_PROPS_RULE_ACTION
|
|
||||||
} kind;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief
|
|
||||||
* The code passage contained within this \c code_props.
|
|
||||||
* \invariant
|
|
||||||
* - <tt>code_props::code = NULL</tt> iff
|
|
||||||
* <tt>code_props::kind = CODE_PROPS_NONE</tt>.
|
|
||||||
*/
|
|
||||||
char const *code;
|
|
||||||
/**
|
|
||||||
* \brief
|
|
||||||
* The grammar file location of \c code_props::code.
|
|
||||||
* \invariant
|
|
||||||
* - \c code_props::location is undefined iff
|
|
||||||
* <tt>code_props::code = NULL</tt>.
|
|
||||||
*/
|
|
||||||
location location;
|
|
||||||
/**
|
|
||||||
* \brief
|
|
||||||
* The value returned by \c code_props_is_value_used for this
|
|
||||||
* \c code_props.
|
|
||||||
*/
|
|
||||||
bool is_value_used;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief
|
|
||||||
* The \c symbol_list node associated with this code passage.
|
|
||||||
* \invariant
|
|
||||||
* - <tt>code_props::rule != NULL</tt> iff \c code_props::kind is
|
|
||||||
* \c CODE_PROPS_RULE_ACTION.
|
|
||||||
*/
|
|
||||||
struct symbol_list *rule;
|
|
||||||
} code_props;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \pre
|
|
||||||
* - <tt>self != NULL</tt>.
|
|
||||||
* \post
|
|
||||||
* - \c self has been overwritten to contain no code. (However, \c self may
|
|
||||||
* still be conceptually associated with some passage of code contained
|
|
||||||
* elsewhere. Thus, a call on <tt>code_props_is_value_used (*self)</tt>,
|
|
||||||
* for example, is still reasonable.)
|
|
||||||
*/
|
|
||||||
void code_props_none_init (code_props *self);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief A \c code_props initializer equivalent to \c code_props_none_init.
|
|
||||||
*/
|
|
||||||
#define CODE_PROPS_NONE_INIT \
|
|
||||||
{CODE_PROPS_NONE, NULL, EMPTY_LOCATION_INIT, false, NULL}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief
|
|
||||||
* A \c code_props initialized by \c CODE_PROPS_NONE_INIT with no further
|
|
||||||
* modification.
|
|
||||||
*/
|
|
||||||
extern code_props const code_props_none;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \pre
|
|
||||||
* - <tt>self != NULL</tt>.
|
|
||||||
* - <tt>code != NULL</tt>.
|
|
||||||
* - \c code is an untranslated code passage containing no Bison escapes.
|
|
||||||
* - \c code was extracted from the grammar file at \c code_loc.
|
|
||||||
* \post
|
|
||||||
* - \c self has been overwritten to represent the specified plain code
|
|
||||||
* passage.
|
|
||||||
* - \c self does not claim responsibility for the memory of \c code.
|
|
||||||
*/
|
|
||||||
void code_props_plain_init (code_props *self, char const *code,
|
|
||||||
location code_loc);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \pre
|
|
||||||
* - <tt>self != NULL</tt>.
|
|
||||||
* - <tt>code != NULL</tt>.
|
|
||||||
* - \c code is an untranslated code passage. The only Bison escapes it
|
|
||||||
* might contain are \c $$ and \c \@$, referring to a single symbol.
|
|
||||||
* - \c code was extracted from the grammar file at \c code_loc.
|
|
||||||
* \post
|
|
||||||
* - \c self has been overwritten to represent the specified symbol action.
|
|
||||||
* - \c self does not claim responsibility for the memory of \c code.
|
|
||||||
*/
|
|
||||||
void code_props_symbol_action_init (code_props *self, char const *code,
|
|
||||||
location code_loc);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \pre
|
|
||||||
* - <tt>self != NULL</tt>.
|
|
||||||
* - <tt>code != NULL</tt>.
|
|
||||||
* - <tt>rule != NULL</tt>.
|
|
||||||
* - \c code is the untranslated action of the rule for which \c rule is the
|
|
||||||
* LHS node. Thus, \c code possibly contains Bison escapes such as \c $$,
|
|
||||||
* \c $1, \c $2, etc referring to the values of the rule.
|
|
||||||
* \post
|
|
||||||
* - \c self has been overwritten to represent the specified rule action.
|
|
||||||
* - \c self does not claim responsibility for the memory of \c code or
|
|
||||||
* \c rule.
|
|
||||||
*/
|
|
||||||
void code_props_rule_action_init (code_props *self, char const *code,
|
|
||||||
location code_loc, struct symbol_list *rule);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \pre
|
|
||||||
* - If there's a code passage contained in \c self and it contains Bison
|
|
||||||
* escapes, all grammar declarations have already been parsed as they may
|
|
||||||
* affect warnings and complaints issued here.
|
|
||||||
* \post
|
|
||||||
* - All M4 special symbols and Bison escapes have been translated in
|
|
||||||
* <tt>code_props_code_get (*self)</tt> iff
|
|
||||||
* <tt>code_props_code_get (*self \@pre) != NULL</tt>.
|
|
||||||
*/
|
|
||||||
void code_props_translate_code (code_props *self);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \pre
|
|
||||||
* - None.
|
|
||||||
* \post
|
|
||||||
* - \c result = either:
|
|
||||||
* - The code passage contained with \c self.
|
|
||||||
* - \c NULL if none.
|
|
||||||
*/
|
|
||||||
char const *code_props_code_get (code_props const self);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \pre
|
|
||||||
* - <tt>code_props_code_get (self) != NULL</tt>.
|
|
||||||
* \post
|
|
||||||
* - \c result = the grammar file location of
|
|
||||||
* <tt>code_props_code_get (self)</tt>.
|
|
||||||
*/
|
|
||||||
location code_props_location_get (code_props const self);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \pre
|
|
||||||
* - \c self was not previously initialized with \c code_props_plain_init.
|
|
||||||
* \post
|
|
||||||
* - \c result = either:
|
|
||||||
* - \c false if either:
|
|
||||||
* - \c code_props_translate_code has never previously been invoked for
|
|
||||||
* the \c code_props that would contain the code passage associated
|
|
||||||
* with \c self. (If \c self is for a RHS \c symbol_list node, that
|
|
||||||
* \c code_props is not \c self. Instead, it's the \c code_props for
|
|
||||||
* the LHS symbol of the same rule.)
|
|
||||||
* - \c code_props_translate_code has been invoked for that
|
|
||||||
* \c code_props, but the symbol value associated with \c self was not
|
|
||||||
* referenced in the code passage.
|
|
||||||
* - \c true otherwise.
|
|
||||||
*/
|
|
||||||
bool code_props_is_value_used (code_props const self);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \pre
|
|
||||||
* - None.
|
|
||||||
* \post
|
|
||||||
* - The dynamic memory allocated by the previous invocation of
|
|
||||||
* \c code_props_translate_code (if any) was freed. The \c code_props
|
|
||||||
* instance for which that \c code_props_translate_code was invoked is now
|
|
||||||
* invalid.
|
|
||||||
*/
|
|
||||||
void code_scanner_last_string_free (void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \pre
|
|
||||||
* - None.
|
|
||||||
* \post
|
|
||||||
* - All dynamic memory allocated during invocations of
|
|
||||||
* \c code_props_translate_code (if any) has been freed. All
|
|
||||||
* \c code_props instances and all pointers returned by
|
|
||||||
* \c code_props_code_get may now be invalid.
|
|
||||||
*/
|
|
||||||
void code_scanner_free (void);
|
void code_scanner_free (void);
|
||||||
|
|
||||||
|
/* The action of the rule R contains $$, $1 etc. referring to the values
|
||||||
|
of the rule R. */
|
||||||
|
char const *translate_rule_action (symbol_list *r);
|
||||||
|
|
||||||
|
/* The action A refers to $$ and @$ only, referring to a symbol. */
|
||||||
|
char const *translate_symbol_action (char const *a, location l);
|
||||||
|
|
||||||
|
/* The action contains no special escapes, just protect M4 special
|
||||||
|
symbols. */
|
||||||
|
char const *translate_code (char const *a, location l);
|
||||||
|
|
||||||
#endif /* !SCAN_CODE_H_ */
|
#endif /* !SCAN_CODE_H_ */
|
||||||
|
|||||||
132
src/scan-code.l
132
src/scan-code.l
@@ -39,11 +39,10 @@
|
|||||||
#include <quote.h>
|
#include <quote.h>
|
||||||
|
|
||||||
#include "scan-code.h"
|
#include "scan-code.h"
|
||||||
#include "symlist.h"
|
|
||||||
|
|
||||||
/* The current calling start condition: SC_RULE_ACTION or
|
/* The current calling start condition: SC_RULE_ACTION or
|
||||||
SC_SYMBOL_ACTION. */
|
SC_SYMBOL_ACTION. */
|
||||||
# define YY_DECL static char *code_lex (code_props *self, int sc_context)
|
# define YY_DECL char *code_lex (int sc_context, symbol_list *rule)
|
||||||
YY_DECL;
|
YY_DECL;
|
||||||
|
|
||||||
#define YY_USER_ACTION location_compute (loc, &loc->end, yytext, yyleng);
|
#define YY_USER_ACTION location_compute (loc, &loc->end, yytext, yyleng);
|
||||||
@@ -54,9 +53,6 @@ static void handle_action_at (symbol_list *rule, char *cp, location at_loc);
|
|||||||
static location the_location;
|
static location the_location;
|
||||||
static location *loc = &the_location;
|
static location *loc = &the_location;
|
||||||
|
|
||||||
/* A string representing the most recent translation. */
|
|
||||||
static char *last_string;
|
|
||||||
|
|
||||||
/* True if an untyped $$ or $n was seen. */
|
/* True if an untyped $$ or $n was seen. */
|
||||||
static bool untyped_var_seen;
|
static bool untyped_var_seen;
|
||||||
%}
|
%}
|
||||||
@@ -155,12 +151,8 @@ splice (\\[ \f\t\v]*\n)*
|
|||||||
|
|
||||||
<SC_RULE_ACTION>
|
<SC_RULE_ACTION>
|
||||||
{
|
{
|
||||||
"$"("<"{tag}">")?(-?[0-9]+|"$") {
|
"$"("<"{tag}">")?(-?[0-9]+|"$") handle_action_dollar (rule, yytext, *loc);
|
||||||
handle_action_dollar (self->rule, yytext, *loc);
|
"@"(-?[0-9]+|"$") handle_action_at (rule, yytext, *loc);
|
||||||
}
|
|
||||||
"@"(-?[0-9]+|"$") {
|
|
||||||
handle_action_at (self->rule, yytext, *loc);
|
|
||||||
}
|
|
||||||
|
|
||||||
"$" {
|
"$" {
|
||||||
warn_at (*loc, _("stray `$'"));
|
warn_at (*loc, _("stray `$'"));
|
||||||
@@ -198,10 +190,7 @@ splice (\\[ \f\t\v]*\n)*
|
|||||||
|
|
||||||
<SC_SYMBOL_ACTION>
|
<SC_SYMBOL_ACTION>
|
||||||
{
|
{
|
||||||
"$$" {
|
"$$" obstack_sgrow (&obstack_for_string, "]b4_dollar_dollar[");
|
||||||
obstack_sgrow (&obstack_for_string, "]b4_dollar_dollar[");
|
|
||||||
self->is_value_used = true;
|
|
||||||
}
|
|
||||||
"@$" obstack_sgrow (&obstack_for_string, "]b4_at_dollar[");
|
"@$" obstack_sgrow (&obstack_for_string, "]b4_at_dollar[");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,8 +215,8 @@ splice (\\[ \f\t\v]*\n)*
|
|||||||
|
|
||||||
/* End of processing. */
|
/* End of processing. */
|
||||||
<*><<EOF>> {
|
<*><<EOF>> {
|
||||||
STRING_FINISH;
|
obstack_1grow (&obstack_for_string, '\0');
|
||||||
return last_string;
|
return obstack_finish (&obstack_for_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
%%
|
%%
|
||||||
@@ -249,7 +238,7 @@ int max_left_semantic_context = 0;
|
|||||||
static void
|
static void
|
||||||
handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
|
handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
|
||||||
{
|
{
|
||||||
char const *type_name = NULL;
|
const char *type_name = NULL;
|
||||||
char *cp = text + 1;
|
char *cp = text + 1;
|
||||||
symbol_list *effective_rule;
|
symbol_list *effective_rule;
|
||||||
int effective_rule_length;
|
int effective_rule_length;
|
||||||
@@ -304,7 +293,7 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
|
|||||||
|
|
||||||
obstack_fgrow1 (&obstack_for_string,
|
obstack_fgrow1 (&obstack_for_string,
|
||||||
"]b4_lhs_value([%s])[", type_name);
|
"]b4_lhs_value([%s])[", type_name);
|
||||||
rule->action_props.is_value_used = true;
|
rule->used = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -332,9 +321,7 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
|
|||||||
obstack_fgrow3 (&obstack_for_string,
|
obstack_fgrow3 (&obstack_for_string,
|
||||||
"]b4_rhs_value(%d, %d, [%s])[",
|
"]b4_rhs_value(%d, %d, [%s])[",
|
||||||
effective_rule_length, n, type_name);
|
effective_rule_length, n, type_name);
|
||||||
if (n > 0)
|
symbol_list_n_used_set (effective_rule, n, true);
|
||||||
symbol_list_n_get (effective_rule, n)->action_props.is_value_used =
|
|
||||||
true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
complain_at (dollar_loc, _("integer out of range: %s"), quote (text));
|
complain_at (dollar_loc, _("integer out of range: %s"), quote (text));
|
||||||
@@ -381,11 +368,12 @@ handle_action_at (symbol_list *rule, char *text, location at_loc)
|
|||||||
| Initialize the scanner. |
|
| Initialize the scanner. |
|
||||||
`-------------------------*/
|
`-------------------------*/
|
||||||
|
|
||||||
/* Translate the dollars and ats in \a self, in the context \a sc_context
|
/* Translate the dollars and ats in \a a, whose location is \a l. The
|
||||||
|
translation is for \a rule, in the context \a sc_context
|
||||||
(SC_RULE_ACTION, SC_SYMBOL_ACTION, INITIAL). */
|
(SC_RULE_ACTION, SC_SYMBOL_ACTION, INITIAL). */
|
||||||
|
|
||||||
static char const *
|
static char const *
|
||||||
translate_action (code_props *self, int sc_context)
|
translate_action (int sc_context, symbol_list *rule, char const *a, location l)
|
||||||
{
|
{
|
||||||
char *res;
|
char *res;
|
||||||
static bool initialized = false;
|
static bool initialized = false;
|
||||||
@@ -396,102 +384,36 @@ translate_action (code_props *self, int sc_context)
|
|||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
loc->start = loc->end = self->location.start;
|
loc->start = loc->end = l.start;
|
||||||
yy_switch_to_buffer (yy_scan_string (self->code));
|
yy_switch_to_buffer (yy_scan_string (a));
|
||||||
res = code_lex (self, sc_context);
|
res = code_lex (sc_context, rule);
|
||||||
yy_delete_buffer (YY_CURRENT_BUFFER);
|
yy_delete_buffer (YY_CURRENT_BUFFER);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------------.
|
char const *
|
||||||
| Implementation of the public interface as documented in "scan-code.h". |
|
translate_rule_action (symbol_list *rule)
|
||||||
`------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
void
|
|
||||||
code_props_none_init (code_props *self)
|
|
||||||
{
|
{
|
||||||
*self = code_props_none;
|
return translate_action (SC_RULE_ACTION, rule, rule->action,
|
||||||
}
|
rule->action_location);
|
||||||
|
|
||||||
code_props const code_props_none = CODE_PROPS_NONE_INIT;
|
|
||||||
|
|
||||||
void
|
|
||||||
code_props_plain_init (code_props *self, char const *code, location code_loc)
|
|
||||||
{
|
|
||||||
self->kind = CODE_PROPS_PLAIN;
|
|
||||||
self->code = code;
|
|
||||||
self->location = code_loc;
|
|
||||||
self->is_value_used = false;
|
|
||||||
self->rule = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
code_props_symbol_action_init (code_props *self, char const *code,
|
|
||||||
location code_loc)
|
|
||||||
{
|
|
||||||
self->kind = CODE_PROPS_SYMBOL_ACTION;
|
|
||||||
self->code = code;
|
|
||||||
self->location = code_loc;
|
|
||||||
self->is_value_used = false;
|
|
||||||
self->rule = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
code_props_rule_action_init (code_props *self, char const *code,
|
|
||||||
location code_loc, symbol_list *rule)
|
|
||||||
{
|
|
||||||
self->kind = CODE_PROPS_RULE_ACTION;
|
|
||||||
self->code = code;
|
|
||||||
self->location = code_loc;
|
|
||||||
self->is_value_used = false;
|
|
||||||
self->rule = rule;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
code_props_translate_code (code_props *self)
|
|
||||||
{
|
|
||||||
switch (self->kind)
|
|
||||||
{
|
|
||||||
case CODE_PROPS_NONE:
|
|
||||||
break;
|
|
||||||
case CODE_PROPS_PLAIN:
|
|
||||||
self->code = translate_action (self, INITIAL);
|
|
||||||
break;
|
|
||||||
case CODE_PROPS_SYMBOL_ACTION:
|
|
||||||
self->code = translate_action (self, SC_SYMBOL_ACTION);
|
|
||||||
break;
|
|
||||||
case CODE_PROPS_RULE_ACTION:
|
|
||||||
self->code = translate_action (self, SC_RULE_ACTION);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char const *
|
char const *
|
||||||
code_props_code_get (code_props const self)
|
translate_symbol_action (char const *a, location l)
|
||||||
{
|
{
|
||||||
return self.code;
|
return translate_action (SC_SYMBOL_ACTION, NULL, a, l);
|
||||||
}
|
}
|
||||||
|
|
||||||
location
|
char const *
|
||||||
code_props_location_get (code_props const self)
|
translate_code (char const *a, location l)
|
||||||
{
|
{
|
||||||
aver (self.code != NULL);
|
return translate_action (INITIAL, NULL, a, l);
|
||||||
return self.location;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
/*-----------------------------------------------.
|
||||||
code_props_is_value_used (code_props const self)
|
| Free all the memory allocated to the scanner. |
|
||||||
{
|
`-----------------------------------------------*/
|
||||||
aver (self.kind != CODE_PROPS_PLAIN);
|
|
||||||
return self.is_value_used;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
code_scanner_last_string_free (void)
|
|
||||||
{
|
|
||||||
STRING_FREE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
code_scanner_free (void)
|
code_scanner_free (void)
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
/* From the scanner. */
|
/* From the scanner. */
|
||||||
extern FILE *gram_in;
|
extern FILE *gram_in;
|
||||||
extern int gram__flex_debug;
|
extern int gram__flex_debug;
|
||||||
|
extern char *gram_last_string;
|
||||||
void gram_scanner_initialize (void);
|
void gram_scanner_initialize (void);
|
||||||
void gram_scanner_free (void);
|
void gram_scanner_free (void);
|
||||||
void gram_scanner_last_string_free (void);
|
void gram_scanner_last_string_free (void);
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ static size_t no_cr_read (FILE *, char *, size_t);
|
|||||||
#define YY_INPUT(buf, result, size) ((result) = no_cr_read (yyin, buf, size))
|
#define YY_INPUT(buf, result, size) ((result) = no_cr_read (yyin, buf, size))
|
||||||
|
|
||||||
/* A string representing the most recently saved token. */
|
/* A string representing the most recently saved token. */
|
||||||
static char *last_string;
|
char *last_string;
|
||||||
|
|
||||||
void
|
void
|
||||||
gram_scanner_last_string_free (void)
|
gram_scanner_last_string_free (void)
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
#include "complain.h"
|
#include "complain.h"
|
||||||
#include "scan-code.h"
|
|
||||||
#include "symlist.h"
|
#include "symlist.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -44,7 +43,8 @@ symbol_list_sym_new (symbol *sym, location loc)
|
|||||||
res->midrule_parent_rule = NULL;
|
res->midrule_parent_rule = NULL;
|
||||||
res->midrule_parent_rhs_index = 0;
|
res->midrule_parent_rhs_index = 0;
|
||||||
|
|
||||||
code_props_none_init (&res->action_props);
|
res->action = NULL;
|
||||||
|
res->used = false;
|
||||||
|
|
||||||
res->ruleprec = NULL;
|
res->ruleprec = NULL;
|
||||||
res->dprec = 0;
|
res->dprec = 0;
|
||||||
@@ -118,9 +118,7 @@ symbol_list_syms_print (const symbol_list *l, FILE *f)
|
|||||||
for (/* Nothing. */; l && l->content.sym; l = l->next)
|
for (/* Nothing. */; l && l->content.sym; l = l->next)
|
||||||
{
|
{
|
||||||
symbol_print (l->content.sym, f);
|
symbol_print (l->content.sym, f);
|
||||||
fprintf (stderr,
|
fprintf (stderr, l->used ? " used" : " unused");
|
||||||
code_props_is_value_used (l->action_props)
|
|
||||||
? " used" : " unused");
|
|
||||||
if (l && l->content.sym)
|
if (l && l->content.sym)
|
||||||
fprintf (f, ", ");
|
fprintf (f, ", ");
|
||||||
}
|
}
|
||||||
@@ -209,50 +207,57 @@ symbol_list_n_type_name_get (symbol_list *l, location loc, int n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*--------------------------------------.
|
||||||
|
| The item N in symbol list L is USED. |
|
||||||
|
`--------------------------------------*/
|
||||||
|
|
||||||
void
|
void
|
||||||
symbol_list_destructor_set (symbol_list *node, const char *code, location loc)
|
symbol_list_n_used_set (symbol_list *l, int n, bool used)
|
||||||
|
{
|
||||||
|
l = symbol_list_n_get (l, n);
|
||||||
|
if (l)
|
||||||
|
l->used = used;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
symbol_list_destructor_set (symbol_list *node, const char *destructor,
|
||||||
|
location loc)
|
||||||
{
|
{
|
||||||
code_props destructor;
|
|
||||||
code_props_symbol_action_init (&destructor, code, loc);
|
|
||||||
code_props_translate_code (&destructor);
|
|
||||||
switch (node->content_type)
|
switch (node->content_type)
|
||||||
{
|
{
|
||||||
case SYMLIST_SYMBOL:
|
case SYMLIST_SYMBOL:
|
||||||
symbol_destructor_set (node->content.sym, destructor);
|
symbol_destructor_set (node->content.sym, destructor, loc);
|
||||||
break;
|
break;
|
||||||
case SYMLIST_TYPE:
|
case SYMLIST_TYPE:
|
||||||
semantic_type_destructor_set (
|
semantic_type_destructor_set (
|
||||||
semantic_type_get (node->content.type_name), destructor);
|
semantic_type_get (node->content.type_name), destructor, loc);
|
||||||
break;
|
break;
|
||||||
case SYMLIST_DEFAULT_TAGGED:
|
case SYMLIST_DEFAULT_TAGGED:
|
||||||
default_tagged_destructor_set (destructor);
|
default_tagged_destructor_set (destructor, loc);
|
||||||
break;
|
break;
|
||||||
case SYMLIST_DEFAULT_TAGLESS:
|
case SYMLIST_DEFAULT_TAGLESS:
|
||||||
default_tagless_destructor_set (destructor);
|
default_tagless_destructor_set (destructor, loc);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
symbol_list_printer_set (symbol_list *node, const char *code, location loc)
|
symbol_list_printer_set (symbol_list *node, const char *printer, location loc)
|
||||||
{
|
{
|
||||||
code_props printer;
|
|
||||||
code_props_symbol_action_init (&printer, code, loc);
|
|
||||||
code_props_translate_code (&printer);
|
|
||||||
switch (node->content_type)
|
switch (node->content_type)
|
||||||
{
|
{
|
||||||
case SYMLIST_SYMBOL:
|
case SYMLIST_SYMBOL:
|
||||||
symbol_printer_set (node->content.sym, printer);
|
symbol_printer_set (node->content.sym, printer, loc);
|
||||||
break;
|
break;
|
||||||
case SYMLIST_TYPE:
|
case SYMLIST_TYPE:
|
||||||
semantic_type_printer_set (
|
semantic_type_printer_set (
|
||||||
semantic_type_get (node->content.type_name), printer);
|
semantic_type_get (node->content.type_name), printer, loc);
|
||||||
break;
|
break;
|
||||||
case SYMLIST_DEFAULT_TAGGED:
|
case SYMLIST_DEFAULT_TAGGED:
|
||||||
default_tagged_printer_set (printer);
|
default_tagged_printer_set (printer, loc);
|
||||||
break;
|
break;
|
||||||
case SYMLIST_DEFAULT_TAGLESS:
|
case SYMLIST_DEFAULT_TAGLESS:
|
||||||
default_tagless_printer_set (printer);
|
default_tagless_printer_set (printer, loc);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
#ifndef SYMLIST_H_
|
#ifndef SYMLIST_H_
|
||||||
# define SYMLIST_H_
|
# define SYMLIST_H_
|
||||||
|
|
||||||
# include "scan-code.h"
|
|
||||||
# include "location.h"
|
# include "location.h"
|
||||||
# include "symtab.h"
|
# include "symtab.h"
|
||||||
|
|
||||||
@@ -38,14 +37,9 @@ typedef struct symbol_list
|
|||||||
SYMLIST_DEFAULT_TAGGED, SYMLIST_DEFAULT_TAGLESS
|
SYMLIST_DEFAULT_TAGGED, SYMLIST_DEFAULT_TAGLESS
|
||||||
} content_type;
|
} content_type;
|
||||||
union {
|
union {
|
||||||
/**
|
/** The symbol or \c NULL iff <tt>node_type = SYMLIST_SYMBOL</tt>. */
|
||||||
* The symbol or \c NULL iff
|
|
||||||
* <tt>symbol_list::content_type = SYMLIST_SYMBOL</tt>.
|
|
||||||
*/
|
|
||||||
symbol *sym;
|
symbol *sym;
|
||||||
/**
|
/** The semantic type iff <tt>node_type = SYMLIST_TYPE</tt>. */
|
||||||
* The semantic type iff <tt>symbol_list::content_type = SYMLIST_TYPE</tt>.
|
|
||||||
*/
|
|
||||||
uniqstr type_name;
|
uniqstr type_name;
|
||||||
} content;
|
} content;
|
||||||
location location;
|
location location;
|
||||||
@@ -61,9 +55,12 @@ typedef struct symbol_list
|
|||||||
struct symbol_list *midrule_parent_rule;
|
struct symbol_list *midrule_parent_rule;
|
||||||
int midrule_parent_rhs_index;
|
int midrule_parent_rhs_index;
|
||||||
|
|
||||||
/* The action is attached to the LHS of a rule, but action properties for
|
/* The action is attached to the LHS of a rule. */
|
||||||
* each RHS are also stored here. */
|
const char *action;
|
||||||
code_props action_props;
|
location action_location;
|
||||||
|
|
||||||
|
/* Whether this symbol's value is used in the current action. */
|
||||||
|
bool used;
|
||||||
|
|
||||||
/* Precedence/associativity. */
|
/* Precedence/associativity. */
|
||||||
symbol *ruleprec;
|
symbol *ruleprec;
|
||||||
@@ -109,12 +106,15 @@ symbol_list *symbol_list_n_get (symbol_list *l, int n);
|
|||||||
symbol N in rule RULE. */
|
symbol N in rule RULE. */
|
||||||
uniqstr symbol_list_n_type_name_get (symbol_list *l, location loc, int n);
|
uniqstr symbol_list_n_type_name_get (symbol_list *l, location loc, int n);
|
||||||
|
|
||||||
|
/** The item \c n in symbol list \c l is \c used. */
|
||||||
|
void symbol_list_n_used_set (symbol_list *l, int n, bool used);
|
||||||
|
|
||||||
/** Set the \c \%destructor for \c node as \c destructor at \c loc. */
|
/** Set the \c \%destructor for \c node as \c destructor at \c loc. */
|
||||||
void symbol_list_destructor_set (symbol_list *node, const char *code,
|
void symbol_list_destructor_set (symbol_list *node, const char *destructor,
|
||||||
location loc);
|
location loc);
|
||||||
|
|
||||||
/** Set the \c \%printer for \c node as \c printer at \c loc. */
|
/** Set the \c \%printer for \c node as \c printer at \c loc. */
|
||||||
void symbol_list_printer_set (symbol_list *node, const char *code,
|
void symbol_list_printer_set (symbol_list *node, const char *printer,
|
||||||
location loc);
|
location loc);
|
||||||
|
|
||||||
#endif /* !SYMLIST_H_ */
|
#endif /* !SYMLIST_H_ */
|
||||||
|
|||||||
241
src/symtab.c
241
src/symtab.c
@@ -45,10 +45,15 @@ location startsymbol_location;
|
|||||||
| Default %destructor's and %printer's. |
|
| Default %destructor's and %printer's. |
|
||||||
`---------------------------------------*/
|
`---------------------------------------*/
|
||||||
|
|
||||||
static code_props default_tagged_destructor = CODE_PROPS_NONE_INIT;
|
static const char *default_tagged_destructor = NULL;
|
||||||
static code_props default_tagless_destructor = CODE_PROPS_NONE_INIT;
|
static location default_tagged_destructor_location;
|
||||||
static code_props default_tagged_printer = CODE_PROPS_NONE_INIT;
|
static const char *default_tagless_destructor = NULL;
|
||||||
static code_props default_tagless_printer = CODE_PROPS_NONE_INIT;
|
static location default_tagless_destructor_location;
|
||||||
|
|
||||||
|
static const char *default_tagged_printer = NULL;
|
||||||
|
static location default_tagged_printer_location;
|
||||||
|
static const char *default_tagless_printer = NULL;
|
||||||
|
static location default_tagless_printer_location;
|
||||||
|
|
||||||
/*---------------------------------.
|
/*---------------------------------.
|
||||||
| Create a new symbol, named TAG. |
|
| Create a new symbol, named TAG. |
|
||||||
@@ -64,8 +69,8 @@ symbol_new (uniqstr tag, location loc)
|
|||||||
res->location = loc;
|
res->location = loc;
|
||||||
|
|
||||||
res->type_name = NULL;
|
res->type_name = NULL;
|
||||||
code_props_none_init (&res->destructor);
|
res->destructor = NULL;
|
||||||
code_props_none_init (&res->printer);
|
res->printer = NULL;
|
||||||
|
|
||||||
res->number = NUMBER_UNDEFINED;
|
res->number = NUMBER_UNDEFINED;
|
||||||
res->prec = 0;
|
res->prec = 0;
|
||||||
@@ -94,8 +99,8 @@ semantic_type_new (uniqstr tag)
|
|||||||
|
|
||||||
uniqstr_assert (tag);
|
uniqstr_assert (tag);
|
||||||
res->tag = tag;
|
res->tag = tag;
|
||||||
code_props_none_init (&res->destructor);
|
res->destructor = NULL;
|
||||||
code_props_none_init (&res->printer);
|
res->printer = NULL;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -109,10 +114,6 @@ semantic_type_new (uniqstr tag)
|
|||||||
if (s->Attr) \
|
if (s->Attr) \
|
||||||
fprintf (f, " %s { %s }", #Attr, s->Attr)
|
fprintf (f, " %s { %s }", #Attr, s->Attr)
|
||||||
|
|
||||||
#define SYMBOL_CODE_PRINT(Attr) \
|
|
||||||
if (code_props_code_get (s->Attr)) \
|
|
||||||
fprintf (f, " %s { %s }", #Attr, code_props_code_get(s->Attr))
|
|
||||||
|
|
||||||
void
|
void
|
||||||
symbol_print (symbol *s, FILE *f)
|
symbol_print (symbol *s, FILE *f)
|
||||||
{
|
{
|
||||||
@@ -120,15 +121,14 @@ symbol_print (symbol *s, FILE *f)
|
|||||||
{
|
{
|
||||||
fprintf (f, "\"%s\"", s->tag);
|
fprintf (f, "\"%s\"", s->tag);
|
||||||
SYMBOL_ATTR_PRINT (type_name);
|
SYMBOL_ATTR_PRINT (type_name);
|
||||||
SYMBOL_CODE_PRINT (destructor);
|
SYMBOL_ATTR_PRINT (destructor);
|
||||||
SYMBOL_CODE_PRINT (printer);
|
SYMBOL_ATTR_PRINT (printer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fprintf (f, "<NULL>");
|
fprintf (f, "<NULL>");
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef SYMBOL_ATTR_PRINT
|
#undef SYMBOL_ATTR_PRINT
|
||||||
#undef SYMBOL_CODE_PRINT
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------.
|
/*------------------------------------------------------------------.
|
||||||
| Complain that S's WHAT is redeclared at SECOND, and was first set |
|
| Complain that S's WHAT is redeclared at SECOND, and was first set |
|
||||||
@@ -171,118 +171,170 @@ symbol_type_set (symbol *sym, uniqstr type_name, location loc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------.
|
/*------------------------------------------------------------------.
|
||||||
| Set the DESTRUCTOR associated with SYM. |
|
| Set the DESTRUCTOR associated with SYM. Do nothing if passed 0. |
|
||||||
`-----------------------------------------*/
|
`------------------------------------------------------------------*/
|
||||||
|
|
||||||
void
|
void
|
||||||
symbol_destructor_set (symbol *sym, code_props destructor)
|
symbol_destructor_set (symbol *sym, const char *destructor, location loc)
|
||||||
{
|
{
|
||||||
if (code_props_code_get (sym->destructor))
|
if (destructor)
|
||||||
symbol_redeclaration (sym, "%destructor",
|
{
|
||||||
code_props_location_get (sym->destructor),
|
if (sym->destructor)
|
||||||
code_props_location_get (destructor));
|
symbol_redeclaration (sym, "%destructor", sym->destructor_location,
|
||||||
sym->destructor = destructor;
|
loc);
|
||||||
|
sym->destructor = destructor;
|
||||||
|
sym->destructor_location = loc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------.
|
/*-------------------------------------------------------------------.
|
||||||
| Set the DESTRUCTOR associated with TYPE. |
|
| Set the DESTRUCTOR associated with TYPE. Do nothing if passed 0. |
|
||||||
`------------------------------------------*/
|
`-------------------------------------------------------------------*/
|
||||||
|
|
||||||
void
|
void
|
||||||
semantic_type_destructor_set (semantic_type *type, code_props destructor)
|
semantic_type_destructor_set (semantic_type *type, const char *destructor,
|
||||||
|
location loc)
|
||||||
{
|
{
|
||||||
if (code_props_code_get (type->destructor))
|
if (destructor)
|
||||||
semantic_type_redeclaration (type, "%destructor",
|
{
|
||||||
code_props_location_get (type->destructor),
|
if (type->destructor)
|
||||||
code_props_location_get (destructor));
|
semantic_type_redeclaration (type, "%destructor",
|
||||||
type->destructor = destructor;
|
type->destructor_location, loc);
|
||||||
|
type->destructor = destructor;
|
||||||
|
type->destructor_location = loc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------.
|
/*---------------------------------------.
|
||||||
| Get the computed %destructor for SYM. |
|
| Get the computed %destructor for SYM. |
|
||||||
`---------------------------------------*/
|
`---------------------------------------*/
|
||||||
|
|
||||||
code_props
|
const char *
|
||||||
symbol_destructor_get (symbol *sym)
|
symbol_destructor_get (symbol *sym)
|
||||||
{
|
{
|
||||||
/* Per-symbol %destructor. */
|
/* Per-symbol %destructor. */
|
||||||
if (code_props_code_get (sym->destructor))
|
if (sym->destructor != NULL)
|
||||||
return sym->destructor;
|
return sym->destructor;
|
||||||
|
|
||||||
/* Per-type %destructor. */
|
/* Per-type %destructor. */
|
||||||
if (sym->type_name)
|
if (sym->type_name)
|
||||||
{
|
{
|
||||||
code_props destructor = semantic_type_get (sym->type_name)->destructor;
|
semantic_type *type = semantic_type_get (sym->type_name);
|
||||||
if (code_props_code_get (destructor))
|
if (type->destructor)
|
||||||
return destructor;
|
return type->destructor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Apply default %destructor's only to user-defined symbols. */
|
/* Apply default %destructor's only to user-defined symbols. */
|
||||||
if (sym->tag[0] == '$' || sym == errtoken)
|
if (sym->tag[0] == '$' || sym == errtoken)
|
||||||
return code_props_none;
|
return NULL;
|
||||||
|
|
||||||
if (sym->type_name)
|
if (sym->type_name)
|
||||||
return default_tagged_destructor;
|
return default_tagged_destructor;
|
||||||
return default_tagless_destructor;
|
return default_tagless_destructor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------.
|
/*---------------------------------------------------------------.
|
||||||
| Set the PRINTER associated with SYM. |
|
| Get the grammar location of the %destructor computed for SYM. |
|
||||||
`--------------------------------------*/
|
`---------------------------------------------------------------*/
|
||||||
|
|
||||||
void
|
location
|
||||||
symbol_printer_set (symbol *sym, code_props printer)
|
symbol_destructor_location_get (symbol *sym)
|
||||||
{
|
{
|
||||||
if (code_props_code_get (sym->printer))
|
if (sym->destructor != NULL)
|
||||||
symbol_redeclaration (sym, "%printer",
|
return sym->destructor_location;
|
||||||
code_props_location_get (sym->printer),
|
if (sym->type_name)
|
||||||
code_props_location_get (printer));
|
{
|
||||||
sym->printer = printer;
|
semantic_type *type = semantic_type_get (sym->type_name);
|
||||||
|
if (type->destructor)
|
||||||
|
return type->destructor_location;
|
||||||
|
return default_tagged_destructor_location;
|
||||||
|
}
|
||||||
|
return default_tagless_destructor_location;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------.
|
/*---------------------------------------------------------------.
|
||||||
| Set the PRINTER associated with TYPE. |
|
| Set the PRINTER associated with SYM. Do nothing if passed 0. |
|
||||||
`---------------------------------------*/
|
`---------------------------------------------------------------*/
|
||||||
|
|
||||||
void
|
void
|
||||||
semantic_type_printer_set (semantic_type *type, code_props printer)
|
symbol_printer_set (symbol *sym, const char *printer, location loc)
|
||||||
{
|
{
|
||||||
if (code_props_code_get (type->printer))
|
if (printer)
|
||||||
semantic_type_redeclaration (type, "%printer",
|
{
|
||||||
code_props_location_get (type->printer),
|
if (sym->printer)
|
||||||
code_props_location_get (printer));
|
symbol_redeclaration (sym, "%printer", sym->printer_location, loc);
|
||||||
type->printer = printer;
|
sym->printer = printer;
|
||||||
|
sym->printer_location = loc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------.
|
||||||
|
| Set the PRINTER associated with TYPE. Do nothing if passed 0. |
|
||||||
|
`----------------------------------------------------------------*/
|
||||||
|
|
||||||
|
void
|
||||||
|
semantic_type_printer_set (semantic_type *type, const char *printer,
|
||||||
|
location loc)
|
||||||
|
{
|
||||||
|
if (printer)
|
||||||
|
{
|
||||||
|
if (type->printer)
|
||||||
|
semantic_type_redeclaration (type, "%printer", type->printer_location,
|
||||||
|
loc);
|
||||||
|
type->printer = printer;
|
||||||
|
type->printer_location = loc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------.
|
/*------------------------------------.
|
||||||
| Get the computed %printer for SYM. |
|
| Get the computed %printer for SYM. |
|
||||||
`------------------------------------*/
|
`------------------------------------*/
|
||||||
|
|
||||||
code_props
|
const char *
|
||||||
symbol_printer_get (symbol *sym)
|
symbol_printer_get (symbol *sym)
|
||||||
{
|
{
|
||||||
/* Per-symbol %printer. */
|
/* Per-symbol %printer. */
|
||||||
if (code_props_code_get (sym->printer))
|
if (sym->printer != NULL)
|
||||||
return sym->printer;
|
return sym->printer;
|
||||||
|
|
||||||
/* Per-type %printer. */
|
/* Per-type %printer. */
|
||||||
if (sym->type_name)
|
if (sym->type_name)
|
||||||
{
|
{
|
||||||
code_props printer = semantic_type_get (sym->type_name)->printer;
|
semantic_type *type = semantic_type_get (sym->type_name);
|
||||||
if (code_props_code_get (printer))
|
if (type->printer)
|
||||||
return printer;
|
return type->printer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Apply the default %printer only to user-defined symbols. */
|
/* Apply the default %printer only to user-defined symbols. */
|
||||||
if (sym->tag[0] == '$' || sym == errtoken)
|
if (sym->tag[0] == '$' || sym == errtoken)
|
||||||
return code_props_none;
|
return NULL;
|
||||||
|
|
||||||
if (sym->type_name)
|
if (sym->type_name)
|
||||||
return default_tagged_printer;
|
return default_tagged_printer;
|
||||||
return default_tagless_printer;
|
return default_tagless_printer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------------------.
|
||||||
|
| Get the grammar location of the %printer computed for SYM. |
|
||||||
|
`------------------------------------------------------------*/
|
||||||
|
|
||||||
|
location
|
||||||
|
symbol_printer_location_get (symbol *sym)
|
||||||
|
{
|
||||||
|
if (sym->printer != NULL)
|
||||||
|
return sym->printer_location;
|
||||||
|
if (sym->type_name)
|
||||||
|
{
|
||||||
|
semantic_type *type = semantic_type_get (sym->type_name);
|
||||||
|
if (type->printer)
|
||||||
|
return type->printer_location;
|
||||||
|
return default_tagged_printer_location;
|
||||||
|
}
|
||||||
|
return default_tagless_printer_location;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------.
|
/*-----------------------------------------------------------------.
|
||||||
| Set the PRECEDENCE associated with SYM. Does nothing if invoked |
|
| Set the PRECEDENCE associated with SYM. Does nothing if invoked |
|
||||||
| with UNDEF_ASSOC as ASSOC. |
|
| with UNDEF_ASSOC as ASSOC. |
|
||||||
@@ -446,22 +498,22 @@ symbol_check_alias_consistency (symbol *this)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (code_props_code_get (orig->destructor)
|
if (orig->destructor || alias->destructor)
|
||||||
|| code_props_code_get (alias->destructor))
|
|
||||||
{
|
{
|
||||||
if (code_props_code_get (orig->destructor))
|
if (orig->destructor)
|
||||||
symbol_destructor_set (alias, orig->destructor);
|
symbol_destructor_set (alias, orig->destructor,
|
||||||
|
orig->destructor_location);
|
||||||
else
|
else
|
||||||
symbol_destructor_set (orig, alias->destructor);
|
symbol_destructor_set (orig, alias->destructor,
|
||||||
|
alias->destructor_location);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code_props_code_get (orig->printer)
|
if (orig->printer || alias->printer)
|
||||||
|| code_props_code_get (alias->printer))
|
|
||||||
{
|
{
|
||||||
if (code_props_code_get (orig->printer))
|
if (orig->printer)
|
||||||
symbol_printer_set (alias, orig->printer);
|
symbol_printer_set (alias, orig->printer, orig->printer_location);
|
||||||
else
|
else
|
||||||
symbol_printer_set (orig, alias->printer);
|
symbol_printer_set (orig, alias->printer, alias->printer_location);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (alias->prec || orig->prec)
|
if (alias->prec || orig->prec)
|
||||||
@@ -890,54 +942,53 @@ symbols_pack (void)
|
|||||||
`--------------------------------------------------*/
|
`--------------------------------------------------*/
|
||||||
|
|
||||||
void
|
void
|
||||||
default_tagged_destructor_set (code_props destructor)
|
default_tagged_destructor_set (const char *destructor, location loc)
|
||||||
{
|
{
|
||||||
if (code_props_code_get (default_tagged_destructor))
|
if (default_tagged_destructor != NULL)
|
||||||
{
|
{
|
||||||
complain_at (code_props_location_get (destructor),
|
complain_at (loc, _("redeclaration for default tagged %%destructor"));
|
||||||
_("redeclaration for default tagged %%destructor"));
|
complain_at (default_tagged_destructor_location,
|
||||||
complain_at (code_props_location_get (default_tagged_destructor),
|
|
||||||
_("previous declaration"));
|
_("previous declaration"));
|
||||||
}
|
}
|
||||||
default_tagged_destructor = destructor;
|
default_tagged_destructor = destructor;
|
||||||
|
default_tagged_destructor_location = loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
default_tagless_destructor_set (code_props destructor)
|
default_tagless_destructor_set (const char *destructor, location loc)
|
||||||
{
|
{
|
||||||
if (code_props_code_get (default_tagless_destructor))
|
if (default_tagless_destructor != NULL)
|
||||||
{
|
{
|
||||||
complain_at (code_props_location_get (destructor),
|
complain_at (loc, _("redeclaration for default tagless %%destructor"));
|
||||||
_("redeclaration for default tagless %%destructor"));
|
complain_at (default_tagless_destructor_location,
|
||||||
complain_at (code_props_location_get (default_tagless_destructor),
|
|
||||||
_("previous declaration"));
|
_("previous declaration"));
|
||||||
}
|
}
|
||||||
default_tagless_destructor = destructor;
|
default_tagless_destructor = destructor;
|
||||||
|
default_tagless_destructor_location = loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
default_tagged_printer_set (code_props printer)
|
default_tagged_printer_set (const char *printer, location loc)
|
||||||
{
|
{
|
||||||
if (code_props_code_get (default_tagged_printer))
|
if (default_tagged_printer != NULL)
|
||||||
{
|
{
|
||||||
complain_at (code_props_location_get (printer),
|
complain_at (loc, _("redeclaration for default tagged %%printer"));
|
||||||
_("redeclaration for default tagged %%printer"));
|
complain_at (default_tagged_printer_location,
|
||||||
complain_at (code_props_location_get (default_tagged_printer),
|
|
||||||
_("previous declaration"));
|
_("previous declaration"));
|
||||||
}
|
}
|
||||||
default_tagged_printer = printer;
|
default_tagged_printer = printer;
|
||||||
|
default_tagged_printer_location = loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
default_tagless_printer_set (code_props printer)
|
default_tagless_printer_set (const char *printer, location loc)
|
||||||
{
|
{
|
||||||
if (code_props_code_get (default_tagless_printer))
|
if (default_tagless_printer != NULL)
|
||||||
{
|
{
|
||||||
complain_at (code_props_location_get (printer),
|
complain_at (loc, _("redeclaration for default tagless %%printer"));
|
||||||
_("redeclaration for default tagless %%printer"));
|
complain_at (default_tagless_printer_location,
|
||||||
complain_at (code_props_location_get (default_tagless_printer),
|
|
||||||
_("previous declaration"));
|
_("previous declaration"));
|
||||||
}
|
}
|
||||||
default_tagless_printer = printer;
|
default_tagless_printer = printer;
|
||||||
|
default_tagless_printer_location = loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
64
src/symtab.h
64
src/symtab.h
@@ -30,7 +30,6 @@
|
|||||||
|
|
||||||
# include "assoc.h"
|
# include "assoc.h"
|
||||||
# include "location.h"
|
# include "location.h"
|
||||||
# include "scan-code.h"
|
|
||||||
# include "uniqstr.h"
|
# include "uniqstr.h"
|
||||||
|
|
||||||
/*----------.
|
/*----------.
|
||||||
@@ -73,13 +72,25 @@ struct symbol
|
|||||||
example, if <tt>symbol::destructor = NULL</tt>, a default \c \%destructor
|
example, if <tt>symbol::destructor = NULL</tt>, a default \c \%destructor
|
||||||
or a per-type \c \%destructor might be appropriate, and
|
or a per-type \c \%destructor might be appropriate, and
|
||||||
\c symbol_destructor_get will compute the correct one. */
|
\c symbol_destructor_get will compute the correct one. */
|
||||||
code_props destructor;
|
const char *destructor;
|
||||||
|
|
||||||
|
/** The location of \c symbol::destructor.
|
||||||
|
|
||||||
|
Access this field only through <tt>symbol</tt>'s interface functions.
|
||||||
|
\sa symbol::destructor */
|
||||||
|
location destructor_location;
|
||||||
|
|
||||||
/** Any \c \%printer declared specifically for this symbol.
|
/** Any \c \%printer declared specifically for this symbol.
|
||||||
|
|
||||||
Access this field only through <tt>symbol</tt>'s interface functions.
|
Access this field only through <tt>symbol</tt>'s interface functions.
|
||||||
\sa symbol::destructor */
|
\sa symbol::destructor */
|
||||||
code_props printer;
|
const char *printer;
|
||||||
|
|
||||||
|
/** The location of \c symbol::printer.
|
||||||
|
|
||||||
|
Access this field only through <tt>symbol</tt>'s interface functions.
|
||||||
|
\sa symbol::destructor */
|
||||||
|
location printer_location;
|
||||||
|
|
||||||
symbol_number number;
|
symbol_number number;
|
||||||
location prec_location;
|
location prec_location;
|
||||||
@@ -133,18 +144,26 @@ void symbol_make_alias (symbol *sym, symbol *symval, location loc);
|
|||||||
void symbol_type_set (symbol *sym, uniqstr type_name, location loc);
|
void symbol_type_set (symbol *sym, uniqstr type_name, location loc);
|
||||||
|
|
||||||
/** Set the \c destructor associated with \c sym. */
|
/** Set the \c destructor associated with \c sym. */
|
||||||
void symbol_destructor_set (symbol *sym, code_props destructor);
|
void symbol_destructor_set (symbol *sym, const char *destructor, location loc);
|
||||||
|
|
||||||
/** Get the computed \c \%destructor for \c sym, which was initialized with
|
/** Get the computed \c \%destructor for \c sym, or \c NULL if none. */
|
||||||
\c code_props_none_init if there's no \c \%destructor. */
|
const char *symbol_destructor_get (symbol *sym);
|
||||||
code_props symbol_destructor_get (symbol *sym);
|
|
||||||
|
/** Get the grammar location of the computed \c \%destructor for \c sym.
|
||||||
|
|
||||||
|
\pre <tt>symbol_destructor_get (sym) != NULL</tt> */
|
||||||
|
location symbol_destructor_location_get (symbol *sym);
|
||||||
|
|
||||||
/** Set the \c printer associated with \c sym. */
|
/** Set the \c printer associated with \c sym. */
|
||||||
void symbol_printer_set (symbol *sym, code_props printer);
|
void symbol_printer_set (symbol *sym, const char *printer, location loc);
|
||||||
|
|
||||||
/** Get the computed \c \%printer for \c sym, which was initialized with
|
/** Get the computed \c \%printer for \c sym, or \c NULL if none. */
|
||||||
\c code_props_none_init if there's no \c \%printer. */
|
const char *symbol_printer_get (symbol *sym);
|
||||||
code_props symbol_printer_get (symbol *sym);
|
|
||||||
|
/** Get the grammar location of the computed \c \%printer for \c sym.
|
||||||
|
|
||||||
|
\pre <tt>symbol_printer_get (sym) != NULL</tt> */
|
||||||
|
location symbol_printer_location_get (symbol *sym);
|
||||||
|
|
||||||
/* Set the \c precedence associated with \c sym.
|
/* Set the \c precedence associated with \c sym.
|
||||||
|
|
||||||
@@ -190,9 +209,14 @@ typedef struct semantic_type {
|
|||||||
uniqstr tag;
|
uniqstr tag;
|
||||||
|
|
||||||
/** Any \c %destructor declared for this semantic type. */
|
/** Any \c %destructor declared for this semantic type. */
|
||||||
code_props destructor;
|
const char *destructor;
|
||||||
|
/** The location of \c semantic_type::destructor. */
|
||||||
|
location destructor_location;
|
||||||
|
|
||||||
/** Any \c %printer declared for this semantic type. */
|
/** Any \c %printer declared for this semantic type. */
|
||||||
code_props printer;
|
const char *printer;
|
||||||
|
/** The location of \c semantic_type::printer. */
|
||||||
|
location printer_location;
|
||||||
} semantic_type;
|
} semantic_type;
|
||||||
|
|
||||||
/** Fetch (or create) the semantic type associated to KEY. */
|
/** Fetch (or create) the semantic type associated to KEY. */
|
||||||
@@ -202,10 +226,12 @@ semantic_type *semantic_type_from_uniqstr (const uniqstr key);
|
|||||||
semantic_type *semantic_type_get (const char *key);
|
semantic_type *semantic_type_get (const char *key);
|
||||||
|
|
||||||
/** Set the \c destructor associated with \c type. */
|
/** Set the \c destructor associated with \c type. */
|
||||||
void semantic_type_destructor_set (semantic_type *type, code_props destructor);
|
void semantic_type_destructor_set (semantic_type *type, const char *destructor,
|
||||||
|
location loc);
|
||||||
|
|
||||||
/** Set the \c printer associated with \c type. */
|
/** Set the \c printer associated with \c type. */
|
||||||
void semantic_type_printer_set (semantic_type *type, code_props printer);
|
void semantic_type_printer_set (semantic_type *type, const char *printer,
|
||||||
|
location loc);
|
||||||
|
|
||||||
/*----------------------------------.
|
/*----------------------------------.
|
||||||
| Symbol and semantic type tables. |
|
| Symbol and semantic type tables. |
|
||||||
@@ -234,13 +260,13 @@ void symbols_pack (void);
|
|||||||
`---------------------------------------*/
|
`---------------------------------------*/
|
||||||
|
|
||||||
/** Set the default \c \%destructor for tagged values. */
|
/** Set the default \c \%destructor for tagged values. */
|
||||||
void default_tagged_destructor_set (code_props destructor);
|
void default_tagged_destructor_set (const char *destructor, location loc);
|
||||||
/** Set the default \c \%destructor for tagless values. */
|
/** Set the default \c \%destructor for tagless values. */
|
||||||
void default_tagless_destructor_set (code_props destructor);
|
void default_tagless_destructor_set (const char *destructor, location loc);
|
||||||
|
|
||||||
/** Set the default \c \%printer for tagged values. */
|
/** Set the default \c \%printer for tagged values. */
|
||||||
void default_tagged_printer_set (code_props printer);
|
void default_tagged_printer_set (const char *printer, location loc);
|
||||||
/** Set the default \c \%printer for tagless values. */
|
/** Set the default \c \%printer for tagless values. */
|
||||||
void default_tagless_printer_set (code_props printer);
|
void default_tagless_printer_set (const char *printer, location loc);
|
||||||
|
|
||||||
#endif /* !SYMTAB_H_ */
|
#endif /* !SYMTAB_H_ */
|
||||||
|
|||||||
Reference in New Issue
Block a user