update
This commit is contained in:
parent
368baa0561
commit
e2a50a61e6
|
@ -27,11 +27,11 @@ void help()
|
|||
|
||||
void logo()
|
||||
{
|
||||
std::cout<<" __ _ "<<std::endl;
|
||||
std::cout<<" /\\ \\ \\__ _ ___ __ _| | "<<std::endl;
|
||||
std::cout<<" / \\/ / _` / __|/ _` | | "<<std::endl;
|
||||
std::cout<<" / /\\ / (_| \\__ \\ (_| | | "<<std::endl;
|
||||
std::cout<<" \\_\\ \\/ \\__,_|___/\\__,_|_|"<<std::endl;
|
||||
std::cout<<" __ _ \n";
|
||||
std::cout<<" /\\ \\ \\__ _ ___ __ _| | \n";
|
||||
std::cout<<" / \\/ / _` / __|/ _` | | \n";
|
||||
std::cout<<" / /\\ / (_| \\__ \\ (_| | | \n";
|
||||
std::cout<<" \\_\\ \\/ \\__,_|___/\\__,_|_|\n";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -41,13 +41,13 @@ void del_func()
|
|||
lexer.clear();
|
||||
parse.clear();
|
||||
inputfile="null";
|
||||
std::cout<<">> [Delete] complete."<<std::endl;
|
||||
std::cout<<">> [Delete] complete.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
void die(std::string stage,std::string filename)
|
||||
{
|
||||
std::cout<<">> ["<<stage<<"] in <\""<<filename<<"\">: error(s) occurred,stop."<<std::endl;
|
||||
std::cout<<">> ["<<stage<<"] in <\""<<filename<<"\">: error(s) occurred,stop.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -180,19 +180,19 @@ int main()
|
|||
#endif
|
||||
logo();
|
||||
#ifdef _WIN32
|
||||
std::cout<<">> [system] Windows system."<<std::endl;
|
||||
std::cout<<">> [system] Windows system.\n";
|
||||
#endif
|
||||
#ifdef _linux_
|
||||
std::cout<<">> [system] Linux system."<<std::endl;
|
||||
std::cout<<">> [system] Linux system.\n";
|
||||
#endif
|
||||
#ifdef TARGET_OS_MAC
|
||||
std::cout<<">> [system] MacOS system."<<std::endl;
|
||||
std::cout<<">> [system] MacOS system.\n";
|
||||
#endif
|
||||
|
||||
std::cout<<">> Nasal interpreter ver 3.0 ."<<std::endl;
|
||||
std::cout<<">> Code: https://github.com/ValKmjolnir/Nasal-Interpreter"<<std::endl;
|
||||
std::cout<<">> Info: http://wiki.flightgear.org/Nasal_scripting_language"<<std::endl;
|
||||
std::cout<<">> Input \"help\" to get help ."<<std::endl;
|
||||
std::cout<<">> Nasal interpreter ver 3.0 .\n";
|
||||
std::cout<<">> Code: https://github.com/ValKmjolnir/Nasal-Interpreter\n";
|
||||
std::cout<<">> Info: http://wiki.flightgear.org/Nasal_scripting_language\n";
|
||||
std::cout<<">> Input \"help\" to get help .\n";
|
||||
while(1)
|
||||
{
|
||||
std::cout<<">> ";
|
||||
|
@ -238,7 +238,7 @@ int main()
|
|||
std::ifstream fin(command);
|
||||
if(fin.fail())
|
||||
{
|
||||
std::cout<<">> [file] cannot open file \""<<command<<"\"."<<std::endl;
|
||||
std::cout<<">> [file] cannot open file \""<<command<<"\".\n";
|
||||
inputfile="null";
|
||||
}
|
||||
fin.close();
|
||||
|
|
|
@ -207,34 +207,40 @@ std::string nasal_lexer::string_gen(std::vector<char>& res,int& ptr,int& line)
|
|||
{
|
||||
int res_size=res.size();
|
||||
std::string token_str="";
|
||||
char str_begin=res[ptr];
|
||||
++ptr;
|
||||
char str_begin=res[ptr++];
|
||||
if(ptr>=res_size) return token_str;
|
||||
while(ptr<res_size && res[ptr]!=str_begin)
|
||||
{
|
||||
token_str+=res[ptr];
|
||||
if(res[ptr]=='\n') ++line;
|
||||
if(res[ptr]=='\\' && ptr+1<res.size())
|
||||
{
|
||||
++ptr;
|
||||
switch(res[ptr])
|
||||
{
|
||||
case '\\':token_str.pop_back();token_str.push_back('\\');break;
|
||||
case 'r': token_str.pop_back();token_str.push_back('\r');break;
|
||||
case 't': token_str.pop_back();token_str.push_back('\t');break;
|
||||
case 'n': token_str.pop_back();token_str.push_back('\n');break;
|
||||
case '\'':token_str.pop_back();token_str.push_back('\'');break;
|
||||
case '\"':token_str.pop_back();token_str.push_back('\"');break;
|
||||
case 'a':token_str.push_back('\a');break;
|
||||
case 'b':token_str.push_back('\b');break;
|
||||
case 'f':token_str.push_back('\f');break;
|
||||
case 'n':token_str.push_back('\n');break;
|
||||
case 'r':token_str.push_back('\r');break;
|
||||
case 't':token_str.push_back('\t');break;
|
||||
case 'v':token_str.push_back('\v');break;
|
||||
case '?':token_str.push_back('\?');break;
|
||||
case '0':token_str.push_back('\0');break;
|
||||
case '\\':token_str.push_back('\\');break;
|
||||
case '\'':token_str.push_back('\'');break;
|
||||
case '\"':token_str.push_back('\"');break;
|
||||
default: token_str.push_back(res[ptr]);break;
|
||||
}
|
||||
}
|
||||
else
|
||||
token_str+=res[ptr];
|
||||
++ptr;
|
||||
}
|
||||
// check if this string ends with a " or '
|
||||
if(ptr>=res_size)
|
||||
{
|
||||
++error;
|
||||
std::cout<<">> [lexer] line "<<line<<": this string must have a \' "<<str_begin<<" \' as its end."<<std::endl;
|
||||
std::cout<<">> [lexer] line "<<line<<": get EOF when generating string.\n";
|
||||
}
|
||||
++ptr;
|
||||
return token_str;
|
||||
|
|
Loading…
Reference in New Issue