From 2b03202a30e9da09bfc5c0d382b1f5d2287287a4 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Sun, 9 Aug 2020 17:52:46 -0400 Subject: Added the bitwise OR, left shift, and right shift expressions to the emulator's assembler. --- lexer.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'lexer.c') diff --git a/lexer.c b/lexer.c index 0540498..699589c 100644 --- a/lexer.c +++ b/lexer.c @@ -241,6 +241,10 @@ uint64_t lex(char *str, uint64_t address, uint8_t dbg) { l->tok = NULL; l->next = NULL; l->count = 0; + l->espace = 0; + l->etab = 0; + l->sspace = 0; + l->stab = 0; last_line = l; } @@ -422,17 +426,22 @@ uint64_t lex(char *str, uint64_t address, uint8_t dbg) { case PTOK_MINUS: case PTOK_GT: case PTOK_LT: + case PTOK_PIPE: lex_type = TOK_EXPR; switch (ptok) { case PTOK_PLUS : value = EXPR_PLUS ; break; case PTOK_MINUS: value = EXPR_MINUS; break; - case PTOK_GT : value = EXPR_LOW ; break; - case PTOK_LT : value = EXPR_HIGH ; break; + case PTOK_PIPE : value = EXPR_OR ; break; + case PTOK_GT : value = (get_ptok(str[i+1], dbg) == PTOK_GT) ? (EXPR_RSHFT) : (EXPR_LOW) ; break; + case PTOK_LT : value = (get_ptok(str[i+1], dbg) == PTOK_LT) ? (EXPR_LSHFT) : (EXPR_HIGH); break; } l->count++; t = make_token(lex_type, value, 0, "", NULL); memset(lexeme, 0, strlen(lexeme)+1); lexeme[j++] = str[i]; + if (value == EXPR_LSHFT || value == EXPR_RSHFT) { + lexeme[j++] = str[++i]; + } break; case PTOK_EQU: i++; -- cgit v1.2.3-13-gbd6f