diff --git a/src/lx/parser.act b/src/lx/parser.act index 78254e123..f9b0b32f9 100644 --- a/src/lx/parser.act +++ b/src/lx/parser.act @@ -869,7 +869,19 @@ lx->free(lx->buf_opaque); - assert(ast != NULL); + /* + * This can happen when the first token is TOK_UNKNOWN. + * SID's generated parser bails out immediately. + * So we never reach , and never about it. + * + * Really I wanted this handled along with the usual syntax error + * case, from ## alts inside parser.sid, instead of reproducing + * the same error here. + */ + if (ast == NULL) { + err(lex_state, "Syntax error"); + exit(EXIT_FAILURE); + } return ast; } diff --git a/src/lx/parser.c b/src/lx/parser.c index cbc2067fd..dfcf36b8f 100644 --- a/src/lx/parser.c +++ b/src/lx/parser.c @@ -3364,11 +3364,23 @@ ZL1:; lx->free(lx->buf_opaque); - assert(ast != NULL); + /* + * This can happen when the first token is TOK_UNKNOWN. + * SID's generated parser bails out immediately. + * So we never reach , and never about it. + * + * Really I wanted this handled along with the usual syntax error + * case, from ## alts inside parser.sid, instead of reproducing + * the same error here. + */ + if (ast == NULL) { + err(lex_state, "Syntax error"); + exit(EXIT_FAILURE); + } return ast; } -#line 3373 "src/lx/parser.c" +#line 3385 "src/lx/parser.c" /* END OF FILE */ diff --git a/src/lx/parser.h b/src/lx/parser.h index fbe704fc4..bde7c36ab 100644 --- a/src/lx/parser.h +++ b/src/lx/parser.h @@ -29,7 +29,7 @@ extern void p_lx(lex_state, act_state, ast *); /* BEGINNING OF TRAILER */ -#line 877 "src/lx/parser.act" +#line 889 "src/lx/parser.act" #line 36 "src/lx/parser.h"