nooc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/nooc
Log | Files | Refs | LICENSE

commit 015242dbbd45b0fa2b8116bec7da08e4ed24ba9f
parent d956d9b4e938adff3a959c4ab2d45cfdd323c7d6
Author: Nihal Jere <nihal@nihaljere.xyz>
Date:   Tue, 16 Nov 2021 23:13:16 -0600

add name and = token

Diffstat:
Mmain.c | 17++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/main.c b/main.c @@ -76,6 +76,7 @@ elf(char *text, size_t len, char* data, size_t dlen, FILE *f) enum tokentype { TOK_NONE = 0, TOK_SYSCALL = 1, + TOK_NAME, TOK_LPAREN, TOK_RPAREN, @@ -83,6 +84,7 @@ enum tokentype { TOK_PLUS, TOK_COMMA, + TOK_EQUAL, TOK_NUM, TOK_STRING, @@ -150,7 +152,6 @@ lex(struct slice start) start.ptr++; start.len--; cur->slice.ptr = start.ptr; - cur->slice.len = 0; cur->type = TOK_STRING; while (*start.ptr != '"') { start.ptr++; @@ -168,6 +169,20 @@ lex(struct slice start) cur->type = TOK_PLUS; start.ptr++; start.len--; + } else if (*start.ptr == '=') { + cur->type = TOK_EQUAL; + start.ptr++; + start.len--; + } else if (isalpha(*start.ptr)) { + cur->type = TOK_NAME; + start.ptr++; + start.len--; + cur->slice.ptr = start.ptr; + while (isalnum(*start.ptr)) { + start.ptr++; + start.len--; + cur->slice.len++; + } } else { error("invalid token"); }