drop preprocesing

This commit is contained in:
vrd
2023-03-17 09:45:59 +02:00
parent 6fb3dbcaee
commit e603913539
2 changed files with 25 additions and 41 deletions
+19 -32
View File
@@ -66,7 +66,6 @@ namespace /* internal */
using TokenIt = vector<token>::const_iterator; using TokenIt = vector<token>::const_iterator;
char* end_data_; /* past the end pointer */
unsigned line = 1; unsigned line = 1;
pair<person_id, person_id> prev_parents(Nobody, Nobody); pair<person_id, person_id> prev_parents(Nobody, Nobody);
@@ -507,36 +506,15 @@ namespace /* internal */
} }
} }
alloced removeComments(MappedFile file) /* todo - drop */ vector<token> tokenize(const MappedFile f)
{
alloced res(file.len);
char* itres = res.data;
char* end = file.data + file.len;
for(char* it = file.data; it < end; ++it)
{
if(*it == '#')
{
while(++it != end && *it != '\n'); /* skip comment */
*itres++ = '\n'; /* add \n */
}
else
{
*itres = *it;
++itres;
}
}
end_data_ = itres;
return res;
}
vector<token> tokenize(const char* data_begin, const char* data_end)
{ {
vector<token> tokens; vector<token> tokens;
tokens.reserve(256); tokens.reserve(256);
const char* token_begin = data_begin; const char* token_begin = f.data;
const char* end = f.data + f.len;
for(const char* it = data_begin; it < data_end; ++it) const char* it = f.data;
for(; it < end; ++it)
{ {
switch(*it) switch(*it)
{ {
@@ -555,15 +533,25 @@ namespace /* internal */
case '\n': case '\n':
if(token_begin < it) if(token_begin < it)
tokens.emplace_back(token_begin, it); tokens.emplace_back(token_begin, it);
tokens.emplace_back(it, it+1); tokens.emplace_back(it, it+1); /* add the , or \n as a token */
token_begin = it+1; token_begin = it + 1;
break;
case '#':
if(token_begin < it)
tokens.emplace_back(token_begin, it);
while(++it < end && *it != '\n'); /* skip comment */
token_begin = it;
--it;
break; break;
/* case '0' ... '9': */ /* case '0' ... '9': */
default: break; default: break;
} }
} }
tokens.emplace_back(NEW_LINE); if(token_begin < it)
tokens.emplace_back(token_begin, it);
tokens.emplace_back(NEW_LINE); /* add newlines at the end for easier parsing */
tokens.emplace_back(NEW_LINE); tokens.emplace_back(NEW_LINE);
return tokens; return tokens;
} }
@@ -578,8 +566,7 @@ Tree parseTftFile(const char* path)
cur_tree = &result; cur_tree = &result;
MappedFile mapedfile = mapfile(file); MappedFile mapedfile = mapfile(file);
alloced preprocessed = removeComments(mapedfile); vector<token> tokens = tokenize(mapedfile);
vector<token> tokens = tokenize(preprocessed.data, end_data_);
state_neutral(tokens); state_neutral(tokens);
+6 -9
View File
@@ -1,34 +1,31 @@
Parser: Parser:
- clean wh - one pass rather then preprocess
- tokens?
--help --help
help - lowercase help - based on user config
findRelative findRelative
findRelation - extend findRelation - extend
Draw distinct regions of a tree
Draw spouses' relatives if main has none?
Combine trees on the command line Combine trees on the command line
Zooming
Visualization: Visualization:
- zooming
- horizontal navigation between cousins - horizontal navigation between cousins
- color on different consoles - color on different consoles
- screen resize - screen resize
- empty tree - empty tree
- half children and main tree - half children and main tree
- distincs tree regions - distincs tree regions
- info bar
Compilation Compilation
- static and dynamic ncurses - static and dynamic ncurses
? ?
- info bar
- tree visualizer component
- distinct regions of a tree
- same person can be displayed twice - same person can be displayed twice
- coordinate types for large trees - coordinate types for large trees