Camera Information System
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.1 KiB

namespace EC.Helper.RabbitFunc.Syntax;
internal abstract class Token
{
private TokenKind kind;
protected Token(TokenKind kind)
{
this.kind = kind;
}
public abstract string Text { get; }
public TokenKind Kind => kind;
public virtual double Value
{
get => throw new System.NotSupportedException();
}
public static Token Error(string message)
{
return new ErrorToken(message);
}
public static Token Operator(TokenKind kind, string @operator, byte precedence)
{
return new OperatorToken(kind, @operator, precedence);
}
public static Token Symbol(TokenKind kind, string symbol)
{
return new SymbolToken(kind, symbol);
}
public static Token Constant(double value)
{
return new ConstantToken(value);
}
public static Token Comment(string text)
{
return new CommentToken(text);
}
public static Token Identifier(string name)
{
return new IdentifierToken(name);
}
public override string ToString()
{
return Text.ToString();
}
}