This commit is contained in:
Valk Richard Li
2020-01-18 19:34:15 +08:00
committed by GitHub
parent 28cb147765
commit 58c40b5468
5 changed files with 210 additions and 40 deletions
+11
View File
@@ -26,6 +26,7 @@ int main()
std::cout<<">> [par ] turn tokens into abstract syntax tree."<<std::endl;
std::cout<<">> [ast ] check the abstract syntax tree."<<std::endl;
std::cout<<">> [run ] run code."<<std::endl;
std::cout<<">> [info ] print lexer,parser and ast on screen."<<std::endl;
std::cout<<">> [exit ] quit nasal interpreter."<<std::endl;
}
else if(command=="cls")
@@ -117,6 +118,16 @@ int main()
else
std::cout<<">>[Lexer] error occurred,stop."<<std::endl;
}
else if(command=="info")
{
lexer.scanner(resource.get_source());
lexer.print_token_list();
lexer.generate_detail_token();
parser.get_token_list(lexer.get_detail_token_list());
parser.print_detail_token();
parser.main_generate();
parser.get_root().print_tree(1);
}
else if(command=="exit")
break;
else