commit 822a362cbf23c22df832f30672531fb3bd7adcc3 parent c0ce468e1f980dd5bd183993e9582dc8ff66c3a1 Author: Nihal Jere <nihal@nihaljere.xyz> Date: Mon, 1 Nov 2021 23:54:21 -0500 handle whitespace Diffstat:
M | main.c | | | 6 | +++++- |
M | prog.nc | | | 4 | ++-- |
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/main.c b/main.c @@ -97,7 +97,11 @@ lex(struct slice start) struct token *cur = head; while (start.len) { - if (strncmp(start.ptr, "exit", sizeof("exit") - 1) == 0) { + if (isblank(*start.ptr)) { + start.ptr += 1; + start.len -= 1; + continue; + } else if (strncmp(start.ptr, "exit", sizeof("exit") - 1) == 0) { cur->type = TOK_EXIT; start.ptr += 4; start.len -= 4; diff --git a/prog.nc b/prog.nc @@ -1 +1 @@ -exit(12)- \ No newline at end of file + exit( 23 )+ \ No newline at end of file