change format of error info

parser now can report exact place where is lacking ';' or ','
This commit is contained in:
ValKmjolnir
2022-06-30 23:15:10 +08:00
parent a4a7f5075a
commit c993c77b78
5 changed files with 71 additions and 46 deletions
+9 -2
View File
@@ -148,6 +148,14 @@ int utf8_hdchk(char head)
return nbytes;
}
std::string chrhex(const char c)
{
std::string res="";
res+="0123456789abcdef"[(c&0xf0)>>4];
res+="0123456789abcdef"[c&0x0f];
return res;
}
std::string rawstr(const std::string& str)
{
std::string ret("");
@@ -159,8 +167,7 @@ std::string rawstr(const std::string& str)
if(i<=0)
{
ret+="\\x";
ret+="0123456789abcdef"[(i>>4)&15];
ret+="0123456789abcdef"[i&15];
ret+=chrhex(i);
continue;
}
#endif