From d063e3c2c6f4b1566c28d0ea92186f356017f99f Mon Sep 17 00:00:00 2001 From: Kai Stevenson Date: Sun, 11 Jun 2023 16:18:21 -0700 Subject: parsing propositions works now. added some debugging tools --- operetta.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'operetta.c') diff --git a/operetta.c b/operetta.c index 5d71c0b..4c50434 100644 --- a/operetta.c +++ b/operetta.c @@ -9,18 +9,26 @@ int main(int argc, char** argv) { /* read file */ char* path = argv[1]; char* content = read_file(path); - linkList_t* ll = lex_line(content); - linkList_t* l1 = ll; - while (1) { - token_t* t = (token_t*)l1->value; - printf("%d \n", t->type); - if (l1->next == NULL) { - break; - } - l1 = l1->next; + int lineCount = count_lines(content); + lineSet_t lines = parse_lines(content, lineCount); + for (int i = 0; i < lines.count; i++) { + write_prop(lines.lines[i].proposition); + printf("\n"); } free(content); } +void write_prop(prop_t prop) { + if (prop.isSimple) { + printf("%s", prop.name); + } + else { + printf("("); + write_prop(*(prop.propA)); + printf(" %s ", tttos(prop.relation)); + write_prop(*(prop.propB)); + printf(")"); + } +} char* read_file(char* path) { FILE* file = fopen(path, "r"); if (file == NULL) { -- cgit v1.3.1