Table of Contents

Class Parser

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

An immutable implementation of the IParser interface.

public class Parser : IParser
Inheritance
Parser
Implements
Inherited Members
Extension Methods

Constructors

Parser(IEnumerable<IExpressionFactory<IToken>>, bool)

public Parser(IEnumerable<IExpressionFactory<IToken>> factories, bool caseSensitive)

Parameters

factories IEnumerable<IExpressionFactory<IToken>>
caseSensitive bool

Properties

CaseSensitive

Indicates whether this parser performs case-sensitive matching for keywords and identifiers.

public bool CaseSensitive { get; }

Property Value

bool

Methods

BuildPostfixStack(Queue<IToken>)

Converts a token queue from infix notation to postfix (reverse Polish) notation using the shunting-yard algorithm.

public Stack<IToken> BuildPostfixStack(Queue<IToken> queue)

Parameters

queue Queue<IToken>

The token queue in infix notation.

Returns

Stack<IToken>

A stack of tokens in postfix notation for tree construction.

CreateTree(Stack<IToken>)

Constructs an abstract syntax tree from a postfix token stack.

public IExpression CreateTree(Stack<IToken> postfix)

Parameters

postfix Stack<IToken>

The token stack in postfix notation.

Returns

IExpression

The root expression node of the constructed syntax tree.

Tokenize(string)

Parses an expression string from left to right and produces a queue of tokens in infix notation.

public Queue<IToken> Tokenize(string expression)

Parameters

expression string

The expression string to tokenize.

Returns

Queue<IToken>

A queue of tokens in the order they appear in the expression.