/* 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
<INITIAL,SC_AFTER_IDENTIFIER,SC_BRACKETED_ID,SC_RETURN_BRACKETED_ID>
{
/* 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;
"%verbose" return PERCENT_VERBOSE;
"%yacc" return PERCENT_YACC;
- {directive} {
+ /* 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");
+
- complain_at (*loc, _("invalid directive: %s"), quote (yytext));
+ "%"{id}|"%"{notletter}([[:graph:]])+ {
+ complain (loc, complaint, _("invalid directive: %s"), quote (yytext));
}
"=" return EQUAL;
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));
}
<<EOF>> {
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));
}
+
<<EOF>> {
BEGIN bracketed_id_context_state;
unexpected_eof (bracketed_id_start, "]");
<SC_YACC_COMMENT>
{
"*/" BEGIN context_state;
- .|\n ;
- .|\n continue;
++ .|\n continue;
<<EOF>> unexpected_eof (token_start, "*/"); BEGIN context_state;
}
{
if ($l != $r)
fprintf (stderr, "calc: error: %d != %d\n", $l, $r);
- $$ = $l;
+ $$ = $l;
}
| exp[x] '+' { $<ival>$ = $x; } [l] exp[r] { $$ = $<ival>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; }