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; }