diff --git a/src/parser.c b/src/parser.c index c0ab7ff..8b3ef25 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1387,7 +1387,7 @@ static const TSSymbolMetadata ts_symbol_metadata[SYMBOL_COUNT] = { }, }; -static bool ts_lex(TSLexer *lexer, TSStateId state, bool error_mode) { +static bool ts_lex(TSLexer *lexer, TSStateId state) { START_LEXER(); switch (state) { case 0: diff --git a/src/tree_sitter/parser.h b/src/tree_sitter/parser.h index 7b59e14..5d89efc 100644 --- a/src/tree_sitter/parser.h +++ b/src/tree_sitter/parser.h @@ -28,19 +28,11 @@ typedef struct { bool structural : 1; } TSSymbolMetadata; -typedef enum { - TSTransitionTypeMain, - TSTransitionTypeSeparator, - TSTransitionTypeError, -} TSTransitionType; - typedef struct TSLexer { - void (*advance)(struct TSLexer *, TSStateId, TSTransitionType); + void (*advance)(struct TSLexer *, TSStateId, bool); TSLength current_position; - TSLength token_end_position; TSLength token_start_position; - TSLength error_end_position; const char *chunk; size_t chunk_start; @@ -48,10 +40,7 @@ typedef struct TSLexer { size_t lookahead_size; int32_t lookahead; - TSStateId starting_state; TSSymbol result_symbol; - bool result_follows_error; - int32_t first_unexpected_character; TSInput input; TSDebugger debugger; @@ -94,7 +83,7 @@ struct TSLanguage { const unsigned short *parse_table; const TSParseActionEntry *parse_actions; const TSStateId *lex_states; - bool (*lex_fn)(TSLexer *, TSStateId, bool); + bool (*lex_fn)(TSLexer *, TSStateId); }; /* @@ -106,22 +95,18 @@ struct TSLanguage { next_state: \ lookahead = lexer->lookahead; -#define GO_TO_STATE(state_value) \ - { \ - state = state_value; \ - goto next_state; \ - } - #define ADVANCE(state_value) \ { \ - lexer->advance(lexer, state_value, TSTransitionTypeMain); \ - GO_TO_STATE(state_value); \ + lexer->advance(lexer, state_value, false); \ + state = state_value; \ + goto next_state; \ } #define SKIP(state_value) \ { \ - lexer->advance(lexer, state_value, TSTransitionTypeSeparator); \ - GO_TO_STATE(state_value); \ + lexer->advance(lexer, state_value, true); \ + state = state_value; \ + goto next_state; \ } #define ACCEPT_TOKEN(symbol_value) \ @@ -130,14 +115,7 @@ struct TSLanguage { return true; \ } -#define LEX_ERROR() \ - if (error_mode) { \ - if (state == TS_STATE_ERROR) \ - lexer->advance(lexer, state, TSTransitionTypeError); \ - GO_TO_STATE(TS_STATE_ERROR); \ - } else { \ - return false; \ - } +#define LEX_ERROR() return false /* * Parse Table Macros