Class Rule
Denotes a rule for parsing rules
public abstract class Rule
- Inheritance
-
Rule
- Derived
- Inherited Members
Properties
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
CanStartWith(Rule)
Indicates whether the rule could start with the given other rule
public bool CanStartWith(Rule rule)
Parameters
rule
Rulethe 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
semanticElement
objectthe semantic element
context
ParseContextthe 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
semanticElement
objectthe semantic element
context
ParseContextthe context in which the rule is synthesized
synthesisPlan
SynthesisPlanthe 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
position
RuleApplicationanother 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
ruleApplication
RuleApplicationThe rule application context that is used to process the document.
document
ParserThe document being parsed.
position
ParsePositionThe 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)
Calculates an inlay text that should be shown in front of this rule application
public virtual InlayEntry GetInlayHintText(RuleApplication ruleApplication)
Parameters
ruleApplication
RuleApplicationthe rule application
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
kind
stringThe 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
context
GrammarContextthe grammar context
Invalidate(RuleApplication, ParseContext)
Invalidates the given rule application, checking for potential errors
public virtual void Invalidate(RuleApplication ruleApplication, ParseContext context)
Parameters
ruleApplication
RuleApplicationthe rule application to invalidate
context
ParseContextthe 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
context
ParseContextthe context in which the rule is matched
recursionContext
RecursionContextthe recursion context of the matching
position
ParsePositionthe position in the input
Returns
- RuleApplication
the rule application for the provided position
OnActivate(RuleApplication, ParseContext)
Gets called when a rule application is activated
protected virtual void OnActivate(RuleApplication application, ParseContext context)
Parameters
application
RuleApplicationthe rule application that is activated
context
ParseContextthe context in which the rule application is activated
OnDeactivate(RuleApplication, ParseContext)
Gets called when a rule application is deactivated
protected virtual void OnDeactivate(RuleApplication application, ParseContext context)
Parameters
application
RuleApplicationthe rule application that is deactivated
context
ParseContextthe 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
application
RuleApplicationthe rule application for which the value changed
context
ParseContextthe context in which the value changed
oldRuleApplication
RuleApplicationthe 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
context
GrammarContextthe grammar context
RegisterSymbolKind(Dictionary<Type, SymbolKind>)
Registers the correct symbol kind for the reference type if any.
public virtual void RegisterSymbolKind(Dictionary<Type, SymbolKind> _symbolKinds)
Parameters
_symbolKinds
Dictionary<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
context
ParseContextruleApplication
RuleApplicationfragment
stringposition
ParsePosition
Returns
SymbolTags(RuleApplication)
Gets the kind of document symbol to be used for this rule
public virtual SymbolTag[] SymbolTags(RuleApplication ruleApplication)
Parameters
ruleApplication
RuleApplication
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
element
objectthe element for which text should be synthesized
context
ParseContextthe parse context
writer
TextWriterthe text writer the synthesized text should be written to
indentString
stringan 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
element
objectthe element for which text should be synthesized
context
ParseContextthe parse context
indentString
stringan 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
semanticElement
objectposition
ParsePositionthe parse position at which the element should be synthesized
context
ParseContextthe 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.