diff options
Diffstat (limited to 'parse.c')
| -rw-r--r-- | parse.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -54,6 +54,7 @@ line_t parse_line(char* content) { tokenSet_t ts = lex_line(content); int c = 0; int indent = 0; + char isNewIndent = 0; while (ts.tokens[c].type != JUSTIFICATION) { if (ts.tokens[c].type == INDENT) { indent++; @@ -67,6 +68,7 @@ line_t parse_line(char* content) { scope_t* lsp = malloc(sizeof(scope_t)); *lsp = lastScope; thisScope = init_scope(scopes, indent, lsp); + isNewIndent = 1; } else if (indent < lastScope.depth) { scope_t li = lastScope; @@ -84,6 +86,9 @@ line_t parse_line(char* content) { prop_t prop = parse_proposition(init_tokenset(ts.tokens + indent, c - indent), seek, 0); just_t just = parse_justification(init_tokenset(ts.tokens + c + 1, ts.count - (c + 1))); free(seek); + if ((just.rule != ASSUMPTION_R && isNewIndent) || (just.rule == ASSUMPTION_R && !isNewIndent)) { + just.rule = ERR_R; + } return init_line(thisScope, prop, just); } prop_t parse_proposition(tokenSet_t tokenSet, int* seek, char isNegative) { @@ -165,3 +170,15 @@ char peq(prop_t prop1, prop_t prop2) { return prop1.isNegative == prop2.isNegative && prop1.relation == prop2.relation && peq(*prop1.propA, *prop2.propA) && peq(*prop1.propB, *prop2.propB); } } +char slt(scope_t scope1, scope_t scope2) { + while (scope1.parent != NULL) { + scope1 = *scope1.parent; + if (scope1.id == scope2.id) { + return 1; + } + } + return 0; +} +char seqlt(scope_t scope1, scope_t scope2) { + return scope1.id == scope2.id || slt(scope1, scope2); +} |
