diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2023-06-13 00:56:14 -0700 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2023-06-13 00:56:14 -0700 |
| commit | 3bd120957d570756d396db8a112113f2ffb8f33b (patch) | |
| tree | 3d588b9ef9a5e7bd625938183d45edb58386b9a7 /parse.c | |
| parent | 88a8012eeb81be74a6bcaccfc514fd134a85c71a (diff) | |
added negation
Diffstat (limited to 'parse.c')
| -rw-r--r-- | parse.c | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -44,19 +44,23 @@ line_t parse_line(char* content) { i++; } int* seek = calloc(sizeof(int), 1); - prop_t prop = parse_proposition(init_tokenset(ts.tokens, i), seek); + prop_t prop = parse_proposition(init_tokenset(ts.tokens, i), seek, 0); just_t just = parse_justification(init_tokenset(ts.tokens + i + 1, ts.count - (i + 1))); return init_line(prop, just); } -prop_t parse_proposition(tokenSet_t tokenSet, int* seek) { +prop_t parse_proposition(tokenSet_t tokenSet, int* seek, char isNegative) { prop_t prop; /* recurse to parse the parenthetical as its own proposition */ if (tokenSet.tokens[*seek].type == OPEN_PAREN) { (*seek)++; - prop = parse_proposition(tokenSet, seek); + prop = parse_proposition(tokenSet, seek, 0); + } + else if (tokenSet.tokens[*seek].type == NEGATION) { + (*seek)++; + prop = parse_proposition(tokenSet, seek, 1); } else { - prop = init_simple_prop(tokenSet.tokens[*seek].value); + prop = init_simple_prop(isNegative, tokenSet.tokens[*seek].value); (*seek)++; } /* check if we were reading a simple prop, or if there is a relation */ @@ -70,8 +74,8 @@ prop_t parse_proposition(tokenSet_t tokenSet, int* seek) { prop_t* prop1p = malloc(sizeof(prop_t)); *prop1p = prop; prop_t* prop2p = malloc(sizeof(prop_t)); - *prop2p = parse_proposition(tokenSet, seek); - prop_t metaProp = init_prop(prop1p, prop2p, rel); + *prop2p = parse_proposition(tokenSet, seek, 0); + prop_t metaProp = init_prop(0, prop1p, prop2p, rel); return metaProp; } } |
