diff options
Diffstat (limited to 'parse.c')
| -rw-r--r-- | parse.c | 21 |
1 files changed, 14 insertions, 7 deletions
@@ -1,9 +1,11 @@ #include <stdlib.h> #include "parse.h" #include "lexer.h" +#include "stdio.h" -line_t init_line(prop_t proposition, just_t justification) { +line_t init_line(int aLevel, prop_t proposition, just_t justification) { line_t line; + line.aLevel = aLevel; line.proposition = proposition; line.justification = justification; return line; @@ -39,14 +41,19 @@ lineSet_t parse_lines(char* content, int lineCount) { } line_t parse_line(char* content) { tokenSet_t ts = lex_line(content); - int i = 0; - while (ts.tokens[i].type != JUSTIFICATION) { - i++; + int c = 0; + int indent = 0; + while (ts.tokens[c].type != JUSTIFICATION) { + if (ts.tokens[c].type == INDENT) { + indent++; + } + c++; } int* seek = calloc(sizeof(int), 1); - 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 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); + return init_line(indent, prop, just); } prop_t parse_proposition(tokenSet_t tokenSet, int* seek, char isNegative) { prop_t prop; |
