|
@@ -161,9 +161,17 @@ namespace Jint.Native.Json
|
|
|
|
|
|
int start = _index;
|
|
int start = _index;
|
|
string number = "";
|
|
string number = "";
|
|
|
|
+
|
|
|
|
+ // Number start with a -
|
|
|
|
+ if (ch == '-')
|
|
|
|
+ {
|
|
|
|
+ number += _source.CharCodeAt(_index++).ToString();
|
|
|
|
+ ch = _source.CharCodeAt(_index);
|
|
|
|
+ }
|
|
|
|
+
|
|
if (ch != '.')
|
|
if (ch != '.')
|
|
{
|
|
{
|
|
- number = _source.CharCodeAt(_index++).ToString();
|
|
|
|
|
|
+ number += _source.CharCodeAt(_index++).ToString();
|
|
ch = _source.CharCodeAt(_index);
|
|
ch = _source.CharCodeAt(_index);
|
|
|
|
|
|
// Hex number starts with '0x'.
|
|
// Hex number starts with '0x'.
|
|
@@ -219,7 +227,7 @@ namespace Jint.Native.Json
|
|
return new Token
|
|
return new Token
|
|
{
|
|
{
|
|
Type = Tokens.Number,
|
|
Type = Tokens.Number,
|
|
- Value = Double.Parse(number, NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent, CultureInfo.InvariantCulture),
|
|
|
|
|
|
+ Value = Double.Parse(number, NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent, CultureInfo.InvariantCulture),
|
|
LineNumber = _lineNumber,
|
|
LineNumber = _lineNumber,
|
|
LineStart = _lineStart,
|
|
LineStart = _lineStart,
|
|
Range = new[] {start, _index}
|
|
Range = new[] {start, _index}
|
|
@@ -447,6 +455,15 @@ namespace Jint.Native.Json
|
|
return ScanPunctuator();
|
|
return ScanPunctuator();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (ch == '-') // Negative Number
|
|
|
|
+ {
|
|
|
|
+ if (IsDecimalDigit(_source.CharCodeAt(_index + 1)))
|
|
|
|
+ {
|
|
|
|
+ return ScanNumericLiteral();
|
|
|
|
+ }
|
|
|
|
+ return ScanPunctuator();
|
|
|
|
+ }
|
|
|
|
+
|
|
if (IsDecimalDigit(ch))
|
|
if (IsDecimalDigit(ch))
|
|
{
|
|
{
|
|
return ScanNumericLiteral();
|
|
return ScanNumericLiteral();
|