Table of Contents

Class LogicClauseBuilder

Namespace
RandomizerCore.StringLogic
Assembly
RandomizerCore.dll
public class LogicClauseBuilder
Inheritance
LogicClauseBuilder
Inherited Members

Constructors

LogicClauseBuilder()

Initializes an empty LCB. The only valid operation on an empty LCB is Append with a TermToken.

public LogicClauseBuilder()

LogicClauseBuilder(LogicClause)

public LogicClauseBuilder(LogicClause c)

Parameters

c LogicClause

LogicClauseBuilder(LogicClauseBuilder)

public LogicClauseBuilder(LogicClauseBuilder lcb)

Parameters

lcb LogicClauseBuilder

LogicClauseBuilder(TermToken)

public LogicClauseBuilder(TermToken t)

Parameters

t TermToken

LogicClauseBuilder(IEnumerable<LogicToken>)

public LogicClauseBuilder(IEnumerable<LogicToken> lts)

Parameters

lts IEnumerable<LogicToken>

LogicClauseBuilder(string, ITokenSource)

public LogicClauseBuilder(string infix, ITokenSource tokenSource)

Parameters

infix string
tokenSource ITokenSource

Fields

Tokens

public readonly ReadOnlyCollection<LogicToken> Tokens

Field Value

ReadOnlyCollection<LogicToken>

Properties

Arguments

public int Arguments { get; }

Property Value

int

Complete

public bool Complete { get; }

Property Value

bool

Methods

AndWith(LogicClause)

public void AndWith(LogicClause c)

Parameters

c LogicClause

AndWith(LogicClauseBuilder)

public void AndWith(LogicClauseBuilder lcb)

Parameters

lcb LogicClauseBuilder

AndWith(TermToken)

public void AndWith(TermToken t)

Parameters

t TermToken

AndWith(IEnumerable<LogicToken>)

public void AndWith(IEnumerable<LogicToken> ts)

Parameters

ts IEnumerable<LogicToken>

AndWith(string, ITokenSource)

public void AndWith(string infix, ITokenSource tokenSource)

Parameters

infix string
tokenSource ITokenSource

AndWithLeft(LogicClause)

public void AndWithLeft(LogicClause c)

Parameters

c LogicClause

AndWithLeft(LogicClauseBuilder)

public void AndWithLeft(LogicClauseBuilder lcb)

Parameters

lcb LogicClauseBuilder

AndWithLeft(TermToken)

public void AndWithLeft(TermToken t)

Parameters

t TermToken

AndWithLeft(string, ITokenSource)

public void AndWithLeft(string infix, ITokenSource tokenSource)

Parameters

infix string
tokenSource ITokenSource

Append(LogicClause)

public void Append(LogicClause c)

Parameters

c LogicClause

Append(LogicClauseBuilder)

public void Append(LogicClauseBuilder lcb)

Parameters

lcb LogicClauseBuilder

Append(LogicToken)

public void Append(LogicToken lt)

Parameters

lt LogicToken

Append(OperatorToken)

public void Append(OperatorToken ot)

Parameters

ot OperatorToken

Append(TermToken)

public void Append(TermToken tt)

Parameters

tt TermToken

Append(IEnumerable<LogicToken>)

public void Append(IEnumerable<LogicToken> lts)

Parameters

lts IEnumerable<LogicToken>

Append(string)

public void Append(string infix)

Parameters

infix string

Clear()

public void Clear()

Coalesce(Func<TermToken, bool>)

Replaces CoalescingTokens with their result as determined by the delegate. Acts recursively on nested coalescing expressions.

public void Coalesce(Func<TermToken, bool> tokenValidator)

Parameters

tokenValidator Func<TermToken, bool>

OrWith(LogicClause)

public void OrWith(LogicClause c)

Parameters

c LogicClause

OrWith(LogicClauseBuilder)

public void OrWith(LogicClauseBuilder lcb)

