aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorc+12023-05-15 12:53:25 -0400
committerc+12023-05-15 12:53:25 -0400
commitc6c396ad67ab2413d068ffb25d96a5b0a0ba17ef (patch)
tree63f9b07ca84f45459dfaa465e51a91aab822d487 /src
parentd03956f54d15f4904cfa10be96bbdf11d49a68f0 (diff)
things
Diffstat (limited to 'src')
-rw-r--r--src/include/lexer.h3
-rw-r--r--src/lexer.c15
2 files changed, 17 insertions, 1 deletions
diff --git a/src/include/lexer.h b/src/include/lexer.h
index cc96216..3d3b916 100644
--- a/src/include/lexer.h
+++ b/src/include/lexer.h
@@ -21,9 +21,10 @@ extern token_t* lexer_get_next_token(lexer_t* lexer);
extern token_t* lexer_get_string(lexer_t* lexer);
extern token_t* lexer_get_def_const(lexer_t* lexer);
-
extern token_t* lexer_get_def_mut(lexer_t* lexer);
+extern token_t* lexer_get_def_var(lexer_t* lexer);
+
extern token_t* lexer_get_comment(lexer_t* lexer);
extern token_t* lexer_get_directive(lexer_t* lexer);
diff --git a/src/lexer.c b/src/lexer.c
index b61f750..74cc298 100644
--- a/src/lexer.c
+++ b/src/lexer.c
@@ -180,6 +180,20 @@ token_t* lexer_get_def_const(lexer_t* lexer) {
lexer_next(lexer);
return token_init(TOKEN_DEFINE_CONST, "=>");
} else {
+ fputs("Unknown variable state.", stderr);
+ exit(1);
+ }
+}
+
+token_t* lexer_get_def_var(lexer_t* lexer) {
+ lexer_pass(lexer);
+
+ if (lexer_next(lexer), lexer->c == '=') {
+ return lexer_get_def_const(lexer);
+ } else if (lexer_next(lexer), lexer->c == '-') {
+ return lexer_get_def_mut(lexer);
+ } else {
+ fputs("Unknown variable state.", stderr);
exit(1);
}
}
@@ -191,6 +205,7 @@ token_t* lexer_get_def_mut(lexer_t* lexer) {
lexer_next(lexer);
return token_init(TOKEN_DEFINE_MUT, "->");
} else {
+ fputs("Unknown variable state.", stderr);
exit(1);
}
}