Fixed number with exponent scanner (and simplified that code).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35249 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -137,29 +137,49 @@ class Tokenizer {
|
|||||||
BString temp;
|
BString temp;
|
||||||
|
|
||||||
const char* begin = fCurrentChar;
|
const char* begin = fCurrentChar;
|
||||||
bool expectE = true;
|
|
||||||
bool expectPlusOrMinus = false;
|
// optional digits before the comma
|
||||||
while (*fCurrentChar != 0) {
|
while (isdigit(*fCurrentChar)) {
|
||||||
if (!isdigit(*fCurrentChar)) {
|
temp << *fCurrentChar;
|
||||||
if (*fCurrentChar == 'e' || *fCurrentChar == 'E') {
|
|
||||||
if (!expectE)
|
|
||||||
break;
|
|
||||||
expectE = false;
|
|
||||||
expectPlusOrMinus = true;
|
|
||||||
} else if (*fCurrentChar == '+' || *fCurrentChar == '-') {
|
|
||||||
if (!expectPlusOrMinus)
|
|
||||||
break;
|
|
||||||
} else if (!(*fCurrentChar == '.' || *fCurrentChar == ','))
|
|
||||||
break;
|
|
||||||
else
|
|
||||||
expectPlusOrMinus = false;
|
|
||||||
}
|
|
||||||
if (*fCurrentChar == ',')
|
|
||||||
temp << '.';
|
|
||||||
else
|
|
||||||
temp << *fCurrentChar;
|
|
||||||
fCurrentChar++;
|
fCurrentChar++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// optional post comma part
|
||||||
|
// (required if there are no digits before the comma)
|
||||||
|
if (*fCurrentChar == '.' || *fCurrentChar == ',') {
|
||||||
|
temp << '.';
|
||||||
|
fCurrentChar++;
|
||||||
|
|
||||||
|
// optional post comma digits
|
||||||
|
while (isdigit(*fCurrentChar)) {
|
||||||
|
temp << *fCurrentChar;
|
||||||
|
fCurrentChar++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// optional exponent part
|
||||||
|
if (*fCurrentChar == 'e' || *fCurrentChar == 'E') {
|
||||||
|
temp << *fCurrentChar;
|
||||||
|
fCurrentChar++;
|
||||||
|
|
||||||
|
// optional exponent sign
|
||||||
|
if (*fCurrentChar == '+' || *fCurrentChar == '-') {
|
||||||
|
temp << *fCurrentChar;
|
||||||
|
fCurrentChar++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// required exponent digits
|
||||||
|
if (!isdigit(*fCurrentChar)) {
|
||||||
|
throw ParseException("missing exponent in constant",
|
||||||
|
fCurrentChar - begin);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (isdigit(*fCurrentChar)) {
|
||||||
|
temp << *fCurrentChar;
|
||||||
|
fCurrentChar++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int32 length = fCurrentChar - begin;
|
int32 length = fCurrentChar - begin;
|
||||||
BString test = temp;
|
BString test = temp;
|
||||||
test << "&_";
|
test << "&_";
|
||||||
|
|||||||
Reference in New Issue
Block a user