Skip to content

Commit f9d490f

Browse files
Update NumberToken.cs
1 parent 24caf0c commit f9d490f

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

TokenSystem/Tokens/NumberToken.cs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using SER.Helpers.ResultSystem;
2-
using SER.ScriptSystem;
1+
using SER.ScriptSystem;
32
using SER.ValueSystem;
43

54
namespace SER.TokenSystem.Tokens;
@@ -8,27 +7,18 @@ public class NumberToken : LiteralValueToken<NumberValue>
87
{
98
protected override IParseResult InternalParse(Script scr)
109
{
11-
if (TryParse(RawRep).WasSuccessful(out var value))
10+
if (decimal.TryParse(RawRep, out var value))
1211
{
1312
Value = value;
1413
return new Success();
1514
}
1615

17-
return new Ignore();
18-
}
19-
20-
public static TryGet<decimal> TryParse(string stringRep)
21-
{
22-
if (decimal.TryParse(stringRep, out var value))
16+
if (RawRep.EndsWith("%") && decimal.TryParse(RawRep.TrimEnd('%'), out value))
2317
{
24-
return value;
25-
}
26-
27-
if (stringRep.EndsWith("%") && decimal.TryParse(stringRep.TrimEnd('%'), out value))
28-
{
29-
return value / 100;
18+
Value = value / 100;
19+
return new Success();
3020
}
3121

32-
return $"Value '{stringRep}' is not a valid number";
22+
return new Ignore();
3323
}
3424
}

0 commit comments

Comments
 (0)