diff options
-rw-r--r-- | parser.c | 20 |
1 files changed, 13 insertions, 7 deletions
@@ -43,12 +43,18 @@ expect(const char *expect, char *actual) { } -int parse_uop(char *str, enum BINARY (*handler)(enum BINARY, enum BINARY)) { - (void)str; - (void)handler; - emit_error("uop unimplemented\n"); - /* FIXME add gate with specified handler, tie both inputs together */ - return 1; +int parse_uop(char *str, char *name, enum BINARY (*handler)(enum BINARY, enum BINARY)) { + char *gate_name = str; + + strtok(gate_name, " "); + + /* FIXME allow input from other gates, not just inputs */ + struct gate *in = gate_get_input_by_name(gate_name); + + gate_add(name, handler, in, in); + return 0; + + } int parse_bop(char *str, char *name, enum BINARY (*handler)(enum BINARY, enum BINARY)) { @@ -85,7 +91,7 @@ parse_op(char *str, char *name) { for (i = 0; i < sizeof(uop_handlers)/sizeof(uop_handlers[0]); i++) { if (strcmp(uop_handlers[i].str, str) == 0) { match = 1; - if (parse_uop("FIXME", uop_handlers[i].handler)) { + if (parse_uop(str+strlen(str)+1, name, uop_handlers[i].handler)) { return 1; } } |