From 882a58ec5c8405470cf7550218682b3144dd7cb8 Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Tue, 6 Jul 2010 05:57:00 +0200 Subject: parser: support bison >= 2.4 Work around stange behaviour in bison >= 2.4 (see large comment in parser.y for details) and remove the skeleton file since it does not work with 2.4 anymore. Its only purpose was to increase the amount of possible tokens reported in error messages anyways. Signed-off-by: Patrick McHardy --- src/parser.y | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/parser.y') diff --git a/src/parser.y b/src/parser.y index 3004cb25..7668cbf2 100644 --- a/src/parser.y +++ b/src/parser.y @@ -482,7 +482,25 @@ common_block : INCLUDE QUOTED_STRING stmt_seperator line : common_block { $$ = NULL; } | stmt_seperator { $$ = NULL; } | base_cmd stmt_seperator { $$ = $1; } - | base_cmd TOKEN_EOF { $$ = $1; } + | base_cmd TOKEN_EOF + { + /* + * Very hackish workaround for bison >= 2.4: previous versions + * terminated parsing after EOF, 2.4+ tries to get further input + * in 'input' and calls the scanner again, causing a crash when + * the final input buffer has been popped. Terminate manually to + * avoid this. The correct fix should be to adjust the grammar + * to accept EOF in input, but for unknown reasons it does not + * work. + */ + if ($1 != NULL) { + $1->location = @1; + list_add_tail(&$1->list, &state->cmds); + } + $$ = NULL; + + YYACCEPT; + } | base_cmd error { $$ = $1; } ; -- cgit v1.2.3