summaryrefslogtreecommitdiff
path: root/lexer.c
diff options
context:
space:
mode:
Diffstat (limited to 'lexer.c')
-rw-r--r--lexer.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/lexer.c b/lexer.c
index e45f949..ff63bff 100644
--- a/lexer.c
+++ b/lexer.c
@@ -31,7 +31,7 @@ static unsigned int one_wide_tok(const char *s)
case ',': return TOK_COMMA;
case '<': return TOK_COMP_LESS;
case '%': return TOK_MODULO;
- case '*': return TOK_STAR;
+ case '*': return TOK_MULT;
default: return TOK_NONE;
}
}
@@ -43,6 +43,10 @@ static unsigned int two_wide_tok(const char *s)
case PAIR('=', '='): return TOK_COMP_EQ;
case PAIR('!', '='): return TOK_COMP_NEQ;
case PAIR('/', '/'): return TOK_COMMENT;
+ case PAIR('<', '='): return TOK_COMP_LESSEQ;
+ case PAIR('>', '='): return TOK_COMP_MOREEQ;
+ case PAIR('|', '|'): return TOK_COMP_OR;
+ case PAIR('&', '&'): return TOK_COMP_AND;
default: return TOK_NONE;
}
}
@@ -109,6 +113,12 @@ Token *lexer(const char *s)
toks[tok_i].type = TOK_KW_VAR;
else if (strcmp("const", toks[tok_i].s) == 0)
toks[tok_i].type = TOK_KW_CONST;
+ else if (strcmp("if", toks[tok_i].s) == 0)
+ toks[tok_i].type = TOK_KW_IF;
+ else if (strcmp("else", toks[tok_i].s) == 0)
+ toks[tok_i].type = TOK_KW_ELSE;
+ else if (strcmp("while", toks[tok_i].s) == 0)
+ toks[tok_i].type = TOK_KW_WHILE;
else
toks[tok_i].type = TOK_WORD;
tok_i += 1;