This commit is contained in:
Valk Richard Li 2020-04-07 01:49:29 -07:00 committed by GitHub
parent b8728dd725
commit 240670ca85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 1 deletions

View File

@ -242,18 +242,38 @@ std::string nasal_lexer::identifier_gen(std::vector<char>& res,int& ptr,int& lin
} }
std::string nasal_lexer::number_gen(std::vector<char>& res,int& ptr,int& line) std::string nasal_lexer::number_gen(std::vector<char>& res,int& ptr,int& line)
{ {
bool scientific_notation=false;
std::string token_str=""; std::string token_str="";
while(('0'<=res[ptr] && res[ptr]<='9') || while(('0'<=res[ptr] && res[ptr]<='9') ||
('a'<=res[ptr] && res[ptr]<='f') || ('a'<=res[ptr] && res[ptr]<='f') ||
('A'<=res[ptr] && res[ptr]<='F') || ('A'<=res[ptr] && res[ptr]<='F') ||
res[ptr]=='.' || res[ptr]=='x' || res[ptr]=='o' || res[ptr]=='.' || res[ptr]=='x' || res[ptr]=='o' ||
res[ptr]=='e' || res[ptr]=='E' || res[ptr]=='-') res[ptr]=='e' || res[ptr]=='E')
{ {
token_str+=res[ptr]; token_str+=res[ptr];
if(res[ptr]=='e' || res[ptr]=='E')
{
scientific_notation=true;
++ptr;
break;
}
++ptr; ++ptr;
if(ptr>=res.size()) if(ptr>=res.size())
break; break;
} }
if(scientific_notation && ptr<res.size())
{
if(res[ptr]=='-')
{
token_str+='-';
++ptr;
}
while(ptr<res.size() && '0'<=res[ptr] && res[ptr]<='9')
{
token_str+=res[ptr];
++ptr;
}
}
if(!check_numerable_string(token_str)) if(!check_numerable_string(token_str))
{ {
++error; ++error;