From f6cc23d66897774a5050be21288450722e01b0db Mon Sep 17 00:00:00 2001 From: Harald Wolff Date: Tue, 24 Nov 2020 23:10:41 +0100 Subject: [PATCH] Added Token.NativeValue --- ln.parse/ln.parse.csproj | 2 +- ln.parse/tokenizer/Token.cs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ln.parse/ln.parse.csproj b/ln.parse/ln.parse.csproj index c5b27a7..728ed32 100644 --- a/ln.parse/ln.parse.csproj +++ b/ln.parse/ln.parse.csproj @@ -2,7 +2,7 @@ netcoreapp3.1 - 0.0.3 + 0.0.4 Harald Wolff-Thobaben l--n.de diff --git a/ln.parse/tokenizer/Token.cs b/ln.parse/tokenizer/Token.cs index 361c22e..661249a 100644 --- a/ln.parse/tokenizer/Token.cs +++ b/ln.parse/tokenizer/Token.cs @@ -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]; } } }