Przeglądaj źródła

Re-generate parser with latest tree-sitter

pull/2/head
Max Brunsfeld 9 lat temu
rodzic
commit
b8726858d4
2 zmienionych plików z 10 dodań i 32 usunięć
  1. +1
    -1
      src/parser.c
  2. +9
    -31
      src/tree_sitter/parser.h

+ 1
- 1
src/parser.c Wyświetl plik

@ -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:

+ 9
- 31
src/tree_sitter/parser.h Wyświetl plik

@ -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

Ładowanie…
Anuluj
Zapisz