Table of Contents

Class Extensions

Namespace
Albatross.Expression.Parsing
Assembly
Albatross.Expression.dll

Provides extension methods for parser operations and convenience methods.

public static class Extensions
Inheritance
Extensions
Inherited Members

Methods

Build(IParser, string)

Builds an expression tree from the given expression string.

public static IExpression Build(this IParser parser, string expression)

Parameters

parser IParser

The parser instance to use.

expression string

The expression string to parse.

Returns

IExpression

The parsed expression tree.

Eval<T>(IParser, string, IExecutionContext<T>, T)

Parses and evaluates an expression string using the provided execution context.

public static object Eval<T>(this IParser parser, string expression, IExecutionContext<T> context, T t)

Parameters

parser IParser

The parser instance to use.

expression string

The expression string to parse and evaluate.

context IExecutionContext<T>

The execution context for variable resolution.

t T

The input object containing context data.

Returns

object

The result of evaluating the expression.

Type Parameters

T

The type of input object for the execution context.

RegexParse<T>(string, Regex, Func<Match, string>, Func<string, T>, int, out int)

Parses a token from text using a regular expression pattern.

public static T? RegexParse<T>(this string text, Regex regex, Func<Match, string> capture, Func<string, T> func, int start, out int next) where T : class

Parameters

text string

The text to parse.

regex Regex

The regular expression pattern to match.

capture Func<Match, string>

Function to extract the captured value from the match.

func Func<string, T>

Function to create the token from the captured value.

start int

The starting position in the text.

next int

When this method returns, contains the position after the matched text.

Returns

T

The created token if the pattern matched; otherwise, null.

Type Parameters

T

The type of token to create.