summaryrefslogtreecommitdiff
path: root/lex.c
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2019-04-14 20:05:44 +1200
committerDavid Phillips <david@sighup.nz>2019-08-03 12:43:46 +1200
commit3bf3b2a80ef21ac1ac2e43d07b1680432d66cbaf (patch)
treee4c3a4ce3d9646f9d78282a0cf8bb4a4cce2575d /lex.c
parente5eeded02a4abe2729e675203437c79d9ee71a7a (diff)
downloadtoy-cpu-assembler-3bf3b2a80ef21ac1ac2e43d07b1680432d66cbaf.tar.xz
Remove superfluous printfs, factor reg table lookup
Diffstat (limited to 'lex.c')
-rw-r--r--lex.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lex.c b/lex.c
index 47beb01..41b65c5 100644
--- a/lex.c
+++ b/lex.c
@@ -50,7 +50,6 @@ static int add_token(struct token t) {
}
tokens[tokens_count - 1] = t;
-// printf("Adding token from (%d,%d ~%d), str %s int %d\n", t.line, t.column, t.span, t.s_val, t.i_val);
return 0;
}
@@ -81,7 +80,8 @@ static int lex_register(struct token *t) {
;
}
- t->s_val = strndup(&buffer[column], i - column);
+ /* -1, +1 to include $ */
+ t->s_val = strndup(&buffer[column - 1], i - column + 1);
if (!t->s_val) {
perror("strndup");
return 1;