From bfb692d2f7ca64fe6943e4b8454cc133b49a0977 Mon Sep 17 00:00:00 2001 From: Andrew Helwer Date: Fri, 7 Jan 2022 10:16:20 -0500 Subject: [PATCH] Improve diff --- lib/src/lexer.c | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/lib/src/lexer.c b/lib/src/lexer.c index e72297fe..b90bba1b 100644 --- a/lib/src/lexer.c +++ b/lib/src/lexer.c @@ -152,6 +152,27 @@ static void ts_lexer_goto(Lexer *self, Length position) { } } +// Advance to the next character in the source code, retrieving a new +// chunk of source code if needed. +static void ts_lexer__advance(TSLexer *_self, bool skip) { + Lexer *self = (Lexer *)_self; + if (!self->chunk) return; + + if (skip) { + LOG("skip", self->data.lookahead); + } else { + LOG("consume", self->data.lookahead); + } + + ts_lexer__do_advance(self, skip); +} + +// Advance without logging. +static void ts_lexer__advance_no_log(Lexer *self, bool skip) { + if (!self->chunk) return; + ts_lexer__do_advance(self, skip); +} + // Intended to be called only from functions below that control logging. static void ts_lexer__do_advance(Lexer *self, bool skip) { if (self->lookahead_size) { @@ -195,27 +216,6 @@ static void ts_lexer__do_advance(Lexer *self, bool skip) { } } -// Advance to the next character in the source code, retrieving a new -// chunk of source code if needed. -static void ts_lexer__advance(TSLexer *_self, bool skip) { - Lexer *self = (Lexer *)_self; - if (!self->chunk) return; - - if (skip) { - LOG("skip", self->data.lookahead); - } else { - LOG("consume", self->data.lookahead); - } - - ts_lexer__do_advance(self, skip); -} - -// Advance without logging. -static void ts_lexer__advance_no_log(Lexer *self, bool skip) { - if (!self->chunk) return; - ts_lexer__do_advance(self, skip); -} - // Mark that a token match has completed. This can be called multiple // times if a longer match is found later. static void ts_lexer__mark_end(TSLexer *_self) { @@ -265,7 +265,6 @@ static uint32_t ts_lexer__get_column(TSLexer *_self) { return result; } - // Is the lexer at a boundary between two disjoint included ranges of // source code? This is exposed as an API because some languages' external // scanners need to perform custom actions at these boundaries.