aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorc2024-03-18 21:27:42 -0400
committerc2024-03-18 21:27:42 -0400
commit53d5c419bdfaa58c2cf7c30e51e4515f66fa85a1 (patch)
treea3c7ac2a0eb999a7a2770268df356c780e278161
parentaaf2ae7693e2b48358f7d3007aca9f0cb5f4950f (diff)
Fixed bugs.
Keywords with numbers in them were being read as lints, forgot to add numbers to allowed chars somehow.
-rw-r--r--src/doer.c6
-rw-r--r--src/include/doer.h10
-rw-r--r--src/include/syntax.h2
-rw-r--r--src/lexer.c6
4 files changed, 13 insertions, 11 deletions
diff --git a/src/doer.c b/src/doer.c
index 8e11e6e..ab1ca4d 100644
--- a/src/doer.c
+++ b/src/doer.c
@@ -87,7 +87,7 @@ char* doer_eval_str(doer_t* doer) {
}
void blin_die(doer_t* doer) {
- DIE(":(\nYour PC ran into a\n");
+ exit(1);
}
void blin_print(doer_t* doer) {
@@ -108,6 +108,10 @@ void blin_printl(doer_t* doer) {
);
}
+void blin_to_str(doer_t* doer) {
+ // TODO
+}
+
void doer_do_block(doer_t* doer) {
if (!doer->tree) return;
diff --git a/src/include/doer.h b/src/include/doer.h
index 314edc3..641abed 100644
--- a/src/include/doer.h
+++ b/src/include/doer.h
@@ -56,13 +56,16 @@ char* doer_eval_str(doer_t* doer);
// `die`: dies. Does not accept any arguments, returns int (if a tree falls in
// the forest, but it burns down before anyone can hear it, did it ever make a
// sound at all?) TODO: Make this actually clean up afterwards.
-void blin_die(doer_t* tree);
+void blin_die(doer_t* doer);
// `print`: print a string.
-void blin_print(doer_t* tree);
+void blin_print(doer_t* doer);
static tree_type_t blin_print_args[] = { TREE_TYPE_LSTR };
// `printl`: print a string, and add a newline.
-void blin_printl(doer_t* tree);
+void blin_printl(doer_t* doer);
static tree_type_t blin_printl_args[] = { TREE_TYPE_LSTR };
+// `to_str`: convert any (primitive) type to a string.
+void blin_to_str(doer_t* doer);
+static tree_type_t blin_to_str_args[] = { TREE_TYPE_CALL };
void doer_do_block(doer_t* tree);
void doer_do_expr(doer_t* tree);
@@ -78,6 +81,7 @@ static blinf_t blinfs[] = {
{ blin_die, TREE_TYPE_LINT, NULL, "die" },
{ blin_print, TREE_TYPE_LSTR, blin_print_args, "print" },
{ blin_printl, TREE_TYPE_LSTR, blin_printl_args, "printl" },
+ { blin_to_str, TREE_TYPE_LSTR, blin_to_str_args, "to_str" },
};
#endif
diff --git a/src/include/syntax.h b/src/include/syntax.h
index 2938178..2645ca4 100644
--- a/src/include/syntax.h
+++ b/src/include/syntax.h
@@ -22,6 +22,6 @@
#define SYNTAX_ESC '\\'
/* Characters that can appear in keywords. */
-#define SYNTAX_KWD_CHARS "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_~|&+-/*<>=%^$@?"
+#define SYNTAX_KWD_CHARS "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_~|&+-/*<>=%^$@?0123456789"
#endif
diff --git a/src/lexer.c b/src/lexer.c
index 4ad8fd6..aa068a9 100644
--- a/src/lexer.c
+++ b/src/lexer.c
@@ -7,12 +7,6 @@
#include "include/syntax.h"
#include "include/token.h"
-/*
-
- TODO: Fix bug where calls ending with numbers get interpreted as lints.
-
-*/
-
lexer_t* lexer_init(char* src) {
lexer_t* lexer;