Path: redb-route/redb.Route/Expressions/Ast/Token.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route/Expressions/Ast/Token.cs
----
using System;
namespace redb.Route.Expressions.Ast;
///
/// Enumerates the types of tokens recognized by the expression tokenizer.
///
public enum TokenType
{
/// Numeric literal (integer or floating-point).
Number,
/// String literal (single- or double-quoted).
String,
/// Identifier such as a variable name or keyword.
Identifier,
/// Operator symbol (arithmetic, comparison, or logical).
Operator,
/// Left parenthesis (.
LeftParen,
/// Right parenthesis ).
RightParen,
/// Comma separator ,.
Comma,
/// Dot (property access) ..
Dot,
/// Left bracket [.
LeftBracket,
/// Right bracket ].
RightBracket,
/// Function name (identifier followed by an opening parenthesis).
Function,
/// Colon : used in ternary expressions.
Colon,
/// End-of-input marker.
Eof,
// Appended, not inserted: the numeric values above stay as they were.
/// A function namespace with its colon, bean:: the target and the call follow.
Namespace,
/// ${ inside an expression, allowed in the arguments of a namespaced call.
PlaceholderOpen,
/// }, closing a .
RightBrace,
}
///
/// Represents a single token produced by lexical analysis.
///
public class Token
{
///
/// Gets the type of this token.
///
public TokenType Type { get; }
///
/// Gets the textual value of this token.
///
public string Value { get; }
///
/// Gets the position (zero-based index) of this token in the input string.
///
public int Position { get; }
///
/// Initializes a new instance of the class.
///
/// The token type.
/// The textual value of the token.
/// The position of the token in the input string.
public Token(TokenType type, string value, int position)
{
Type = type;
Value = value;
Position = position;
}
///
public override string ToString() => $"{Type}({Value})";
}