From ea75f19804b202fbaf0fc41da519305d49d79d03 Mon Sep 17 00:00:00 2001 From: tocariimaa Date: Sun, 19 Jan 2025 19:32:01 -0300 Subject: [PATCH] move expression to func --- compiler/lex.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/compiler/lex.c b/compiler/lex.c index 6c29b46..40f63d9 100644 --- a/compiler/lex.c +++ b/compiler/lex.c @@ -121,6 +121,14 @@ peek(LexState *ls) return *ls->fwd; } +/* Moves the forward pointer and the column count by one */ +static void +next(LexState *ls) +{ + ++ls->fwd; + ++ls->cur_loc.column; +} + static void backup(LexState *ls, int n) { @@ -460,8 +468,7 @@ lex_scan(LexState *ls) case '!': if (peek(ls) == '=') { token.id = T_NOTEQUAL; - ++ls->fwd; - ++ls->cur_loc.column; + next(ls); } else { token.id = T_EXCLAMATION; } @@ -485,8 +492,7 @@ lex_scan(LexState *ls) case '=': if (peek(ls) == '=') { token.id = T_LOGICEQUAL; - ++ls->fwd; - ++ls->cur_loc.column; + next(ls); } else { token.id = T_EQUAL; }