fix warnings add error info

This commit is contained in:
vrd
2023-03-11 18:38:16 +02:00
parent 84e4938683
commit 6fb3dbcaee
4 changed files with 33 additions and 25 deletions
+25 -19
View File
@@ -94,10 +94,12 @@ namespace /* internal */
exit(1);
}
[[noreturn]]void err_expected(const char* what)
[[noreturn]]void err_expected(const char* what, token instead)
{
endwin();
cerr << "Line " << line << ": Expected " << what << "\n";
cerr << "Line " << line << ": Expected " << what << "got";
cerr.write(instead.begin, instead.size());
cerr << "instead\n";
cerr.flush();
exit(1);
}
@@ -106,7 +108,9 @@ namespace /* internal */
[[noreturn]]void err_unexpected_token(token t)
{
endwin();
/* cerr << "Line " << line << ": Unexpected token '" << c << "'\n"; */
cerr << "Line " << line << ": Unexpected token '";
cerr.write(t.begin, t.size());
cerr << "'\n";
cerr.flush();
exit(1);
}
@@ -114,19 +118,21 @@ namespace /* internal */
[[noreturn]]void err_illegal_attribute(token attr)
{
endwin();
/* cerr << "Line " << line << ": Unexpected '" << c << "'\n"; */
cerr << "Line " << line << ": Illegal attribute '";
cerr.write(attr.begin, attr.size());
cerr << "'\n";
cerr.flush();
exit(1);
}
[[noreturn]]void err_thirdParent(const string& extra_name)
{
endwin();
cerr << "Line " << line << ": two parents are already defined, "
<< extra_name << " is third\n";
cerr.flush();
exit(1);
}
/* [[noreturn]]void err_thirdParent(const string& extra_name) */
/* { */
/* endwin(); */
/* cerr << "Line " << line << ": two parents are already defined, " */
/* << extra_name << " is third\n"; */
/* cerr.flush(); */
/* exit(1); */
/* } */
[[noreturn]]void err_personUndefined(const string& name)
{
@@ -232,7 +238,7 @@ namespace /* internal */
string parseName(TokenIt& it, TokenIt end)
{
if(it->type != STRING)
err_expected("name");
err_expected("name", *it);
string name;
for(; it < end && it->type == STRING; ++it)
@@ -287,11 +293,11 @@ namespace /* internal */
else if(it->begin[0] == 'F')
res = F;
else
err_expected("sex");
err_expected("sex", *it);
++it;
}
else
err_expected("sex");
err_expected("sex", *it);
}
else
@@ -331,7 +337,7 @@ namespace /* internal */
return sign * val;
}
EventTime state_date(TokenIt& it, TokenIt end) /* todo validate */
EventTime state_date(TokenIt& it) /* todo validate */
{
++it; /* skip attribute */
if(it->type == STRING || it->type == NUMBER)
@@ -357,7 +363,7 @@ namespace /* internal */
return date;
}
else
err_expected("date");
err_expected("date", *it);
}
@@ -470,10 +476,10 @@ namespace /* internal */
switch(it->begin[0])
{
case 'b':
birth = state_date(it, end); /* todo check for redefinition */
birth = state_date(it); /* todo check for redefinition */
break;
case 'd':
death = state_date(it, end);
death = state_date(it);
break;
case 'p':
parents = processParents(it, end);