commit f593d304d58e54765e22853fb8296e275da19930
parent c5981f652f6e524c8b3520015410052efa95eaf4
Author: Nihal Jere <nihal@nihaljere.xyz>
Date: Tue, 7 Dec 2021 23:48:29 -0600
fix line/col marking
ADVANCE is called everytime a char is read for a name, so the
location would end up being at the end of the token.
Diffstat:
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/main.c b/main.c
@@ -24,8 +24,6 @@ struct exprs exprs;
char *infile;
#define ADVANCE(n) \
- cur->line = line ; \
- cur->col = line ; \
start.data += (n) ; \
start.len -= (n) ; \
col += (n) ;
@@ -53,6 +51,9 @@ lex(struct slice start)
continue;
}
+ cur->line = line;
+ cur->col = col;
+
if (slice_cmplit(&start, "if") == 0) {
cur->type = TOK_IF;
ADVANCE(2);