Terrace/packages/c/parser.c
Joshua Bemenderfer 0196cd5c87 Reorganize repo.
2022-11-01 14:57:07 -04:00

24 lines
529 B
C

struct terrace_linedata_s {
char type;
unsigned int level;
unsigned int offset;
};
typedef struct terrace_linedata_s terrace_linedata_t;
void terrace_parse_line(char* line, terrace_linedata_t *lineData) {
char type = 0;
unsigned int level = 0;
if (line[0] == '\n') {
if (lineData->type == 1) level++;
if (lineData->type == 0) level = lineData->level;
} else {
type = 1;
while(line[level] == ' ' && level <= lineData->level + 1) ++level;
}
lineData->type = type;
lineData->level = level;
}