cyrilic attributes
This commit is contained in:
+57
-18
@@ -37,7 +37,10 @@ namespace /* internal */
|
||||
|
||||
enum TokenType
|
||||
{
|
||||
ATTRIBUTE,
|
||||
ATR_BIRTH,
|
||||
ATR_DEATH,
|
||||
ATR_PARENTS,
|
||||
ATR_SPOUSES,
|
||||
STRING,
|
||||
/* DATE, */
|
||||
NUMBER,
|
||||
@@ -113,9 +116,9 @@ namespace /* internal */
|
||||
[[noreturn]]void err_expected(const char* what, token instead)
|
||||
{
|
||||
endwin();
|
||||
cerr << "Line " << line << ": Expected " << what << "got";
|
||||
cerr << "Line " << line << ": Expected " << what << " got ";
|
||||
cerr.write(instead.begin, instead.size());
|
||||
cerr << "instead\n";
|
||||
cerr << " instead\n";
|
||||
cerr.flush();
|
||||
exit(1);
|
||||
}
|
||||
@@ -212,10 +215,43 @@ namespace /* internal */
|
||||
type = NEW_LINE;
|
||||
}
|
||||
}
|
||||
else if(t.size() == 2)
|
||||
else if(t.end[-1] == ':')
|
||||
{
|
||||
if(t.begin[1] == ':')
|
||||
type = ATTRIBUTE;
|
||||
switch(t.begin[0])
|
||||
{
|
||||
case 'b':
|
||||
type = ATR_BIRTH;
|
||||
break;
|
||||
case 'd':
|
||||
type = ATR_DEATH;
|
||||
break;
|
||||
case 'p':
|
||||
type = ATR_PARENTS;
|
||||
break;
|
||||
case 's':
|
||||
type = ATR_SPOUSES;
|
||||
break;
|
||||
default:
|
||||
U16 cyr = ((U8)t.begin[0] << 8) | (U8)t.begin[1]; /* assuming char signed? */
|
||||
switch(cyr) /* check for cyrilic attribure */
|
||||
{
|
||||
case 'д':
|
||||
type = ATR_BIRTH;
|
||||
break;
|
||||
case 'п':
|
||||
type = ATR_DEATH;
|
||||
break;
|
||||
case 'р':
|
||||
type = ATR_PARENTS;
|
||||
break;
|
||||
case 'с':
|
||||
type = ATR_SPOUSES;
|
||||
break;
|
||||
default:
|
||||
err_illegal_attribute(t);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return type;
|
||||
@@ -309,9 +345,19 @@ namespace /* internal */
|
||||
err_expected("sex", *it);
|
||||
++it;
|
||||
}
|
||||
else if(it->size() == 2)
|
||||
{
|
||||
U16 cyr = ((U8)it->begin[0] << 8) | (U8)it->begin[1]; /* assuming char signed? */
|
||||
if(cyr == 'М')
|
||||
res = M;
|
||||
else if(cyr == 'Ж')
|
||||
res = F;
|
||||
else
|
||||
err_expected("sex", *it);
|
||||
++it;
|
||||
}
|
||||
else
|
||||
err_expected("sex", *it);
|
||||
|
||||
}
|
||||
else
|
||||
err_unexpected_token(*it);
|
||||
@@ -494,25 +540,18 @@ namespace /* internal */
|
||||
{
|
||||
switch(it->type)
|
||||
{
|
||||
case ATTRIBUTE:
|
||||
switch(it->begin[0])
|
||||
{
|
||||
case 'b':
|
||||
case ATR_BIRTH:
|
||||
birth = state_date(it); /* todo check for redefinition */
|
||||
break;
|
||||
case 'd':
|
||||
case ATR_DEATH:
|
||||
death = state_date(it);
|
||||
break;
|
||||
case 'p':
|
||||
case ATR_PARENTS:
|
||||
parents = processParents(it, end);
|
||||
break;
|
||||
case 's':
|
||||
case ATR_SPOUSES:
|
||||
spouses = parseSpouses(it, end);
|
||||
break;
|
||||
default:
|
||||
err_illegal_attribute(*it);
|
||||
}
|
||||
break;
|
||||
case NEW_LINE:
|
||||
++line;
|
||||
++it;
|
||||
|
||||
Reference in New Issue
Block a user