struct ulas_expr {
enum ulas_exprs type;
union ulas_expval val;
+ // link to the next expression, 0 indicates
+ // there is no next expression
+ long next;
+};
+
+struct ulas_exprbuf {
+ struct ulas_expr *exprs;
+ unsigned long len;
+ unsigned long maxlen;
};
/**
int tokrc = 0;
while ((tokrc = ulas_tok(&ulas.tok, line, n) > 0)) {
if (tokrc == -1) {
- goto fail;
+ goto end;
}
// interpret the token
struct ulas_tok tok = ulas_totok(
ulas.tok.buf, strnlen(ulas.tok.buf, ulas.tok.maxlen), &tokrc);
if (tokrc == -1) {
- goto fail;
+ goto end;
+ }
+
+ // check for any expression terminators here
+ if (tok.type == ',') {
+ goto end;
}
// now we can loop token type, add all tokens to the token buffer
ulas_tokbufpush(&ulas.toks, tok);
}
-fail:
+end:
return tokrc;
}
+// parses tokens to expression tree
+int ulas_parseexpr(struct ulas_tokbuf *toks) {
+ int rc = 0;
+ for (long i = 0; i < toks->len; i++) {
+ }
+
+fail:
+ return rc;
+}
+
int ulas_intexpr(const char **line, unsigned long n, int *rc) {
if (ulas_tokexpr(line, n) == -1) {
*rc = -1;
return -1;
}
- // now that we have all tokens in the buffer, create the tree strucute
+ if (ulas_parseexpr(&ulas.toks) == -1) {
+ *rc = -1;
+ return -1;
+ }
+
+ // execute the tree of expressions
return -1;
}