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
rule
Rulethe rule
literal
stringthe matched literal
examinedTo
ParsePositionDelta
LiteralRuleApplication(Rule, string, ParsePositionDelta, ParsePositionDelta)
Creates a new instance
public LiteralRuleApplication(Rule rule, string literal, ParsePositionDelta length, ParsePositionDelta examinedTo)
Parameters
rule
Rulethe rule
literal
stringthe matched literal
length
ParsePositionDeltathe length (use in case of multiline literals)
examinedTo
ParsePositionDelta
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
other
RuleApplicationthe rule application to which the rule should be applied
context
ParseContextthe 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)
Gets the literal at the given position
public override RuleApplication GetLiteralAt(ParsePosition position)
Parameters
position
ParsePositionthe position
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
context
ParseContextthe parse context
Returns
- object
the parsed newPosition
IterateLiterals(Action<LiteralRuleApplication>)
Iterate over all literals
public override void IterateLiterals(Action<LiteralRuleApplication> action)
Parameters
action
Action<LiteralRuleApplication>the action that should be performed for all literals
IterateLiterals<T>(Action<LiteralRuleApplication, T>, T)
Iterate over all literals
public override void IterateLiterals<T>(Action<LiteralRuleApplication, T> action, T parameter)
Parameters
action
Action<LiteralRuleApplication, T>the action that should be performed for all literals
parameter
Tthe parameter
Type Parameters
T
the 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
oldValue
stringthe old literal
newValue
stringthe new literal
context
ParseContextthe parse context
Write(PrettyPrintWriter, ParseContext)
Writes the given rule application to the provided text writer
public override void Write(PrettyPrintWriter writer, ParseContext context)
Parameters
writer
PrettyPrintWriterthe writer to which the rule application should be written
context
ParseContextthe parse context