Don't log when counting codepoints
@@ -152,18 +152,8 @@ 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);
- }
-
+// 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) {
self->current_position.bytes += self->lookahead_size;
if (self->data.lookahead == '\n') {
@@ -205,6 +195,27 @@ static void ts_lexer__advance(TSLexer *_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) {
@@ -247,7 +258,7 @@ static uint32_t ts_lexer__get_column(TSLexer *_self) {
uint32_t result = 0;
ts_lexer__get_lookahead(self);
while (self->current_position.bytes < goal_byte && !ts_lexer__eof(_self)) {
- ts_lexer__advance(_self, false);
+ ts_lexer__advance_no_log(self, false);
result++;
}
