Move error recovery to the common_block definition to handle errors
in any block. Queue those errors and abort parsing once a threshold
is reached.
With this in place, we can continue parsing when errors occur and
show all of them to the user at once.
tests/error.1:3:8-8: Error: syntax error, unexpected '{', expecting string
filter {
^
tests/error.1:4:13-13: Error: syntax error, unexpected newline
filter input
^
tests/error.1:5:17-17: Error: syntax error, unexpected newline
filter input tcp
^
tests/error.1:6:23-23: Error: syntax error, unexpected newline
filter input tcp dport
Signed-off-by: Patrick McHardy <kaber@trash.net>
#define INCLUDE_PATHS_MAX 16
+extern unsigned int max_errors;
extern unsigned int numeric_output;
extern unsigned int handle_output;
extern unsigned int debug_level;
unsigned int indesc_idx;
struct list_head *msgs;
+ unsigned int nerrs;
struct scope top_scope;
struct scope *scopes[SCOPE_NEST_MAX];
#include <erec.h>
#include <mnl.h>
+unsigned int max_errors = 10;
unsigned int numeric_output;
unsigned int handle_output;
#ifdef DEBUG
int ret = 0;
ret = nft_parse(scanner, state);
- if (ret != 0)
+ if (ret != 0 || state->nerrs > 0)
return -1;
memset(&ctx, 0, sizeof(ctx));
symbol_bind(current_scope(state), $2, $4);
xfree($2);
}
+ | error stmt_seperator
+ {
+ if (++state->nerrs == max_errors)
+ YYABORT;
+ yyerrok;
+ }
;
line : common_block { $$ = NULL; }
YYACCEPT;
}
- | base_cmd error { $$ = $1; }
;
base_cmd : /* empty */ add_cmd { $$ = $1; }