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
LogicClauseBuilder(LogicClauseBuilder)
public LogicClauseBuilder(LogicClauseBuilder lcb)
Parameters
LogicClauseBuilder(TermToken)
public LogicClauseBuilder(TermToken t)
Parameters
LogicClauseBuilder(IEnumerable<LogicToken>)
public LogicClauseBuilder(IEnumerable<LogicToken> lts)
Parameters
lts
IEnumerable<LogicToken>
LogicClauseBuilder(string, ITokenSource)
public LogicClauseBuilder(string infix, ITokenSource tokenSource)
Parameters
infix
stringtokenSource
ITokenSource
Fields
Tokens
public readonly ReadOnlyCollection<LogicToken> Tokens
Field Value
Properties
Arguments
public int Arguments { get; }
Property Value
Complete
public bool Complete { get; }
Property Value
Methods
AndWith(LogicClause)
public void AndWith(LogicClause c)
Parameters
AndWith(LogicClauseBuilder)
public void AndWith(LogicClauseBuilder lcb)
Parameters
AndWith(TermToken)
public void AndWith(TermToken t)
Parameters
AndWith(IEnumerable<LogicToken>)
public void AndWith(IEnumerable<LogicToken> ts)
Parameters
AndWith(string, ITokenSource)
public void AndWith(string infix, ITokenSource tokenSource)
Parameters
infix
stringtokenSource
ITokenSource
AndWithLeft(LogicClause)
public void AndWithLeft(LogicClause c)
Parameters
AndWithLeft(LogicClauseBuilder)
public void AndWithLeft(LogicClauseBuilder lcb)
Parameters
AndWithLeft(TermToken)
public void AndWithLeft(TermToken t)
Parameters
AndWithLeft(string, ITokenSource)
public void AndWithLeft(string infix, ITokenSource tokenSource)
Parameters
infix
stringtokenSource
ITokenSource
Append(LogicClause)
public void Append(LogicClause c)
Parameters
Append(LogicClauseBuilder)
public void Append(LogicClauseBuilder lcb)
Parameters
Append(LogicToken)
public void Append(LogicToken lt)
Parameters
lt
LogicToken
Append(OperatorToken)
public void Append(OperatorToken ot)
Parameters
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
OrWith(LogicClause)
public void OrWith(LogicClause c)
Parameters
OrWith(LogicClauseBuilder)
public void OrWith(LogicClauseBuilder lcb)
Parameters
OrWith(TermToken)
public void OrWith(TermToken t)
Parameters
OrWith(IEnumerable<LogicToken>)
public void OrWith(IEnumerable<LogicToken> ts)
Parameters
OrWith(string, ITokenSource)
public void OrWith(string infix, ITokenSource tokenSource)
Parameters
infix
stringtokenSource
ITokenSource
OrWithLeft(LogicClause)
public void OrWithLeft(LogicClause c)
Parameters
OrWithLeft(LogicClauseBuilder)
public void OrWithLeft(LogicClauseBuilder lcb)
Parameters
OrWithLeft(TermToken)
public void OrWithLeft(TermToken t)
Parameters
OrWithLeft(string, ITokenSource)
public void OrWithLeft(string infix, ITokenSource tokenSource)
Parameters
infix
stringtokenSource
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
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
TermTokennewClause
LogicClause
Subst(TermToken, TermToken)
Replaces all occurences that match the old token with the new token.
public void Subst(TermToken oldToken, TermToken newToken)
Parameters
ToInfix()
public string ToInfix()
Returns
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
Returns
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>