35 lines
668 B
C#
35 lines
668 B
C#
namespace Parsing.Tokenization;
|
|
|
|
using Parsing.Schema;
|
|
|
|
public class CustomToken<T> : IValueToken<T>
|
|
{
|
|
private string word;
|
|
|
|
private InputType definedInputType;
|
|
|
|
private Func<string, T> wordConverter;
|
|
|
|
public CustomToken(string word, InputType definedInputType, Func<string, T> wordConverter)
|
|
{
|
|
this.word = word;
|
|
this.wordConverter = wordConverter;
|
|
this.definedInputType = definedInputType;
|
|
}
|
|
|
|
public string GetText()
|
|
{
|
|
return word;
|
|
}
|
|
|
|
public T GetValue()
|
|
{
|
|
return wordConverter(word);
|
|
}
|
|
|
|
public InputType GetInputType()
|
|
{
|
|
return this.definedInputType;
|
|
}
|
|
}
|