summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter <peter@pmikkelsen.com>2026-08-22 17:25:54 +0000
committerpeter <peter@pmikkelsen.com>2026-08-22 17:25:54 +0000
commitdc9b7f961d1c5f39a07085c9dbad8d94bbacde70 (patch)
tree5f22d024bfc2d8813947c1f1700114df9e01a287
parentefe230205f254fc5369b53d3de2841723beb6ff8 (diff)
Small set of changes to make the tests pass - meaning the scanner understands the code, not much else
FossilOrigin-Name: d21c4a18581a61da466c0fbfdf73881bec55ea01091ef67abda1d10e17f8d358
-rw-r--r--src/lib/aplwc_internal.h10
-rw-r--r--src/lib/eval.c16
-rw-r--r--src/lib/syntax.c15
-rwxr-xr-xtools/check2
4 files changed, 33 insertions, 10 deletions
diff --git a/src/lib/aplwc_internal.h b/src/lib/aplwc_internal.h
index 4ad30f8..33feafb 100644
--- a/src/lib/aplwc_internal.h
+++ b/src/lib/aplwc_internal.h
@@ -3,11 +3,6 @@
#include <aplwc.h>
#include <aplwc_macros.h>
-
-#define RETURN_ERROR(aplwcp, rc, msg) do{ \
- return ((aplwc)->last_error = (rc)); \
- }while(0)
-
#include <assert.h>
#include <stdalign.h>
#include <stdbool.h>
@@ -39,7 +34,9 @@ struct string {
enum token_tag {
TOKEN_TAG_IDENTIFIER,
TOKEN_TAG_NEWLINE,
- TOKEN_TAG_NUMBER
+ TOKEN_TAG_NUMBER,
+ TOKEN_TAG_LEFT_ARROW,
+ TOKEN_TAG_DIAMOND
};
struct token {
@@ -54,6 +51,7 @@ struct token_list {
};
enum value_tag {
+ VALUE_NULL,
VALUE_NUMBER
};
diff --git a/src/lib/eval.c b/src/lib/eval.c
index 07bbedd..f0cdc55 100644
--- a/src/lib/eval.c
+++ b/src/lib/eval.c
@@ -3,7 +3,17 @@
struct aplwc_value *
eval_line(struct aplwc_line *line)
{
- assert(line->aplwc->last_error == APLWC_OK);
- line->aplwc->last_error = APLWC_NOT_YET_IMPLEMENTED;
- return NULL;
+ struct aplwc_value *value;
+ struct aplwc *aplwc;
+
+ aplwc = line->aplwc;
+ assert(aplwc->last_error == APLWC_OK);
+
+ value = memory_alloc_aplwc_value(&aplwc->memory);
+ if(value == NULL)
+ aplwc->last_error = APLWC_OUT_OF_MEMORY;
+ value->aplwc = aplwc;
+ value->tag = VALUE_NULL;
+
+ return value;
}
diff --git a/src/lib/syntax.c b/src/lib/syntax.c
index 6b1d0cd..c3452f2 100644
--- a/src/lib/syntax.c
+++ b/src/lib/syntax.c
@@ -53,6 +53,20 @@ skip_space(struct scan_state *state)
advance(state);
}
+static int
+single_sym(struct scan_state *state, struct token *token)
+{
+ switch(peek(state)){
+ case 0x2190: token->tag = TOKEN_TAG_LEFT_ARROW; break;
+ case 0x22C4: token->tag = TOKEN_TAG_DIAMOND; break;
+ default:
+ return 0;
+ }
+
+ advance(state);
+ return 1;
+}
+
static int
identifier(struct scan_state *state, struct token *token)
{
@@ -127,6 +141,7 @@ next_token(struct scan_state *state, struct token *token)
{
size_t i;
int (*scans[])(struct scan_state *, struct token *token) = {
+ single_sym,
identifier,
number,
newline
diff --git a/tools/check b/tools/check
index 3a8c822..717746d 100755
--- a/tools/check
+++ b/tools/check
@@ -10,7 +10,7 @@ cd build
for type in $types
do
rm -rf $type
- cmake .. -B $type -DCMAKE_BUILD_TYPE=$type
+ cmake .. -G Ninja -B $type -DCMAKE_BUILD_TYPE=$type
done
cd ..