mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
* src/parse-gram.y: Include quotearg.h.
(string_as_id): Quote $1 before using it as a key, since the
lexer no longer quotes it for us.
(string_content): Don't strip quotes, since lexer no longer
quotes it for us.
* src/scan-gram.l: Include quotearg.h.
("\""): Omit quote.
("'"<SC_ESCAPED_CHARACTER>): Quote symbol before using it as
a key, since the rest of the lexer doesn't quote it.
* src/symtab.c (symbol_get): Don't quote symbol; caller does it now.
* tests/regression.at (Token definitions): Check for backslashes
in token strings.
This commit is contained in:
@@ -314,20 +314,44 @@ AT_SETUP([Token definitions])
|
||||
# Bison managed, when fed with `%token 'f' "f"' to #define 'f'!
|
||||
AT_DATA_GRAMMAR([input.y],
|
||||
[%{
|
||||
#include <stdio.h>
|
||||
void yyerror (const char *s);
|
||||
int yylex (void);
|
||||
%}
|
||||
[%token MYEOF 0 "end of file"
|
||||
[%error-verbose
|
||||
%token MYEOF 0 "end of file"
|
||||
%token 'a' "a"
|
||||
%token B_TOKEN "b"
|
||||
%token C_TOKEN 'c'
|
||||
%token 'd' D_TOKEN
|
||||
%token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\377\x001\x0000ff"
|
||||
%%
|
||||
exp: "a";
|
||||
exp: "a" "\\\'\?\"\a\b\f\n\r\t\v\001\377\x001\x0000ff";
|
||||
%%
|
||||
void
|
||||
yyerror (char const *s)
|
||||
{
|
||||
fprintf (stderr, "%s\n", s);
|
||||
}
|
||||
|
||||
int
|
||||
yylex (void)
|
||||
{
|
||||
return SPECIAL;
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
return yyparse ();
|
||||
}
|
||||
]])
|
||||
|
||||
AT_CHECK([bison -o input.c input.y])
|
||||
AT_COMPILE([input.o], [-c input.c])
|
||||
AT_COMPILE([input])
|
||||
AT_PARSER_CHECK([./input], 1, [],
|
||||
[syntax error, unexpected "\\'?\"\a\b\f\n\r\t\v\001\377\001\377", expecting "a"
|
||||
])
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user