Class SingleRuleApplication
Denotes a type of rule application that includes zero or one inner rule applications
public class SingleRuleApplication : RuleApplication
- Inheritance
-
SingleRuleApplication
- Derived
- Inherited Members
Constructors
SingleRuleApplication(Rule, RuleApplication, ParsePositionDelta, ParsePositionDelta)
Creates a new rule application
public SingleRuleApplication(Rule rule, RuleApplication inner, ParsePositionDelta length, ParsePositionDelta examinedTo)
Parameters
ruleRulethe rule that the rule application references
innerRuleApplicationthe inner rule application, if any
lengthParsePositionDeltathe length of the rule application
examinedToParsePositionDeltaa length until which the text was examined to conclude this rule application
Properties
Children
Gets the child rule applications
public override IEnumerable<RuleApplication> Children { get; }
Property Value
Inner
Gets the inner rule application
public RuleApplication Inner { get; }
Property Value
PotentialError
Denotes a potential error to improve error reporting
public override RuleApplication PotentialError { 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
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
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
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
OnMigrate(RuleApplication, RuleApplication, ParseContext)
protected virtual void OnMigrate(RuleApplication oldValue, RuleApplication newValue, ParseContext context)
Parameters
oldValueRuleApplicationnewValueRuleApplicationcontextParseContext
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