/* Bracketed identifiers support. */
%x SC_BRACKETED_ID SC_RETURN_BRACKETED_ID
-letter [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
+letter [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
+notletter [^.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]{-}[%\{]
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
"%verbose" return PERCENT_VERBOSE;
"%yacc" return PERCENT_YACC;
- {directive} {
+ "%"{id}|"%"{notletter}([[:graph:]])+ {
complain_at (*loc, _("invalid directive: %s"), quote (yytext));
}
BEGIN SC_BRACKETED_ID;
}
- . {
- complain_at (*loc, _("invalid character: %s"), quote_mem (yytext, yyleng));
+ [^\[%A-Za-z0-9_<>{}\"\'*;|=/, \f\n\t\v]+|. {
+ complain_at (*loc, "%s: %s",
+ ngettext ("invalid character", "invalid characters", yyleng),
+ quote_mem (yytext, yyleng));
}
<<EOF>> {
else
complain_at (*loc, _("an identifier expected"));
}
- . {
- complain_at (*loc, _("invalid character in bracketed name: %s"),
- quote_mem (yytext, yyleng));
+
+ [^\].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));
}
+
<<EOF>> {
BEGIN bracketed_id_context_state;
unexpected_eof (bracketed_id_start, "]");
AT_CHECK([[$PERL -pi -e 's/\\(\d{3})/chr(oct($1))/ge' input.y || exit 77]])
AT_BISON_CHECK([input.y], [1], [],
-[[input.y:1.1: error: invalid character: '\0'
-input.y:1.1: error: invalid character: '\001'
-input.y:1.1: error: invalid character: '\002'
-input.y:1.1: error: invalid character: '\377'
-input.y:1.2: error: invalid character: '?'
+[[input.y:1.1-2: error: invalid characters: '\0\001\002\377?'
input.y:3.1: error: invalid character: '?'
input.y:4.14: error: invalid character: '}'
input.y:5.1: error: invalid character: '%'
AT_DATA_GRAMMAR([test.y],
[[
%%
-start: foo[ /* aaa */ *&-.+\000\001\002\377 ] bar
+start: foo[ % /* aaa */ *&-.+\000\001\002\377 ] bar
{ s = $foo; }
]])
AT_CHECK([[$PERL -pi -e 's/\\(\d{3})/chr(oct($1))/ge' test.y || exit 77]])
AT_BISON_CHECK([-o test.c test.y], 1, [],
-[[test.y:11.23: error: invalid character in bracketed name: '*'
-test.y:11.24: error: invalid character in bracketed name: '&'
-test.y:11.25: error: invalid character in bracketed name: '-'
-test.y:11.27: error: invalid character in bracketed name: '+'
-test.y:11.28: error: invalid character in bracketed name: '\0'
-test.y:11.28: error: invalid character in bracketed name: '\001'
-test.y:11.28: error: invalid character in bracketed name: '\002'
-test.y:11.28: error: invalid character in bracketed name: '\377'
+[[test.y:11.13: error: invalid character in bracketed name: '%'
+test.y:11.25-27: error: invalid characters in bracketed name: '*&-'
+test.y:11.29-30: error: invalid characters in bracketed name: '+\0\001\002\377'
]])
AT_CLEANUP