diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2023-06-11 16:18:21 -0700 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2023-06-11 16:18:21 -0700 |
| commit | d063e3c2c6f4b1566c28d0ea92186f356017f99f (patch) | |
| tree | af7b093f016d16a4902a9094d120f1a33bee64b6 /operetta.c | |
| parent | 2a232f8f42c0a7d5a7b648358a192c21865a55f6 (diff) | |
parsing propositions works now. added some debugging tools
Diffstat (limited to 'operetta.c')
| -rw-r--r-- | operetta.c | 26 |
1 files changed, 17 insertions, 9 deletions
@@ -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) { |
