Preserve the initial error node in handle_error function
This commit is contained in:
parent
b71d0f7f9d
commit
bd145d2c6a
3 changed files with 33 additions and 31 deletions
|
|
@ -21,7 +21,6 @@ typedef struct TSLexer {
|
|||
size_t position_in_chunk;
|
||||
size_t token_end_position;
|
||||
size_t token_start_position;
|
||||
int reached_end;
|
||||
|
||||
TSTree *(*accept_fn)(struct TSLexer *, TSSymbol, int);
|
||||
int (*advance_fn)(struct TSLexer *);
|
||||
|
|
@ -48,6 +47,10 @@ static inline TSTree *ts_lexer_accept(TSLexer *lexer, TSSymbol symbol,
|
|||
return lexer->accept_fn(lexer, symbol, is_hidden);
|
||||
}
|
||||
|
||||
static inline int ts_lexer_is_done(const TSLexer *lexer) {
|
||||
return lexer->chunk_size == 0 && lexer->position_in_chunk > 0;
|
||||
}
|
||||
|
||||
typedef unsigned short TSStateId;
|
||||
|
||||
typedef enum {
|
||||
|
|
@ -108,8 +111,11 @@ struct TSLanguage {
|
|||
#define ADVANCE(state_index) \
|
||||
{ \
|
||||
DEBUG_LEX("ADVANCE %d", state_index); \
|
||||
if (!ts_lexer_advance(lexer)) \
|
||||
ACCEPT_TOKEN(ts_builtin_sym_end); \
|
||||
if (ts_lexer_is_done(lexer)) { \
|
||||
DEBUG_LEX("END_OF_INPUT"); \
|
||||
return NULL; \
|
||||
} \
|
||||
ts_lexer_advance(lexer); \
|
||||
lex_state = state_index; \
|
||||
goto next_state; \
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue