Class MultiRuleApplication
Represents a rule application with multiple inner rule applications
public class MultiRuleApplication : RuleApplication
- Inheritance
-
MultiRuleApplication
- Inherited Members
Constructors
MultiRuleApplication(Rule, List<RuleApplication>, ParsePositionDelta, ParsePositionDelta)
Creates a new instance
public MultiRuleApplication(Rule rule, List<RuleApplication> inner, ParsePositionDelta length, ParsePositionDelta examinedTo)
Parameters
ruleRulethe rule referenced by this rule application
innerList<RuleApplication>the inner rule applications
lengthParsePositionDeltathe length of the rule application
examinedToParsePositionDeltathe span that was used to conclude the rule application
Properties
Children
Gets the child rule applications
public override IEnumerable<RuleApplication> Children { get; }
Property Value
Inner
Gets a list of inner rule applications
public List<RuleApplication> Inner { get; }
Property Value
SemanticElement
Gets the semantic element of the rule application
public override object SemanticElement { get; }
Property Value
Methods
Activate(ParseContext, bool)
Activates the rule application, i.e. marks it as part of the current parse tree
public override void Activate(ParseContext context, bool initial)
Parameters
contextParseContextthe context in which the parse tree exists
initialboolflag to indicate whether the activation is part of the initial parse
AddParseErrors(ParseContext)
Gets a collection of parse errors represented by this rule application
public override void AddParseErrors(ParseContext context)
Parameters
contextParseContextthe parse context in which the parse errors are requested
ApplyTo(RuleApplication, ParseContext)
Applies the structure of the current rule application to the given other rule application
public override RuleApplication ApplyTo(RuleApplication other, ParseContext context)
Parameters
otherRuleApplicationthe rule application to which the rule should be applied
contextParseContextthe parse context
Returns
- RuleApplication
the merged rule application
CalculateIndex(RuleApplication)
Calculates an insertion index
public override int CalculateIndex(RuleApplication ruleApplication)
Parameters
ruleApplicationRuleApplicationthe rule application for which to calculate the index
Returns
- int
an index or -1, if no index could be found
CalculateIndex(RuleApplication, Stack<Rule>)
Calculates an insertion index
public override int CalculateIndex(RuleApplication ruleApplication, Stack<Rule> ruleStack)
Parameters
ruleApplicationRuleApplicationthe rule application for which to calculate the index
ruleStackStack<Rule>a rule stack that needs to match
Returns
- int
an index or -1, if no index could be found
ContinueToNextToken(RuleApplication, PrettyPrintWriter, ParseContext)
Writes white spaces until the next token
public override bool ContinueToNextToken(RuleApplication childRuleApplication, PrettyPrintWriter writer, ParseContext context)
Parameters
childRuleApplicationRuleApplicationthe child rule application that was written last
writerPrettyPrintWriterthe pretty print writer to write to
contextParseContextthe parse context
Returns
- bool
true, if a token was produced, otherwise false
Deactivate(ParseContext)
Deactivates the rule application, i.e. unmarks it as part of the parse tree
public override void Deactivate(ParseContext context)
Parameters
contextParseContextthe context in which the parse tree exists
FindChildAt(ParsePosition, Rule)
Gets the child rule application at the given position
public override RuleApplication FindChildAt(ParsePosition position, Rule rule)
Parameters
positionParsePositionThe position
ruleRuleThe expected rule of the child
Returns
- RuleApplication
The child at the given position or null
GetFirstInnerLiteral()
Calculates the first literal within this rule application
public override LiteralRuleApplication GetFirstInnerLiteral()
Returns
- LiteralRuleApplication
the first literal rule application or null
GetIdentifier()
Gets the first contained rule application that represents an identifier
public override RuleApplication GetIdentifier()
Returns
- RuleApplication
The rule application for the literal rule representing the identifier
GetLastInnerLiteral()
Calculates the last literal within this rule application
public override LiteralRuleApplication GetLastInnerLiteral()
Returns
- LiteralRuleApplication
the last literal rule application or null
GetLiteralAt(ParsePosition, bool)
Gets the literal at the given position
public override RuleApplication GetLiteralAt(ParsePosition position, bool onlyActive = false)
Parameters
positionParsePositionthe position
onlyActiveboolwhether to only return an active rule application (default: false)
Returns
- RuleApplication
the literal rule application or null, if there is no literal there
GetValue(ParseContext)
Gets the parsed newPosition under the given context
public override object GetValue(ParseContext context)
Parameters
contextParseContextthe parse context
Returns
- object
the parsed newPosition
IsStack(Stack<Rule>)
Determines whether the rule application contains a tree of the given rule stack
public override bool IsStack(Stack<Rule> ruleStack)
Parameters
Returns
- bool
true, if the application contains a tree of the given rule stack, otherwise false
IterateLiterals(Action<LiteralRuleApplication>, ParsePosition, ParsePosition, bool)
Iterate over all literals
public override void IterateLiterals(Action<LiteralRuleApplication> action, ParsePosition from, ParsePosition to, bool includeFailures)
Parameters
actionAction<LiteralRuleApplication>the action that should be performed for all literals
fromParsePositionthe inclusive position from which the literals should be iterated
toParsePositionthe inclusive position to which the literals should be iterated
includeFailuresbooltrue, if failed rule applications should be considered, otherwise false
IterateLiterals(Action<LiteralRuleApplication>, bool)
Iterate over all literals
public override void IterateLiterals(Action<LiteralRuleApplication> action, bool includeFailures)
Parameters
actionAction<LiteralRuleApplication>the action that should be performed for all literals
includeFailuresbooltrue, if failed rule applications should be considered, otherwise false
IterateLiterals(Func<LiteralRuleApplication, bool>, ParsePosition, bool)
Iterate over all literals
public override bool IterateLiterals(Func<LiteralRuleApplication, bool> action, ParsePosition from, bool includeFailures)
Parameters
actionFunc<LiteralRuleApplication, bool>the action that should be performed for all literals
fromParsePositionthe inclusive position from which the literals should be iterated
includeFailuresbooltrue, if failed rule applications should be considered, otherwise false
Returns
IterateLiterals(Func<LiteralRuleApplication, bool>, bool)
Iterate over all literals
public override bool IterateLiterals(Func<LiteralRuleApplication, bool> action, bool includeFailures)
Parameters
actionFunc<LiteralRuleApplication, bool>the action that should be performed for all literals
includeFailuresbooltrue, if failed rule applications should be considered, otherwise false
Returns
IterateLiterals<T>(Action<LiteralRuleApplication, T>, T, bool)
Iterate over all literals
public override void IterateLiterals<T>(Action<LiteralRuleApplication, T> action, T parameter, bool includeFailures)
Parameters
actionAction<LiteralRuleApplication, T>the action that should be performed for all literals
parameterTthe parameter
includeFailuresbooltrue, if failed rule applications should be considered, otherwise false
Type Parameters
Tthe parameter type
OnContextChange(object, object, ParseContext)
Gets called when the context of this rule application changes
protected override void OnContextChange(object oldContext, object newContext, ParseContext context)
Parameters
oldContextobjectthe old context element
newContextobjectthe new context element
contextParseContextthe parse context
Recover(RuleApplication, ParseContext, out ParsePosition)
Tries to recover the given rule application
public override RuleApplication Recover(RuleApplication currentRoot, ParseContext context, out ParsePosition position)
Parameters
currentRootRuleApplicationthe current root rule application
contextParseContextthe parse context in which a recovery is attempted
positionParsePositionthe parse position after recovery
Returns
- RuleApplication
the recovered rule application
ReplaceChild(RuleApplication, RuleApplication, ParseContext)
Replaces the given child rule application with the given new child
public override void ReplaceChild(RuleApplication childApplication, RuleApplication newChild, ParseContext context)
Parameters
childApplicationRuleApplicationthe child rule application
newChildRuleApplicationa new child
contextParseContextthe context in which the child is replaced
Validate(ParseContext)
Validates the rule semantically
public override void Validate(ParseContext context)
Parameters
contextParseContextthe parse context in which the rule is validated
Write(PrettyPrintWriter, ParseContext)
Writes the given rule application to the provided text writer
public override void Write(PrettyPrintWriter writer, ParseContext context)
Parameters
writerPrettyPrintWriterthe writer to which the rule application should be written
contextParseContextthe parse context