mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
muscles: be sure that %code snippets are not glue together on a single line
Recently "braceless" in the parser was changed so that an eol was no longer added to the value. This is not correct when a %code is used multiple times, because the syncline of the next snippet might be appended to the last (and not ended) line of the previous snippet. * src/muscle-tab.h (muscle_grow): Make it private. * src/muscle-tab.c (muscle_grow): Accept a fourth argument: a required terminator. Adjust callers. * tests/input.at (Multiple %code): New.
This commit is contained in:
@@ -1274,6 +1274,45 @@ special-char-@:>@.y:3.7: error: %code qualifier 'q' is not used
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
## ---------------- ##
|
||||
## Multiple %code. ##
|
||||
## ---------------- ##
|
||||
|
||||
AT_SETUP([Multiple %code])
|
||||
|
||||
# Make sure that repeated arguments to %code are separated by
|
||||
# end-of-lines. At some point, a missing eol would leave synclines
|
||||
# appended to the previous value. Here, we use CPP directive to
|
||||
# introduce dependency on the absence/presence of the eol.
|
||||
AT_BISON_OPTION_PUSHDEFS
|
||||
|
||||
AT_DATA([input.y],
|
||||
[[%code {#include <assert.h>}
|
||||
%code {#define A B}
|
||||
%code {#define B C}
|
||||
%code {#define C D}
|
||||
%code {#define D 42}
|
||||
%code {
|
||||
]AT_YYERROR_DECLARE[
|
||||
]AT_YYLEX_DECLARE[
|
||||
}
|
||||
%%
|
||||
start: %empty;
|
||||
%%
|
||||
]AT_YYERROR_DEFINE[
|
||||
]AT_YYLEX_DEFINE[
|
||||
int main (void)
|
||||
{
|
||||
assert (A == 42);
|
||||
return 0;
|
||||
}
|
||||
]])
|
||||
AT_FULL_COMPILE([input])
|
||||
AT_PARSER_CHECK([./input])
|
||||
|
||||
AT_BISON_OPTION_POPDEFS
|
||||
AT_CLEANUP()
|
||||
|
||||
## ---------------- ##
|
||||
## %define errors. ##
|
||||
## ---------------- ##
|
||||
|
||||
Reference in New Issue
Block a user