Parameters

lcb LogicClauseBuilder

OrWith(TermToken)

public void OrWith(TermToken t)

Parameters

t TermToken

OrWith(IEnumerable<LogicToken>)

public void OrWith(IEnumerable<LogicToken> ts)

Parameters

ts IEnumerable<LogicToken>

OrWith(string, ITokenSource)

public void OrWith(string infix, ITokenSource tokenSource)

Parameters

infix string
tokenSource ITokenSource

OrWithLeft(LogicClause)

public void OrWithLeft(LogicClause c)

Parameters

c LogicClause

OrWithLeft(LogicClauseBuilder)

public void OrWithLeft(LogicClauseBuilder lcb)

Parameters

lcb LogicClauseBuilder

OrWithLeft(TermToken)

public void OrWithLeft(TermToken t)

Parameters

t TermToken

OrWithLeft(string, ITokenSource)

public void OrWithLeft(string infix, ITokenSource tokenSource)

Parameters

infix string
tokenSource ITokenSource

PartialCoalesce(Func<TermToken, bool?>)

Replaces CoalescingTokens with their result as determined by the delegate. If the delegate returns null, the CoalescingToken is left in place. Acts recursively on nested coalescing expressions, provided the delegate returns nonnull.

public void PartialCoalesce(Func<TermToken, bool?> tokenValidator)

Parameters

tokenValidator Func<TermToken, bool?>

PushOut(Func<TermToken, bool>, OperatorToken)

Distributes nested occurences of the inner operation acting on the specified tokens.
That is, if innerOp is OperatorToken.OR, then the result will decompose as a disjunction of clauses, such that within each clause, any disjunction does not contain any specified tokens.
For example, if we push out token D, operator OR in "A | B + (C | D + (E | F) | G) | H", the result is "A | B + (C | G) | B + D + (E | F) | H".

public void PushOut(Func<TermToken, bool> predicate, OperatorToken innerOp)

Parameters

predicate Func<TermToken, bool>
innerOp OperatorToken

PushOut<T>(OperatorToken)

Distributes nested occurences of the inner operation acting on tokens of the type parameter.
That is, if innerOp is OperatorToken.OR, then the result will decompose as a disjunction of clauses, such that within each clause, any disjunction does not contain any specified tokens.
For example, if we push out token D, operator OR in "A | B + (C | D + (E | F) | G) | H", the result is "A | B + (C | G) | B + D + (E | F) | H".

public void PushOut<T>(OperatorToken innerOp) where T : TermToken

Parameters

innerOp OperatorToken

Type Parameters

T

Simpl()

Reduces ConstTokens from the expression.

public void Simpl()

Subst(TermToken, LogicClause)

Replaces all occurences that match the old token with the new clause. Is not recursive--it is safe to reference the old token inside the new clause.

public void Subst(TermToken oldToken, LogicClause newClause)

Parameters

oldToken TermToken
newClause LogicClause

Subst(TermToken, TermToken)

Replaces all occurences that match the old token with the new token.

public void Subst(TermToken oldToken, TermToken newToken)

Parameters

oldToken TermToken
newToken TermToken

ToInfix()

public string ToInfix()

Returns

string

Transform(Func<TermToken, TermToken?>)

Applies the delegate to each term in the expression. If the result of the delegate is not null, replaces the term at that position with the result.
Returns the number of modified tokens.

public int Transform(Func<TermToken, TermToken?> transformer)

Parameters

transformer Func<TermToken, TermToken>

Returns

int

Unfold()

Replaces MacroTokens with the clauses they represent. Acts recursively on the inserted clauses.

public void Unfold()

Unfold(Func<string, LogicClause>)

Replaces MacroTokens and ReferenceTokens with the clauses they represent. Acts recursively on the inserted clauses.

public void Unfold(Func<string, LogicClause> referenceResolver)

Parameters

referenceResolver Func<string, LogicClause>