@@ -47,23 +47,6 @@ Features Features::strictMode() {
47
47
// Implementation of class Reader
48
48
// ////////////////////////////////
49
49
50
- static inline bool in (Reader::Char c,
51
- Reader::Char c1,
52
- Reader::Char c2,
53
- Reader::Char c3,
54
- Reader::Char c4) {
55
- return c == c1 || c == c2 || c == c3 || c == c4;
56
- }
57
-
58
- static inline bool in (Reader::Char c,
59
- Reader::Char c1,
60
- Reader::Char c2,
61
- Reader::Char c3,
62
- Reader::Char c4,
63
- Reader::Char c5) {
64
- return c == c1 || c == c2 || c == c3 || c == c4 || c == c5;
65
- }
66
-
67
50
static bool containsNewLine (Reader::Location begin, Reader::Location end) {
68
51
for (; begin < end; ++begin)
69
52
if (*begin == ' \n ' || *begin == ' \r ' )
@@ -229,13 +212,6 @@ void Reader::skipCommentTokens(Token& token) {
229
212
}
230
213
}
231
214
232
- bool Reader::expectToken (TokenType type, Token& token, const char * message) {
233
- readToken (token);
234
- if (token.type_ != type)
235
- return addError (message, token);
236
- return true ;
237
- }
238
-
239
215
bool Reader::readToken (Token& token) {
240
216
skipSpaces ();
241
217
token.start_ = current_;
@@ -517,20 +493,14 @@ bool Reader::decodeNumber(Token& token) {
517
493
}
518
494
519
495
bool Reader::decodeNumber (Token& token, Value& decoded) {
520
- bool isDouble = false ;
521
- for (Location inspect = token.start_ ; inspect != token.end_ ; ++inspect) {
522
- isDouble = isDouble || in (*inspect, ' .' , ' e' , ' E' , ' +' ) ||
523
- (*inspect == ' -' && inspect != token.start_ );
524
- }
525
- if (isDouble)
526
- return decodeDouble (token, decoded);
527
496
// Attempts to parse the number as an integer. If the number is
528
497
// larger than the maximum supported value of an integer then
529
498
// we decode the number as a double.
530
499
Location current = token.start_ ;
531
500
bool isNegative = *current == ' -' ;
532
501
if (isNegative)
533
502
++current;
503
+ // TODO: Help the compiler do the div and mod at compile time or get rid of them.
534
504
Value::LargestUInt maxIntegerValue =
535
505
isNegative ? Value::LargestUInt (-Value::minLargestInt)
536
506
: Value::maxLargestUInt;
@@ -539,9 +509,7 @@ bool Reader::decodeNumber(Token& token, Value& decoded) {
539
509
while (current < token.end_ ) {
540
510
Char c = *current++;
541
511
if (c < ' 0' || c > ' 9' )
542
- return addError (" '" + std::string (token.start_ , token.end_ ) +
543
- " ' is not a number." ,
544
- token);
512
+ return decodeDouble (token, decoded);
545
513
Value::UInt digit (c - ' 0' );
546
514
if (value >= threshold) {
547
515
// We've hit or exceeded the max value divided by 10 (rounded down). If
0 commit comments