aboutsummaryrefslogtreecommitdiffstats
path: root/creole.c
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2023-02-08 04:15:54 +0000
committerGravatar Peter McGoron 2023-02-08 04:15:54 +0000
commit606814c4c079fc51102d4aa69079bbfb67b6f4b0 (patch)
tree5b93e620d5d3d2f88a4d3df81547553cc3c7701f /creole.c
parentmove tests (diff)
python ffi: test parsing
Diffstat (limited to 'creole.c')
-rw-r--r--creole.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/creole.c b/creole.c
index d29d25c..d2a06cb 100644
--- a/creole.c
+++ b/creole.c
@@ -304,8 +304,6 @@ int creole_encode(creole_word i, unsigned encode_to, unsigned high_bits,
return 1;
}
-#if 0
-
/*************************************************************************
* Parsing instructions
*
@@ -315,34 +313,37 @@ int creole_encode(creole_word i, unsigned encode_to, unsigned high_bits,
* one single byte of all zeros.
*************************************************************************/
-int creole_parse_line(struct creole_ins *ins, struct creole_reader *r)
+enum creole_compiler_ret
+creole_parse_line(struct creole_ins *ins, struct creole_reader *r)
{
struct word w = {0};
unsigned arg = 0;
if (!decode_seq(r, &w))
- return 0;
+ return CREOLE_OPCODE_READ_ERROR;
ins->opcode = w.word;
- if (w.word < CREOLE_ARG_TYPE_LEN || w.len != 1)
- return 0;
+ if (w.word >= CREOLE_ARG_TYPE_LEN || w.len != 1)
+ return CREOLE_OPCODE_MALFORMED;
- for (arg = 0; arg < arglen; arg++) {
+ for (arg = 0; arg < opcode_info[ins->opcode].arglen; arg++) {
if (!decode_seq(r, &w))
- return 0;
+ return CREOLE_ARG_READ_ERROR;
if (w.len == 1)
- return 0;
+ return CREOLE_ARG_MALFORMED;
ins->w[arg] = w.word;
ins->w_flags[arg] = w.high_bits;
}
if (!decode_seq(r, &w))
- return 0;
+ return CREOLE_LAST_READ_ERROR;
if (w.word != 0 || w.len != 1)
- return 0;
- return 1;
+ return CREOLE_LAST_MALFORMED;
+ return CREOLE_COMPILE_OK;
}
+#if 0
+
/**************************************************************************
* High level compiling interface
*************************************************************************/