aboutsummaryrefslogtreecommitdiffstats
path: root/src/mds-kbdc/make-tree.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-11-13 21:12:42 +0100
committerMattias Andrée <maandree@operamail.com>2014-11-13 21:12:42 +0100
commit7809256dfbc417c8a0a9ddc732dd54294a0cff99 (patch)
tree9ebc5498f875ba55fa202f550e7975dfe54c207c /src/mds-kbdc/make-tree.c
parentm (diff)
downloadmds-7809256dfbc417c8a0a9ddc732dd54294a0cff99.tar.gz
mds-7809256dfbc417c8a0a9ddc732dd54294a0cff99.tar.bz2
mds-7809256dfbc417c8a0a9ddc732dd54294a0cff99.tar.xz
parse let statement, however not arrays yet
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/mds-kbdc/make-tree.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/mds-kbdc/make-tree.c b/src/mds-kbdc/make-tree.c
index 1ed742d..b34b358 100644
--- a/src/mds-kbdc/make-tree.c
+++ b/src/mds-kbdc/make-tree.c
@@ -260,7 +260,7 @@
/**
* Test that there are no more parameters
*/
-#define END \
+#define END \
while (*line && (*line == ' ')) \
line++; \
do \
@@ -269,7 +269,7 @@
NEW_ERROR(1, ERROR, "too many parameters"); \
error->end = strlen(source_code.lines[line_i]); \
} \
- while (0) \
+ while (0)
/**
@@ -622,7 +622,35 @@ int parse_to_tree(const char* restrict filename, mds_kbdc_tree_t** restrict resu
END;
BRANCH("for");
}
- else if (!strcmp(line, "let")) ; /* TODO */
+ else if (!strcmp(line, "let"))
+ {
+ NEW_NODE(let, LET);
+ CHARS(variable);
+ TEST_FOR_KEYWORD(":");
+ *end = prev_end_char;
+ while (*line && (*line == ' '))
+ line++;
+ if (*line == '\0')
+ {
+ line = original, end = line + strlen(line), prev_end_char = '\0';
+ NEW_ERROR(1, ERROR, "too few parameters");
+ LEAF;
+ }
+ else if (*line != '{')
+ {
+#define node subnode
+ NEW_NODE(string, STRING);
+ CHARS(string);
+#undef node
+ node->value = (mds_kbdc_tree_t*)subnode;
+ END;
+ LEAF;
+ }
+ else
+ {
+ /* TODO */
+ }
+ }
else if (!strcmp(line, "have"))
{
NEW_NODE(assumption_have, ASSUMPTION_HAVE);