Add source info to TSLexer

This commit is contained in:
joshvera 2015-11-12 12:24:05 -05:00
parent d6f87fbb6b
commit e720922662
3 changed files with 15 additions and 0 deletions

View file

@ -38,6 +38,10 @@ typedef struct TSLexer {
TSLength token_end_position;
TSLength token_start_position;
TSSourceInfo current_source_info;
TSSourceInfo token_end_source_info;
TSSourceInfo token_start_source_info;
size_t lookahead_size;
int32_t lookahead;

View file

@ -35,9 +35,16 @@ typedef struct {
size_t chars_removed;
} TSInputEdit;
typedef struct {
size_t line;
size_t column;
} TSSourceInfo;
typedef struct {
const void *data;
TSLength offset;
TSSourceInfo start;
TSSourceInfo end;
} TSNode;
typedef unsigned short TSSymbol;

View file

@ -53,6 +53,10 @@ static void ts_lexer__start(TSLexer *self, TSStateId lex_state) {
static void ts_lexer__start_token(TSLexer *self) {
DEBUG("start_token chars:%lu", self->current_position.chars);
self->token_start_position = self->current_position;
DEBUG("start_token line:%lu", self->current_source_info.line);
DEBUG("start_token column:%lu", self->current_source_info.column);
self->token_start_source_info = self->current_source_info;
}
static bool ts_lexer__advance(TSLexer *self, TSStateId state) {