Class LiteralRuleApplication
Denotes a rule application that matches a given literal string
public class LiteralRuleApplication : RuleApplication
- Inheritance
-
LiteralRuleApplication
- Inherited Members
Constructors
LiteralRuleApplication(Rule, string, ParsePositionDelta)
Creates a new instance
public LiteralRuleApplication(Rule rule, string literal, ParsePositionDelta examinedTo)
Parameters
ruleRulethe rule
literalstringthe matched literal
examinedToParsePositionDelta
LiteralRuleApplication(Rule, string, ParsePositionDelta, ParsePositionDelta)
Creates a new instance
public LiteralRuleApplication(Rule rule, string literal, ParsePositionDelta length, ParsePositionDelta examinedTo)
Parameters
ruleRulethe rule
literalstringthe matched literal
lengthParsePositionDeltathe length (use in case of multiline literals)
examinedToParsePositionDelta
Properties
Literal
Gets the matched literal
public string Literal { get; }
Property Value
SemanticElement
Gets the semantic element of the rule application
public override object SemanticElement { get; }
Property Value
Methods
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
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>, 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<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
OnMigrate(string, string, ParseContext)
Gets called when the rule application is migrated
protected virtual void OnMigrate(string oldValue, string newValue, ParseContext context)
Parameters
oldValuestringthe old literal
newValuestringthe new literal
contextParseContextthe parse context
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