X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/2cbe6b7f8f268366877078c8256011e20a76c464..02975b9aade52df362645b82a81ac2134290e221:/src/parse-gram.y diff --git a/src/parse-gram.y b/src/parse-gram.y index 66e5283a..aabace13 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -93,13 +93,13 @@ static int current_prec = 0; boundary_set (&@$.end, current_file, 1, 1); } -/* Only NUMBERS have a value. */ %union { symbol *symbol; symbol_list *list; int integer; - char *chars; + char const *chars; + char *code; assoc assoc; uniqstr uniqstr; unsigned char character; @@ -116,8 +116,6 @@ static int current_prec = 0; %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" @@ -177,17 +175,20 @@ static int current_prec = 0; %token PROLOGUE "%{...%}" %token SEMICOLON ";" %token TYPE "type" +%token TYPE_TAG_ANY "<*>" +%token TYPE_TAG_NONE "<>" %type CHAR %printer { fputs (char_name ($$), stderr); } CHAR /* braceless is not to be used for rule or symbol actions, as it calls translate_code. */ -%type STRING "{...}" "%{...%}" EPILOGUE braceless content content.opt +%type STRING "%{...%}" EPILOGUE braceless content content.opt +%type "{...}" %printer { fputs (quotearg_style (c_quoting_style, $$), stderr); } - STRING + STRING %printer { fprintf (stderr, "{\n%s\n}", $$); } - braceless content content.opt "{...}" "%{...%}" EPILOGUE + braceless content content.opt "{...}" "%{...%}" EPILOGUE %type TYPE ID ID_COLON %printer { fprintf (stderr, "<%s>", $$); } TYPE @@ -225,10 +226,16 @@ prologue_declaration: | "%debug" { debug_flag = true; } | "%define" STRING content.opt { muscle_insert ($2, $3); } | "%defines" { defines_flag = true; } +| "%defines" STRING + { + defines_flag = true; + spec_defines_file = xstrdup ($2); + } | "%error-verbose" { error_verbose = true; } | "%expect" INT { expected_sr_conflicts = $2; } | "%expect-rr" INT { expected_rr_conflicts = $2; } -| "%file-prefix" "=" STRING { spec_file_prefix = $3; } +| "%file-prefix" STRING { spec_file_prefix = $2; } +| "%file-prefix" "=" STRING { spec_file_prefix = $3; } /* deprecated */ | "%glr-parser" { nondeterministic_parser = true; @@ -240,10 +247,12 @@ prologue_declaration: } | "%lex-param" "{...}" { add_param ("lex_param", $2, @2); } | "%locations" { locations_flag = true; } -| "%name-prefix" "=" STRING { spec_name_prefix = $3; } +| "%name-prefix" STRING { spec_name_prefix = $2; } +| "%name-prefix" "=" STRING { spec_name_prefix = $3; } /* deprecated */ | "%no-lines" { no_lines_flag = true; } | "%nondeterministic-parser" { nondeterministic_parser = true; } -| "%output" "=" STRING { spec_outfile = $3; } +| "%output" STRING { spec_outfile = $2; } +| "%output" "=" STRING { spec_outfile = $3; } /* deprecated */ | "%parse-param" "{...}" { add_param ("parse_param", $2, @2); } | "%pure-parser" { pure_parser = true; } | "%push-parser" { push_parser = true; } @@ -267,7 +276,7 @@ grammar_declaration: symbol_list *list; const char *action = translate_symbol_action ($2, @2); for (list = $3; list; list = list->next) - symbol_list_destructor_set (list, action, @2); + symbol_list_destructor_set (list, action, @2); symbol_list_free ($3); } | "%printer" "{...}" generic_symlist @@ -275,7 +284,7 @@ grammar_declaration: symbol_list *list; const char *action = translate_symbol_action ($2, @2); for (list = $3; list; list = list->next) - symbol_list_printer_set (list, action, @2); + symbol_list_printer_set (list, action, @2); symbol_list_free ($3); } | "%default-prec" @@ -395,7 +404,8 @@ generic_symlist: generic_symlist_item: symbol { $$ = symbol_list_sym_new ($1, @1); } | TYPE { $$ = symbol_list_type_new ($1, @1); } -| "%symbol-default" { $$ = symbol_list_default_new (@1); } +| "<*>" { $$ = symbol_list_default_tagged_new (@1); } +| "<>" { $$ = symbol_list_default_tagless_new (@1); } ; /* One token definition. */