diff options
Diffstat (limited to 'parse.c')
| -rw-r--r-- | parse.c | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -1,4 +1,5 @@ #include <stdlib.h> +#include <string.h> #include "parse.h" #include "lexer.h" #include "stdio.h" @@ -71,7 +72,8 @@ prop_t parse_proposition(tokenSet_t tokenSet, int* seek, char isNegative) { (*seek)++; } /* check if we were reading a simple prop, or if there is a relation */ - if (*seek == tokenSet.count || tokenSet.tokens[*seek].type == CLOSE_PAREN) { + if (*seek >= tokenSet.count || tokenSet.tokens[*seek].type == CLOSE_PAREN) { + (*seek)++; return prop; } else { @@ -119,3 +121,17 @@ just_t parse_justification(tokenSet_t tokenSet) { } return init_just(just, references, i); } +char peq(prop_t prop1, prop_t prop2) { + if (prop1.isSimple && prop2.isSimple) { + /* both simple */ + return strcmp(prop1.name, prop2.name) == 0 && prop1.isNegative == prop2.isNegative; + } + else if (prop1.isSimple || prop2.isSimple) { + /* only one simple */ + return 0; + } + else { + /* neither simple */ + return prop1.isNegative == prop2.isNegative && prop1.relation == prop2.relation && peq(*prop1.propA, *prop2.propA) && peq(*prop1.propB, *prop2.propB); + } +} |
