summaryrefslogtreecommitdiff
path: root/operetta.c
diff options
context:
space:
mode:
Diffstat (limited to 'operetta.c')
-rw-r--r--operetta.c26
1 files changed, 17 insertions, 9 deletions
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) {