Reorganize repo.
This commit is contained in:
23
packages/c/parser.c
Normal file
23
packages/c/parser.c
Normal file
@@ -0,0 +1,23 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user