%error-verbose
%defines
%name-prefix="gram_"
+%expect 0
%initial-action
{
%token PERCENT_TYPE "%type"
%token PERCENT_DESTRUCTOR "%destructor"
%token PERCENT_PRINTER "%printer"
+%token PERCENT_SYMBOL_DEFAULT
+ "%symbol-default"
%token PERCENT_LEFT "%left"
%token PERCENT_RIGHT "%right"
PERCENT_OUTPUT "%output"
PERCENT_PARSE_PARAM "%parse-param"
PERCENT_PURE_PARSER "%pure-parser"
+ PERCENT_PUSH_PARSER "%push-parser"
PERCENT_REQUIRE "%require"
PERCENT_SKELETON "%skeleton"
PERCENT_START "%start"
%printer { fprintf (stderr, "%s:", $$->tag); } id_colon
%type <assoc> precedence_declarator
-%type <list> symbols.1
+%type <list> symbols.1 generic_symlist generic_symlist_item
%%
input:
| "%output" "=" STRING { spec_outfile = $3; }
| "%parse-param" "{...}" { add_param ("parse_param", $2, @2); }
| "%pure-parser" { pure_parser = true; }
+| "%push-parser" { push_parser = true; }
| "%require" STRING { version_check (&@2, $2); }
| "%skeleton" STRING { skeleton = $2; }
| "%start-header" braceless { muscle_code_grow ("start_header", $2, @2); }
{
grammar_start_symbol_set ($2, @2);
}
-| "%destructor" "{...}" symbols.1
+| "%destructor" "{...}" generic_symlist
{
symbol_list *list;
const char *action = translate_symbol_action ($2, @2);
for (list = $3; list; list = list->next)
- symbol_destructor_set (list->sym, action, @2);
+ symbol_list_destructor_set (list, action, @2);
symbol_list_free ($3);
}
-| "%printer" "{...}" symbols.1
+| "%printer" "{...}" generic_symlist
{
symbol_list *list;
const char *action = translate_symbol_action ($2, @2);
for (list = $3; list; list = list->next)
- symbol_printer_set (list->sym, action, @2);
+ symbol_list_printer_set (list, action, @2);
symbol_list_free ($3);
}
| "%default-prec"
tag_seen = true;
symbol_list *list;
for (list = $3; list; list = list->next)
- symbol_type_set (list->sym, $2, @2);
+ symbol_type_set (list->content.sym, $2, @2);
symbol_list_free ($3);
}
;
++current_prec;
for (list = $3; list; list = list->next)
{
- symbol_type_set (list->sym, current_type, @2);
- symbol_precedence_set (list->sym, current_prec, $1, @1);
+ symbol_type_set (list->content.sym, current_type, @2);
+ symbol_precedence_set (list->content.sym, current_prec, $1, @1);
}
symbol_list_free ($3);
current_type = NULL;
| TYPE { current_type = $1; tag_seen = true; }
;
-/* One or more nonterminals to be %typed. */
+/* One or more symbols to be %typed. */
symbols.1:
- symbol { $$ = symbol_list_new ($1, @1); }
-| symbols.1 symbol { $$ = symbol_list_prepend ($1, $2, @2); }
+ symbol
+ { $$ = symbol_list_sym_new ($1, @1); }
+| symbols.1 symbol
+ { $$ = symbol_list_prepend ($1, symbol_list_sym_new ($2, @2)); }
+;
+
+generic_symlist:
+ generic_symlist_item { $$ = $1; }
+| generic_symlist generic_symlist_item { $$ = symbol_list_prepend ($1, $2); }
+;
+
+generic_symlist_item:
+ symbol { $$ = symbol_list_sym_new ($1, @1); }
+| TYPE { $$ = symbol_list_type_new ($1, @1); }
+| "%symbol-default" { $$ = symbol_list_default_new (@1); }
;
/* One token definition. */