Class Rule
Denotes a rule for parsing rules
public abstract class Rule
- Inheritance
-
Rule
- Derived
- Inherited Members
Properties
Continuations
Gets a collection of recursive continuations for this rule
public IReadOnlyCollection<RecursiveContinuation> Continuations { get; }
Property Value
IsComment
True, if the rule is ignored in the parse tree, otherwise false
public virtual bool IsComment { get; }
Property Value
IsDefinition
True, if the application of this rule denotes a definition
public virtual bool IsDefinition { get; }
Property Value
IsIdentifier
True, if the rule application of this rule denotes an identifier
public virtual bool IsIdentifier { get; }
Property Value
IsLeftRecursive
Indicates whether the rule is recursive
public bool IsLeftRecursive { get; }
Property Value
IsLiteral
True, if the rule contributes characters, otherwise false
public virtual bool IsLiteral { get; }
Property Value
IsReference
True, if the application of this rule denotes a reference
public virtual bool IsReference { get; }
Property Value
Name
Gets or sets the name of this rule
public string Name { get; set; }
Property Value
PassAlongDocumentSymbols
True, if inner document symbols should be passed on to be handled separately, e.g. if the inner elements of the corresponding rule application should be visible in the outline, but not the rule application itself
public bool PassAlongDocumentSymbols { get; }
Property Value
SymbolKind
Gets the kind of document symbol to be used for this rule
public virtual SymbolKind SymbolKind { get; }
Property Value
TokenModifierIndex
Gets the index of the token modifiers
public uint? TokenModifierIndex { get; }
Property Value
- uint?
TokenModifiers
Gets the token modifiers of
public virtual string[] TokenModifiers { get; }
Property Value
- string[]
TokenType
Gets the token type of tokens created for this rule
public virtual string TokenType { get; }
Property Value
TokenTypeIndex
Gets the index of the token type
public uint? TokenTypeIndex { get; }
Property Value
- uint?
TrailingWhitespaces
True, if the rule permits trailing whitespaces, otherwise false
public bool TrailingWhitespaces { get; protected set; }
Property Value
Methods
AddLeftRecursionRules(List<Rule>, List<RecursiveContinuation>)
Adds rules to the given left recursion trace
protected virtual void AddLeftRecursionRules(List<Rule> trace, List<RecursiveContinuation> continuations)
Parameters
traceList<Rule>the trace
continuationsList<RecursiveContinuation>a collection of recursion continuations
CanStartWith(Rule)
Indicates whether the rule could start with the given other rule
public bool CanStartWith(Rule rule)
Parameters
ruleRulethe other rule
Returns
- bool
true, if the rule could start with the given other rule, otherwise false
CanStartWith(Rule, List<Rule>)
Indicates whether the rule could start with the given other rule
protected abstract 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)
Determines whether the current rule can synthesize rule applications for the given semantic element
public bool CanSynthesize(object semanticElement, ParseContext context)
Parameters
semanticElementobjectthe semantic element
contextParseContextthe context in which the rule is synthesized
Returns
- bool
true, if a rule application can be synthesized, otherwise false
CanSynthesize(object, ParseContext, SynthesisPlan)
Determines whether the current rule can synthesize rule applications for the given semantic element
public abstract 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
CreateEpsilonRuleApplication(RuleApplication)
Creates a new rule application at the given position
public virtual RuleApplication CreateEpsilonRuleApplication(RuleApplication position)
Parameters
positionRuleApplicationanother rule application at the desired position
Returns
- RuleApplication
A new rule application
CreateSynthesisRequirements()
Creates a collection of requirements for synthesis
public virtual IEnumerable<SynthesisRequirement> CreateSynthesisRequirements()
Returns
- IEnumerable<SynthesisRequirement>
A collection of synthesis requirements
GetHoverText(RuleApplication, Parser, ParsePosition)
Retrieves the hover text for a symbol at a given position in the document, if available.
public virtual string GetHoverText(RuleApplication ruleApplication, Parser document, ParsePosition position)
Parameters
ruleApplicationRuleApplicationThe rule application context that is used to process the document.
documentParserThe document being parsed.
positionParsePositionThe position in the document where the hover text is requested.
Returns
- string
A string containing the hover text, or null if no matching symbol or hover text is found.
GetInlayHintText(RuleApplication, ParseContext)
Calculates an inlay text that should be shown in front of this rule application
public virtual InlayEntry GetInlayHintText(RuleApplication ruleApplication, ParseContext context)
Parameters
ruleApplicationRuleApplicationthe rule application
contextParseContextthe parse context in which the inlay hint is queried
Returns
- InlayEntry
An inlay entry
HasFoldingKind(out string)
Returns the folding kind for a rule if one is defined for the rule
public virtual bool HasFoldingKind(out string kind)
Parameters
kindstringThe folding kind of the rule
Returns
- bool
True, if a folding kind is defined for the rule
Initialize(GrammarContext)
Initializes the rule based on the provided grammar context
public virtual void Initialize(GrammarContext context)
Parameters
contextGrammarContextthe grammar context
Invalidate(RuleApplication, ParseContext)
Invalidates the given rule application, checking for potential errors
public virtual void Invalidate(RuleApplication ruleApplication, ParseContext context)
Parameters
ruleApplicationRuleApplicationthe rule application to invalidate
contextParseContextthe parse context in which the rule application is invalidated
IsEpsilonAllowed()
Determines whether the rule could capture empty input
public bool IsEpsilonAllowed()
Returns
- bool
true, if the rule can be expanded to an empty string, otherwise false
IsEpsilonAllowed(List<Rule>)
Determines whether the rule could capture empty input
protected abstract bool IsEpsilonAllowed(List<Rule> trace)
Parameters
Returns
- bool
true, if the rule can be expanded to an empty string, otherwise false
IsFoldable()
True, if the application of this rule can be folded away (hidden)
public virtual bool IsFoldable()
Returns
IsImports()
True, if the rule is used to define imports
public virtual bool IsImports()
Returns
Match(ParseContext, RecursionContext, ref ParsePosition)
Matches the the context at the provided position
public abstract 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
OnActivate(RuleApplication, ParseContext, bool)
Gets called when a rule application is activated
protected virtual void OnActivate(RuleApplication application, ParseContext context, bool initial)
Parameters
applicationRuleApplicationthe rule application that is activated
contextParseContextthe context in which the rule application is activated
initialboolflag indicating whether the activation happened due to initial parse
OnDeactivate(RuleApplication, ParseContext)
Gets called when a rule application is deactivated
protected virtual void OnDeactivate(RuleApplication application, ParseContext context)
Parameters
applicationRuleApplicationthe rule application that is deactivated
contextParseContextthe context in which the rule application is deactivated
OnValueChange(RuleApplication, ParseContext, RuleApplication)
Gets called when the value of a rule application changes
protected virtual bool OnValueChange(RuleApplication application, ParseContext context, RuleApplication oldRuleApplication)
Parameters
applicationRuleApplicationthe rule application for which the value changed
contextParseContextthe context in which the value changed
oldRuleApplicationRuleApplicationthe old rule application
Returns
- bool
true, if the rule processed the value change, otherwise false (in which case the value change is propagated)
PostInitialize(GrammarContext)
Initializes the rule based on the provided grammar context
protected virtual void PostInitialize(GrammarContext context)
Parameters
contextGrammarContextthe grammar context
Recover(RuleApplication, RuleApplication, RuleApplication, ParseContext, out ParsePosition)
Recovers from the given inner failed rule application
protected virtual RuleApplication Recover(RuleApplication ruleApplication, RuleApplication failedRuleApplication, RuleApplication currentRoot, ParseContext context, out ParsePosition position)
Parameters
ruleApplicationRuleApplicationthe rule application that should be recovered
failedRuleApplicationRuleApplicationthe inner rule application that caused the failure
currentRootRuleApplicationthe current root rule application
contextParseContextthe parse context in which the rule application is recovered
positionParsePositionthe position after the recovery
Returns
- RuleApplication
the recovered rule application if the recovery was successful or the old rule application if not
RegisterSymbolKind(Dictionary<Type, SymbolKind>)
Registers the correct symbol kind for the reference type if any.
public virtual void RegisterSymbolKind(Dictionary<Type, SymbolKind> _symbolKinds)
Parameters
_symbolKindsDictionary<Type, SymbolKind>
SuggestCompletions(ParseContext, RuleApplication, string, ParsePosition)
Suggests useful code completions
public virtual IEnumerable<CompletionEntry> SuggestCompletions(ParseContext context, RuleApplication ruleApplication, string fragment, ParsePosition position)
Parameters
contextParseContextthe parse context
ruleApplicationRuleApplicationthe rule application for which a completion was queried
fragmentstringthe fragment available
positionParsePositionthe exact position
Returns
SymbolTags(RuleApplication)
Gets the kind of document symbol to be used for this rule
public virtual SymbolTag[] SymbolTags(RuleApplication ruleApplication)
Parameters
ruleApplicationRuleApplication
Returns
Synthesize(object, ParseContext, TextWriter, string)
Synthesizes text for the given element
public void Synthesize(object element, ParseContext context, TextWriter writer, string indentString = null)
Parameters
elementobjectthe element for which text should be synthesized
contextParseContextthe parse context
writerTextWriterthe text writer the synthesized text should be written to
indentStringstringan indentation string. If none is provided, a double space is used as default.
Synthesize(object, ParseContext, string)
Synthesizes text for the given element
public string Synthesize(object element, ParseContext context, string indentString = null)
Parameters
elementobjectthe element for which text should be synthesized
contextParseContextthe parse context
indentStringstringan indentation string. If none is provided, a double space is used as default.
Returns
- string
the synthesized text or null, if no text can be synthesized
Synthesize(object, ParsePosition, ParseContext)
Synthesizes a rule application for the given semantic element
public abstract 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
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.