Handle numbers fully as lua

This commit is contained in:
Deukhoofd 2018-11-11 18:19:30 +01:00
parent 3561979ded
commit 4e331712a8
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
3 changed files with 13 additions and 4 deletions

View File

@ -5,7 +5,7 @@ namespace Upsilon.BaseTypes.Number
public class NumberLong : Number
{
public long Value { get; }
protected override bool IsFloat { get; } = true;
protected override bool IsFloat { get; } = false;
public NumberLong(long val)
{

View File

@ -73,6 +73,10 @@ namespace Upsilon.Binder
type = Type.Number;
outValue = new NumberDouble(d);
break;
case long l:
type = Type.Number;
outValue = new NumberLong(l);
break;
case bool b:
type = Type.Boolean;
outValue = value;

View File

@ -124,8 +124,13 @@ namespace Upsilon.Parser
numStr.Append(Next);
_position++;
}
var i = double.Parse(numStr.ToString());
return new SyntaxToken(SyntaxKind.Number, start, numStr.ToString(), i);
object o;
if (hasDecimalPoint)
o = double.Parse(numStr.ToString());
else
o = long.Parse(numStr.ToString());
return new SyntaxToken(SyntaxKind.Number, start, numStr.ToString(), o);
}
private SyntaxToken LexIdentifierOrKeyword()