Class RegexRule
Denotes a rule that parses text based on regular expressions
public class RegexRule : Rule
- Inheritance
-
RegexRule
- Derived
- Inherited Members
Remarks
Regular expressions are always restricted to a single line, only
Properties
IsLiteral
True, if the rule contributes characters, otherwise false
public override bool IsLiteral { get; }
Property Value
Regex
Gets or sets the regular expression
public Regex Regex { get; set; }
Property Value
TokenType
Gets the token type of tokens created for this rule
public override string TokenType { get; }
Property Value
Methods
CanStartWith(Rule, List<Rule>)
Indicates whether the rule could start with the given other rule
protected override bool CanStartWith(Rule rule, List<Rule> trace)
Parameters
Returns
- bool
true, if the rule could start with the given other rule, otherwise false
CanSynthesize(object, ParseContext, SynthesisPlan)
Determines whether the current rule can synthesize rule applications for the given semantic element
public override bool CanSynthesize(object semanticElement, ParseContext context, SynthesisPlan synthesisPlan)
Parameters
semanticElementobjectthe semantic element
contextParseContextthe context in which the rule is synthesized
synthesisPlanSynthesisPlanthe plan of the synthesis
Returns
- bool
true, if a rule application can be synthesized, otherwise false
CreateRuleApplication(string, ParsePosition, ParsePositionDelta, ParseContext)
Creates a new rule application
public virtual RuleApplication CreateRuleApplication(string matched, ParsePosition position, ParsePositionDelta examined, ParseContext context)
Parameters
matchedstringthe matched string content
positionParsePositionthe position where the rule matched
examinedParsePositionDeltathe examined length of text
contextParseContextthe parse context
Returns
- RuleApplication
a rule application
IsEpsilonAllowed(List<Rule>)
Determines whether the rule could capture empty input
protected override bool IsEpsilonAllowed(List<Rule> trace)
Parameters
Returns
- bool
true, if the rule can be expanded to an empty string, otherwise false
Match(ParseContext, RecursionContext, ref ParsePosition)
Matches the the context at the provided position
public override RuleApplication Match(ParseContext context, RecursionContext recursionContext, ref ParsePosition position)
Parameters
contextParseContextthe context in which the rule is matched
recursionContextRecursionContextthe recursion context of the matching
positionParsePositionthe position in the input
Returns
- RuleApplication
the rule application for the provided position
Synthesize(object, ParsePosition, ParseContext)
Synthesizes a rule application for the given semantic element
public override RuleApplication Synthesize(object semanticElement, ParsePosition position, ParseContext context)
Parameters
semanticElementobjectpositionParsePositionthe parse position at which the element should be synthesized
contextParseContextthe parse context
Returns
- RuleApplication
a rule application