Added Token.NativeValue

master
Harald Wolff 2020-11-24 23:10:41 +01:00
parent 7f7f1e68be
commit f6cc23d668
2 changed files with 10 additions and 1 deletions

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Version>0.0.3</Version>
<Version>0.0.4</Version>
<Authors>Harald Wolff-Thobaben</Authors>
<Company>l--n.de</Company>
</PropertyGroup>

View File

@ -29,33 +29,42 @@ namespace ln.parse.tokenizer
public string TokenSource => SourceBuffer.GetText(LinearStart, Length);
public virtual object NativeValue { get; }
public class IntegerToken : Token
{
public IntegerToken(SourceBuffer sourceBuffer, int start, int length, string value) : base(sourceBuffer, start, length, value) { }
public override object NativeValue => Int32.Parse(Value);
}
public class FloatToken : Token
{
public FloatToken(SourceBuffer sourceBuffer, int start, int length, string value) : base(sourceBuffer, start, length, value) { }
public override object NativeValue => Double.Parse(Value);
}
public class StringToken : Token
{
public StringToken(SourceBuffer sourceBuffer, int start, int length, string value) : base(sourceBuffer, start, length, value) { }
public override object NativeValue => Value;
}
public class OperatorToken : Token
{
public OperatorToken(SourceBuffer sourceBuffer, int start, int length, string value) : base(sourceBuffer, start, length, value) { }
public override object NativeValue => Value[0];
}
public class WhiteSpaceToken : Token
{
public WhiteSpaceToken(SourceBuffer sourceBuffer, int start, int length, string value) : base(sourceBuffer, start, length, value) { }
public override object NativeValue => Value;
}
public class IdentifierToken : Token
{
public IdentifierToken(SourceBuffer sourceBuffer, int start, int length, string value) : base(sourceBuffer, start, length, value) { }
public override object NativeValue => Value;
}
public class BracketToken : Token
{
public BracketToken(SourceBuffer sourceBuffer, int start, int length, string value) : base(sourceBuffer, start, length, value) { }
public override object NativeValue => Value[0];
}
}
}