summaryrefslogtreecommitdiff
path: root/parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/parse.c b/parse.c
index 5bd56e3..d955bc4 100644
--- a/parse.c
+++ b/parse.c
@@ -76,10 +76,31 @@ kerchunk() {
/** Parsers ******************************************************************/
int
+parse_bop(char *ident) {
+ char *l = NULL;
+ char *r = NULL;
+
+ EXPECT_CRITICAL(TOK_IDENT);
+ l = cursor->value;
+ kerchunk();
+
+ EXPECT_CRITICAL(TOK_IDENT);
+ r = cursor->value;
+ kerchunk();
+
+ return gate_add(cursor->type, ident, l, r);
+}
+
+int
parse_expr(void) {
- /* FIXME write wrapper to exit on fail */
+ char *ident = NULL;
+
EXPECT_AND_DISCARD_CRITICAL(TOK_EXPR);
- EXPECT_AND_DISCARD_CRITICAL(TOK_IDENT); /* FIXME do something, don't discard */
+
+ EXPECT_CRITICAL(TOK_IDENT);
+ ident = cursor->value;
+ kerchunk();
+
EXPECT_AND_DISCARD_CRITICAL(TOK_COLON);
switch(cursor->type) {
@@ -90,8 +111,7 @@ parse_expr(void) {
case TOK_NOR: /* fallthrough */
case TOK_NAND:
kerchunk();
- EXPECT_AND_DISCARD_CRITICAL(TOK_IDENT); /* FIXME don't discard */
- EXPECT_AND_DISCARD_CRITICAL(TOK_IDENT); /* FIXME don't discard */
+ parse_bop(ident);
break;
case TOK_NOT:
kerchunk();
@@ -133,8 +153,7 @@ parse(const char *fname, FILE *f, struct token *t) {
case TOK_INPUT:
kerchunk();
expect(TOK_IDENT);
- emit("Debug: input is named %s\n", cursor->value);
- /* FIXME do something */
+ gate_input_add(cursor->value);
kerchunk();
break;
case TOK_EXPR: