summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2019-08-29 15:50:19 -0400
committerLeo Tenenbaum <pommicket@gmail.com>2019-08-29 15:50:19 -0400
commit7c790561cca382660081dfae3a6fe50fc31ad2a5 (patch)
tree06888e0b652cbac60abaad82e27b52a5daaeaf62 /eval.c
parent1dea1f4703b4ec0a990c2b9f6ecc81b99fed6112 (diff)
Added fixed-size arrays
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/eval.c b/eval.c
new file mode 100644
index 0000000..8cb3303
--- /dev/null
+++ b/eval.c
@@ -0,0 +1,25 @@
+static bool eval_expr_as_float(Expression *e, FloatLiteral *f) {
+ switch (e->kind) {
+ case EXPR_FLOAT_LITERAL:
+ *f = e->floatl;
+ return true;
+ case EXPR_INT_LITERAL:
+ *f = (FloatLiteral)e->intl;
+ return true;
+ }
+ err_print(e->where, "Not implemented yet");
+ return false;
+}
+
+static bool eval_expr_as_int(Expression *e, IntLiteral *i) {
+ switch (e->kind) {
+ case EXPR_FLOAT_LITERAL:
+ err_print(e->where, "Expected integer, but found floating-point literal.");
+ return false;
+ case EXPR_INT_LITERAL:
+ *i = e->intl;
+ return true;
+ }
+ err_print(e->where, "Not implemented yet");
+ return false;
+}