Handle unexpected tokens properly
Also, add null and boolean values to json grammar
This commit is contained in:
parent
f248ece3aa
commit
c40411b4d1
5 changed files with 158 additions and 40 deletions
|
|
@ -351,7 +351,11 @@ static int ts_lr_parser_handle_error(ts_lr_parser *parser) {
|
|||
|
||||
for (;;) {
|
||||
ts_tree_release(parser->lookahead);
|
||||
size_t position = ts_lexer_position(&parser->lexer);
|
||||
parser->lookahead = ts_lex(&parser->lexer, ts_lex_state_error);
|
||||
if (ts_lexer_position(&parser->lexer) == position)
|
||||
ts_lexer_advance(&parser->lexer);
|
||||
|
||||
if (parser->lookahead->symbol == ts_builtin_sym_end) {
|
||||
parser->stack.entries[0].node = error;
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue