mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-14 14:53:03 +00:00
In the grammar scanner, STRING_FINISH unclosed constructs and return
them to the parser in order to improve error messages.
* src/scan-gram.l (SC_ESCAPED_STRING, SC_ESCAPED_CHARACTER,
SC_BRACED_CODE, SC_PROLOGUE): Implement.
* tests/input.at (Unclosed constructs): New test case.
* tests/regression.at (Invalid inputs): Update now that unclosed %{ is
seen.
* src/scan-gram.h, src/scan-gram.l (gram_last_braced_code_loc): Remove
unused global.
This commit is contained in:
@@ -492,3 +492,48 @@ start: 'a';
|
||||
AT_CHECK([bison -o input.c input.y])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
## --------------------- ##
|
||||
## Unclosed constructs. ##
|
||||
## --------------------- ##
|
||||
|
||||
AT_SETUP([Unclosed constructs])
|
||||
|
||||
# Bison's scan-gram.l once forgot to STRING_FINISH some unclosed constructs, so
|
||||
# they were prepended to whatever it STRING_GROW'ed next. It also threw them
|
||||
# away rather than returning them to the parser. The effect was confusing
|
||||
# subsequent error messages.
|
||||
|
||||
AT_DATA([input.y],
|
||||
[[%token A "a
|
||||
%token B "b"
|
||||
%token AB "ab" // Used to complain that "ab" was already used.
|
||||
%token C '1
|
||||
%token TWO "2"
|
||||
%token TICK_TWELVE "'12" // Used to complain that "'12" was already used.
|
||||
|
||||
%%
|
||||
|
||||
start: ;
|
||||
|
||||
// Used to report a syntax error because it didn't see any kind of symbol
|
||||
// identifier.
|
||||
%type <f> 'a
|
||||
;
|
||||
%type <f> "a
|
||||
;
|
||||
// Used to report a syntax error because it didn't see braced code.
|
||||
%destructor { free ($$)
|
||||
]])
|
||||
|
||||
AT_CHECK([bison -o input.c input.y], 1, [],
|
||||
[[input.y:1.10-2.0: missing `"' at end of line
|
||||
input.y:4.10-5.0: missing `'' at end of line
|
||||
input.y:14.11-15.0: missing `'' at end of line
|
||||
input.y:16.11-17.0: missing `"' at end of line
|
||||
input.y:19.13-20.0: missing `}' at end of file
|
||||
input.y:20.1: syntax error, unexpected end of file, expecting ;
|
||||
]])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
@@ -398,6 +398,7 @@ input.y:5.1-17: invalid directive: `%a-does-not-exist'
|
||||
input.y:6.1: invalid character: `%'
|
||||
input.y:6.2: invalid character: `-'
|
||||
input.y:7.1-8.0: missing `%}' at end of file
|
||||
input.y:7.1-8.0: syntax error, unexpected %{...%}
|
||||
]])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
Reference in New Issue
Block a user