X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/d9df47b656fd1757f1f36c8f3d823ca9ca5bfe91..e186a284863938a406f562630a3bdc48737a664a:/src/parse-gram.y diff --git a/src/parse-gram.y b/src/parse-gram.y index 4d1c45a4..83b02e36 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -1,7 +1,7 @@ %{/* Bison Grammar Parser -*- C -*- - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, - Inc. + Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -21,8 +21,6 @@ #include #include "system.h" -#include - #include "complain.h" #include "conflicts.h" #include "files.h" @@ -192,12 +190,12 @@ static int current_prec = 0; %type INT %printer { fprintf (stderr, "%d", $$); } INT -%type id id_colon symbol string_as_id +%type id id_colon symbol symbol.prec string_as_id %printer { fprintf (stderr, "%s", $$->tag); } id symbol string_as_id %printer { fprintf (stderr, "%s:", $$->tag); } id_colon %type precedence_declarator -%type symbols.1 generic_symlist generic_symlist_item +%type symbols.1 symbols.prec generic_symlist generic_symlist_item %% input: @@ -256,7 +254,7 @@ prologue_declaration: muscle_code_grow ("initial_action", action.code, @2); code_scanner_last_string_free (); } -| "%language" STRING { language_argmatch ($2, 1, &@1); } +| "%language" STRING { language_argmatch ($2, grammar_prio, @1); } | "%lex-param" "{...}" { add_param ("lex_param", $2, @2); } | "%locations" { locations_flag = true; } | "%name-prefix" STRING { spec_name_prefix = $2; } @@ -302,10 +300,10 @@ prologue_declaration: skeleton_user = uniqstr_new (skeleton_build); free (skeleton_build); } - skeleton_arg (skeleton_user, 1, &@1); + skeleton_arg (skeleton_user, grammar_prio, @1); } | "%token-table" { token_table_flag = true; } -| "%verbose" { report_flag = report_states; } +| "%verbose" { report_flag |= report_states; } | "%yacc" { yacc_flag = true; } | /*FIXME: Err? What is this horror doing here? */ ";" ; @@ -399,7 +397,7 @@ symbol_declaration: ; precedence_declaration: - precedence_declarator type.opt symbols.1 + precedence_declarator type.opt symbols.prec { symbol_list *list; ++current_prec; @@ -424,6 +422,19 @@ type.opt: | TYPE { current_type = $1; tag_seen = true; } ; +/* Just like symbols.1 but accept INT for the sake of POSIX. */ +symbols.prec: + symbol.prec + { $$ = symbol_list_sym_new ($1, @1); } +| symbols.prec symbol.prec + { $$ = symbol_list_prepend ($1, symbol_list_sym_new ($2, @2)); } +; + +symbol.prec: + symbol { $$ = $1; } + | symbol INT { $$ = $1; symbol_user_token_number_set ($1, $2, @2); } + ; + /* One or more symbols to be %typed. */ symbols.1: symbol