Pass row/column position to input seek method
This commit is contained in:
parent
8b70cb85f7
commit
facafcd6e4
5 changed files with 10 additions and 10 deletions
|
|
@ -26,10 +26,15 @@ typedef enum {
|
|||
TSSymbolTypeAuxiliary,
|
||||
} TSSymbolType;
|
||||
|
||||
typedef struct {
|
||||
uint32_t row;
|
||||
uint32_t column;
|
||||
} TSPoint;
|
||||
|
||||
typedef struct {
|
||||
void *payload;
|
||||
const char *(*read)(void *payload, uint32_t *bytes_read);
|
||||
int (*seek)(void *payload, uint32_t byte_index);
|
||||
int (*seek)(void *payload, uint32_t byte_index, TSPoint position);
|
||||
TSInputEncoding encoding;
|
||||
} TSInput;
|
||||
|
||||
|
|
@ -43,11 +48,6 @@ typedef struct {
|
|||
void (*log)(void *payload, TSLogType, const char *);
|
||||
} TSLogger;
|
||||
|
||||
typedef struct {
|
||||
uint32_t row;
|
||||
uint32_t column;
|
||||
} TSPoint;
|
||||
|
||||
typedef struct {
|
||||
uint32_t start_byte;
|
||||
uint32_t bytes_removed;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ static void ts_lexer__get_chunk(Lexer *self) {
|
|||
TSInput input = self->input;
|
||||
if (!self->chunk ||
|
||||
self->current_position.bytes != self->chunk_start + self->chunk_size) {
|
||||
input.seek(input.payload, self->current_position.bytes);
|
||||
input.seek(input.payload, self->current_position.bytes, self->current_position.extent);
|
||||
}
|
||||
|
||||
self->chunk_start = self->current_position.bytes;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ static const char *ts_string_input__read(void *payload, uint32_t *bytes_read) {
|
|||
return input->string + previous_position;
|
||||
}
|
||||
|
||||
static int ts_string_input__seek(void *payload, uint32_t byte) {
|
||||
static int ts_string_input__seek(void *payload, uint32_t byte, TSPoint _) {
|
||||
TSStringInput *input = (TSStringInput *)payload;
|
||||
input->position = byte;
|
||||
return (byte < input->length);
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ const char * SpyInput::read(void *payload, uint32_t *bytes_read) {
|
|||
return spy->buffer;
|
||||
}
|
||||
|
||||
int SpyInput::seek(void *payload, uint32_t byte) {
|
||||
int SpyInput::seek(void *payload, uint32_t byte, TSPoint position) {
|
||||
auto spy = static_cast<SpyInput *>(payload);
|
||||
spy->byte_offset = byte;
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class SpyInput {
|
|||
std::vector<SpyInputEdit> undo_stack;
|
||||
|
||||
static const char * read(void *, uint32_t *);
|
||||
static int seek(void *, uint32_t);
|
||||
static int seek(void *, uint32_t, TSPoint);
|
||||
std::pair<std::string, TSPoint> swap_substr(size_t, size_t, std::string);
|
||||
|
||||
public:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue