Skip to content

Commit

Permalink
Avoid tokenizing literals with e followed by +/- as hexadecimals
Browse files Browse the repository at this point in the history
  • Loading branch information
sp1187 committed Sep 22, 2019
1 parent 8189eae commit 31391b8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Parser/Tokenizer.cpp
Expand Up @@ -538,6 +538,7 @@ Token FileTokenizer::loadToken()
bool isValid = true; bool isValid = true;
bool foundPoint = false; bool foundPoint = false;
bool foundExp = false; bool foundExp = false;
bool foundExpSign = false;
bool isHex = start+1 < currentLine.size() && currentLine[start] == '0' && towlower(currentLine[start+1]) == 'x'; bool isHex = start+1 < currentLine.size() && currentLine[start] == '0' && towlower(currentLine[start+1]) == 'x';


while (end < currentLine.size() && (iswalnum(currentLine[end]) || currentLine[end] == '.')) while (end < currentLine.size() && (iswalnum(currentLine[end]) || currentLine[end] == '.'))
Expand All @@ -547,7 +548,7 @@ Token FileTokenizer::loadToken()
if (isHex || foundExp || foundPoint) if (isHex || foundExp || foundPoint)
isValid = false; isValid = false;
foundPoint = true; foundPoint = true;
} else if (towlower(currentLine[end]) == 'h') { } else if (towlower(currentLine[end]) == 'h' && !foundExpSign) {
isHex = true; isHex = true;
} else if (towlower(currentLine[end]) == 'e' && !isHex) } else if (towlower(currentLine[end]) == 'e' && !isHex)
{ {
Expand All @@ -558,6 +559,7 @@ Token FileTokenizer::loadToken()
end++; end++;
if (end+1 >= currentLine.size() || !iswalnum(currentLine[end+1])) if (end+1 >= currentLine.size() || !iswalnum(currentLine[end+1]))
isValid = false; isValid = false;
foundExpSign = true;
} }
foundExp = true; foundExp = true;
} }
Expand Down

0 comments on commit 31391b8

Please sign in to comment.