From: Akim Demaille Date: Mon, 26 Nov 2012 08:14:51 +0000 (+0100) Subject: Merge remote-tracking branch 'origin/maint' X-Git-Tag: v2.7.90~271 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/c6b1772473d0a26faa22464df98718d0d0ae2e2e Merge remote-tracking branch 'origin/maint' * origin/maint: yacc.c: always initialize yylloc scanner: issue a single error for groups of invalid characters tests: formatting changes doc: one of the fixes for an ambiguous grammar was ambiguous too doc: fix the dangling else with precedence directives doc: prefer "token" to TOKEN doc: formatting changes scanner: use explicit "ignore" statements Conflicts: src/scan-gram.l --- c6b1772473d0a26faa22464df98718d0d0ae2e2e diff --cc doc/bison.texi index 6a35422b,f2d3dbc5..1c4bfd4e --- a/doc/bison.texi +++ b/doc/bison.texi @@@ -276,10 -273,10 +276,11 @@@ The Bison Parser Algorith Operator Precedence * Why Precedence:: An example showing why precedence is needed. -* Using Precedence:: How to specify precedence in Bison grammars. +* Using Precedence:: How to specify precedence and associativity. +* Precedence Only:: How to specify precedence only. * Precedence Examples:: How these features are used in the previous example. * How Precedence:: How they work. + * Non Operators:: Using precedence for general conflicts. Tuning LR @@@ -7013,10 -6741,10 +7018,11 @@@ shift and when to reduce @menu * Why Precedence:: An example showing why precedence is needed. -* Using Precedence:: How to specify precedence in Bison grammars. +* Using Precedence:: How to specify precedence and associativity. +* Precedence Only:: How to specify precedence only. * Precedence Examples:: How these features are used in the previous example. * How Precedence:: How they work. + * Non Operators:: Using precedence for general conflicts. @end menu @node Why Precedence diff --cc src/scan-gram.l index 98124556,fd6458fa..f5c9b88f --- a/src/scan-gram.l +++ b/src/scan-gram.l @@@ -130,10 -103,10 +130,10 @@@ static void unexpected_newline (boundar /* Bracketed identifiers support. */ %x SC_BRACKETED_ID SC_RETURN_BRACKETED_ID -letter [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_] +letter [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_] + notletter [^.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]{-}[%\{] -id {letter}({letter}|[-0-9])* -int [0-9]+ +id {letter}({letter}|[-0-9])* - directive %{id} +int [0-9]+ /* POSIX says that a tag must be both an id and a C union member, but historically almost any character is allowed in a tag. We disallow @@@ -180,11 -146,9 +180,11 @@@ eqopt ([[:space:]]*=) { /* Comments and white space. */ - "," warn_at (*loc, _("stray ',' treated as white space")); + "," { + complain (loc, Wother, _("stray ',' treated as white space")); + } [ \f\n\t\v] | - "//".* ; + "//".* continue; "/*" { token_start = loc->start; context_state = YY_START; @@@ -256,21 -218,8 +256,21 @@@ "%verbose" return PERCENT_VERBOSE; "%yacc" return PERCENT_YACC; + /* deprecated */ + "%default"[-_]"prec" DEPRECATED("%default-prec"); + "%error"[-_]"verbose" DEPRECATED("%define parse.error verbose"); + "%expect"[-_]"rr" DEPRECATED("%expect-rr"); + "%file-prefix"{eqopt} DEPRECATED("%file-prefix"); + "%fixed"[-_]"output"[-_]"files" DEPRECATED("%fixed-output-files"); + "%name"[-_]"prefix"{eqopt} DEPRECATED("%name-prefix"); + "%no"[-_]"default"[-_]"prec" DEPRECATED("%no-default-prec"); + "%no"[-_]"lines" DEPRECATED("%no-lines"); + "%output"{eqopt} DEPRECATED("%output"); + "%pure"[-_]"parser" DEPRECATED("%pure-parser"); + "%token"[-_]"table" DEPRECATED("%token-table"); + - {directive} { + "%"{id}|"%"{notletter}([[:graph:]])+ { - complain_at (*loc, _("invalid directive: %s"), quote (yytext)); + complain (loc, complaint, _("invalid directive: %s"), quote (yytext)); } "=" return EQUAL; @@@ -353,9 -290,10 +353,10 @@@ BEGIN SC_BRACKETED_ID; } - . { - complain (loc, complaint, _("invalid character: %s"), + [^\[%A-Za-z0-9_<>{}\"\'*;|=/, \f\n\t\v]+|. { - complain_at (*loc, "%s: %s", - ngettext ("invalid character", "invalid characters", yyleng), - quote_mem (yytext, yyleng)); ++ complain (loc, complaint, "%s: %s", ++ ngettext ("invalid character", "invalid characters", yyleng), + quote_mem (yytext, yyleng)); } <> { @@@ -438,21 -364,25 +439,25 @@@ BEGIN bracketed_id_context_state; if (bracketed_id_str) { - if (INITIAL == bracketed_id_context_state) - { - val->uniqstr = bracketed_id_str; - bracketed_id_str = 0; - *loc = bracketed_id_loc; - return BRACKETED_ID; - } + if (INITIAL == bracketed_id_context_state) + { + val->uniqstr = bracketed_id_str; + bracketed_id_str = 0; + *loc = bracketed_id_loc; + return BRACKETED_ID; + } } else - complain_at (*loc, _("an identifier expected")); + complain (loc, complaint, _("an identifier expected")); } - . { - complain (loc, complaint, _("invalid character in bracketed name: %s"), + + [^\].A-Za-z0-9_/ \f\n\t\v]+|. { - complain_at (*loc, "%s: %s", - ngettext ("invalid character in bracketed name", - "invalid characters in bracketed name", yyleng), - quote_mem (yytext, yyleng)); ++ complain (loc, complaint, "%s: %s", ++ ngettext ("invalid character in bracketed name", ++ "invalid characters in bracketed name", yyleng), + quote_mem (yytext, yyleng)); } + <> { BEGIN bracketed_id_context_state; unexpected_eof (bracketed_id_start, "]"); @@@ -479,7 -409,7 +484,7 @@@ { "*/" BEGIN context_state; - .|\n ; - .|\n continue; ++ .|\n continue; <> unexpected_eof (token_start, "*/"); BEGIN context_state; } diff --cc tests/named-refs.at index 8c0fbb90,de48e0f7..ea379222 --- a/tests/named-refs.at +++ b/tests/named-refs.at @@@ -69,15 -69,15 +69,15 @@@ exp { if ($l != $r) fprintf (stderr, "calc: error: %d != %d\n", $l, $r); - $$ = $l; + $$ = $l; } | exp[x] '+' { $$ = $x; } [l] exp[r] { $$ = $l + $r; } - | exp[l] '-' exp[r] { $$ = $l - $r; } - | exp[l] '*' exp[r] { $$ = $l * $r; } + | exp[l] '-' exp[r] { $$ = $l - $r; } + | exp[l] '*' exp[r] { $$ = $l * $r; } | exp[l] '/' exp[r] { $$ = $l / $r; } | '-' exp %prec NEG { $$ = -$2; } - | exp[l] '^' exp[r] { $$ = power ($l, $r); } - | '(' exp[e] ')' { $$ = $e; } + | exp[l] '^' exp[r] { $$ = power ($l, $r); } + | '(' exp[e] ')' { $$ = $e; } | '(' error ')' { $$ = 1111; yyerrok; } | '!' { $$ = 0; YYERROR; } | '-' error { $$ = 0; YYERROR; }