371 // ============================================================================ |
371 // ============================================================================ |
372 void ScriptReader::MustNumber (bool fromthis) { |
372 void ScriptReader::MustNumber (bool fromthis) { |
373 if (!fromthis) |
373 if (!fromthis) |
374 MustNext (); |
374 MustNext (); |
375 |
375 |
|
376 str num = token; |
|
377 if (!num.compare ("-")) { |
|
378 MustNext (); |
|
379 num += token; |
|
380 } |
|
381 |
376 // "true" and "false" are valid numbers |
382 // "true" and "false" are valid numbers |
377 if (!token.icompare ("true")) |
383 if (!token.icompare ("true")) |
378 token = "1"; |
384 token = "1"; |
379 else if (!token.icompare ("false")) |
385 else if (!token.icompare ("false")) |
380 token = "0"; |
386 token = "0"; |
381 else { |
387 else { |
382 if (!token.isnumber()) |
388 if (!token.isnumber()) |
383 ParserError ("expected a number, got `%s`", token.chars()); |
389 ParserError ("expected a number, got `%s`", num.chars()); |
384 |
390 |
385 str check; |
391 str check; |
386 check.appendformat ("%d", atoi (token)); |
392 check.appendformat ("%d", atoi (num)); |
387 if (token.compare (check) != 0) |
393 if (token.compare (check) != 0) |
388 ParserWarning ("integer too large: %s -> %s", token.chars(), check.chars()); |
394 ParserWarning ("integer too large: %s -> %s", num.chars(), check.chars()); |
389 } |
395 |
390 } |
396 token = num; |
|
397 } |
|
398 } |