Don't create error node in lexer unless token is completely invalid
Before, any syntax error would cause the lexer to create an error leaf node. This could happen even with a valid input, if the parse stack had split and one particular version of the parse stack failed to parse. Now, an error leaf node is only created when the lexer cannot understand part of the input stream at all. When a normal syntax error occurs, the lexer just returns a token that is outside of the expected token set, and the parser handles the unexpected token.
This commit is contained in:
parent
7c859a07bb
commit
1e353381ff
13 changed files with 225 additions and 148 deletions
|
|
@ -7,9 +7,19 @@ extern "C" {
|
|||
|
||||
#include "tree_sitter/parser.h"
|
||||
|
||||
typedef struct {
|
||||
TSSymbol symbol;
|
||||
TSLength padding;
|
||||
TSLength size;
|
||||
bool is_fragile;
|
||||
int32_t first_unexpected_character;
|
||||
} TSLexerResult;
|
||||
|
||||
void ts_lexer_init(TSLexer *);
|
||||
void ts_lexer_set_input(TSLexer *, TSInput);
|
||||
void ts_lexer_reset(TSLexer *, TSLength);
|
||||
void ts_lexer_start(TSLexer *, TSStateId);
|
||||
void ts_lexer_finish(TSLexer *, TSLexerResult *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue