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
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
parserIParserThe parser instance to use.
expressionstringThe expression string to parse and evaluate.
contextIExecutionContext<T>The execution context for variable resolution.
tTThe input object containing context data.
Returns
- object
The result of evaluating the expression.
Type Parameters
TThe 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
textstringThe text to parse.
regexRegexThe regular expression pattern to match.
captureFunc<Match, string>Function to extract the captured value from the match.
funcFunc<string, T>Function to create the token from the captured value.
startintThe starting position in the text.
nextintWhen this method returns, contains the position after the matched text.
Returns
- T
The created token if the pattern matched; otherwise, null.
Type Parameters
TThe type of token to create.