Table of Contents

Class Rule

Namespace
NMF.AnyText.Rules
Assembly
NMF.AnyText.Core.dll

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

bool

IsDefinition

True, if the application of this rule denotes a definition

public virtual bool IsDefinition { get; }

Property Value

bool

IsIdentifier

True, if the rule application of this rule denotes an identifier

public virtual bool IsIdentifier { get; }

Property Value

bool

IsLeftRecursive

Indicates whether the rule is recursive

public bool IsLeftRecursive { get; }

Property Value

bool

IsLiteral

True, if the rule contributes characters, otherwise false

public virtual bool IsLiteral { get; }

Property Value

bool

IsReference

True, if the application of this rule denotes a reference

public virtual bool IsReference { get; }

Property Value

bool

Name

Gets or sets the name of this rule

public string Name { get; set; }

Property Value

string

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

bool

SymbolKind

Gets the kind of document symbol to be used for this rule

public virtual SymbolKind SymbolKind { get; }

Property Value

SymbolKind

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

string

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

bool

Methods

CanStartWith(Rule)

Indicates whether the rule could start with the given other rule

public bool CanStartWith(Rule rule)

Parameters

rule Rule

the 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

rule Rule

the other rule

trace List<Rule>

a list of rules visited so far

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 object

the semantic element

context ParseContext

the 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 object

the semantic element

context ParseContext

the context in which the rule is synthesized

synthesisPlan SynthesisPlan

the 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 RuleApplication

another 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 RuleApplication

The rule application context that is used to process the document.

document Parser

The document being parsed.

position ParsePosition

The 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 RuleApplication

the 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 string

The 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 GrammarContext

the grammar context

Invalidate(RuleApplication, ParseContext)

Invalidates the given rule application, checking for potential errors

public virtual void Invalidate(RuleApplication ruleApplication, ParseContext context)

Parameters

ruleApplication RuleApplication

the rule application to invalidate

context ParseContext

the 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

trace List<Rule>

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

bool

IsImports()

True, if the rule is used to define imports

public virtual bool IsImports()

Returns

bool

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 ParseContext

the context in which the rule is matched

recursionContext RecursionContext

the recursion context of the matching

position ParsePosition

the 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 RuleApplication

the rule application that is activated

context ParseContext

the 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 RuleApplication

the rule application that is deactivated

context ParseContext

the 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 RuleApplication

the rule application for which the value changed

context ParseContext

the context in which the value changed

oldRuleApplication RuleApplication

the 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 GrammarContext

the 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 ParseContext
ruleApplication RuleApplication
fragment string
position ParsePosition

Returns

IEnumerable<CompletionEntry>

SymbolTags(RuleApplication)

Gets the kind of document symbol to be used for this rule

public virtual SymbolTag[] SymbolTags(RuleApplication ruleApplication)

Parameters

ruleApplication RuleApplication

Returns

SymbolTag[]

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 object

the element for which text should be synthesized

context ParseContext

the parse context

writer TextWriter

the text writer the synthesized text should be written to

indentString string

an 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 object

the element for which text should be synthesized

context ParseContext

the parse context

indentString string

an 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 object
position ParsePosition

the parse position at which the element should be synthesized

context ParseContext

the 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.