mirror of
https://github.com/ValKmjolnir/Nasal-Interpreter.git
synced 2026-07-22 10:58:47 +08:00
bug fixed
This commit is contained in:
+11
-1
@@ -48,11 +48,16 @@ public:
|
||||
void err(const char* stage,const std::string& info)
|
||||
{
|
||||
++error;
|
||||
std::cout<<"["<<stage<<"] "<<info<<'\n';
|
||||
std::cout<<"["<<stage<<"] "<<file<<": "<<info<<'\n';
|
||||
}
|
||||
void err(const char* stage,uint32_t line,uint32_t column,const std::string& info)
|
||||
{
|
||||
++error;
|
||||
if(!line)
|
||||
{
|
||||
err(stage,info);
|
||||
return;
|
||||
}
|
||||
std::cout<<"["<<stage<<"] "<<file<<":"<<line<<":"<<column<<" "<<info<<"\n"<<res[line-1]<<'\n';
|
||||
for(int i=0;i<(int)column-1;++i)
|
||||
std::cout<<char(" \t"[res[line-1][i]=='\t']);
|
||||
@@ -61,6 +66,11 @@ public:
|
||||
void err(const char* stage,uint32_t line,const std::string& info)
|
||||
{
|
||||
++error;
|
||||
if(!line)
|
||||
{
|
||||
err(stage,info);
|
||||
return;
|
||||
}
|
||||
std::cout<<"["<<stage<<"] "<<file<<":"<<line<<" "<<info<<"\n"<<res[line-1]<<'\n';
|
||||
}
|
||||
void chkerr(){if(error)std::exit(1);}
|
||||
|
||||
+8
-2
@@ -294,9 +294,15 @@ void nasal_lexer::scan(const std::string& file)
|
||||
tokens.push_back({line,column,type?type:tok_id,str});
|
||||
}
|
||||
else if(DIGIT(res[ptr]))
|
||||
tokens.push_back({line,column,tok_num,num_gen()});
|
||||
{
|
||||
str=num_gen(); // make sure column is correct
|
||||
tokens.push_back({line,column,tok_num,str});
|
||||
}
|
||||
else if(STR(res[ptr]))
|
||||
tokens.push_back({line,column,tok_str,str_gen()});
|
||||
{
|
||||
str=str_gen(); // make sure column is correct
|
||||
tokens.push_back({line,column,tok_str,str});
|
||||
}
|
||||
else if(SINGLE_OPERATOR(res[ptr]))
|
||||
{
|
||||
str=res[ptr];
|
||||
|
||||
@@ -124,6 +124,8 @@ void nasal_parse::compile(const nasal_lexer& lexer)
|
||||
void nasal_parse::die(uint32_t line,const std::string& info)
|
||||
{
|
||||
int col=(int)tokens[ptr].column-(int)tokens[ptr].str.length();
|
||||
if(tokens[ptr].type==tok_str)
|
||||
col-=2; // tok_str's str has no \"
|
||||
nerr.err("parse",line,col<0?0:col,info);
|
||||
}
|
||||
void nasal_parse::match(uint32_t type,const char* info)
|
||||
|
||||
Reference in New Issue
Block a user