bug fixed
fixed SIGSEGV when failed to load file in nasal_lexer::openfile
This commit is contained in:
parent
b25a1bc3f4
commit
9f2c31149a
2
main.cpp
2
main.cpp
|
@ -53,6 +53,7 @@ void execute(std::string& file,std::string& command)
|
|||
return;
|
||||
}
|
||||
parse.set_toklist(lexer.get_token_list());
|
||||
lexer.get_token_list().clear();
|
||||
parse.main_process();
|
||||
if(parse.get_error())
|
||||
{
|
||||
|
@ -65,6 +66,7 @@ void execute(std::string& file,std::string& command)
|
|||
return;
|
||||
}
|
||||
import.link(parse.get_root());
|
||||
parse.get_root().clear();
|
||||
if(import.get_error())
|
||||
{
|
||||
die("import",file);
|
||||
|
|
|
@ -87,18 +87,19 @@ nasal_ast nasal_import::file_import(nasal_ast& node)
|
|||
import_lex.scanner();
|
||||
if(import_lex.get_error())
|
||||
{
|
||||
this->die(filename,"lexer");
|
||||
die(filename,"lexer");
|
||||
return tmp;
|
||||
}
|
||||
import_par.set_toklist(import_lex.get_token_list());
|
||||
import_lex.get_token_list().clear();
|
||||
import_par.main_process();
|
||||
if(import_par.get_error())
|
||||
{
|
||||
this->die(filename,"parser");
|
||||
die(filename,"parser");
|
||||
return tmp;
|
||||
}
|
||||
tmp=import_par.get_root();
|
||||
|
||||
import_par.get_root().clear();
|
||||
// check if tmp has 'import'
|
||||
return load(tmp);
|
||||
}
|
||||
|
|
|
@ -125,7 +125,8 @@ void nasal_lexer::openfile(std::string filename)
|
|||
{
|
||||
++error;
|
||||
std::cout<<">> [lexer] cannot open file \""<<filename<<"\".\n";
|
||||
fin.close();
|
||||
fin.close();
|
||||
res_size=0;
|
||||
return;
|
||||
}
|
||||
while(!fin.eof())
|
||||
|
@ -390,6 +391,7 @@ void nasal_lexer::scanner()
|
|||
}
|
||||
token tk(line,tok_eof,"");
|
||||
token_list.push_back(tk);
|
||||
res.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue