Table of Contents

Class GrammarContext

Namespace
NMF.AnyText.Grammars
Assembly
NMF.AnyText.Core.dll

Denotes the context in which a rule is initialized

public class GrammarContext
Inheritance
GrammarContext
Inherited Members

Constructors

GrammarContext(IDictionary<Type, Rule>, Grammar)

Creates a new instance

public GrammarContext(IDictionary<Type, Rule> rules, Grammar grammar)

Parameters

rules IDictionary<Type, Rule>

a dictionary of rules that should be used in this context

grammar Grammar

the context grammar, used to resolve keywords

Properties

Keywords

Gets the keywords used in the grammar

public ICollection<LiteralRule> Keywords { get; }

Property Value

ICollection<LiteralRule>

Methods

ResolveFormattedRule<T>(params FormattingInstruction[])

Resolves the grammar rule of the given type and adds formatting instructions

public FormattedRule ResolveFormattedRule<T>(params FormattingInstruction[] formattingInstructions) where T : Rule

Parameters

formattingInstructions FormattingInstruction[]

formatting instructions

Returns

FormattedRule

the rule instance with the given rule type

Type Parameters

T

the rule type

ResolveKeyword(string)

Resolves the rule for the given keyword

public FormattedRule ResolveKeyword(string keyword)

Parameters

keyword string

the keyword

Returns

FormattedRule

a literal rule that represents matching the provided keyword

ResolveKeyword(string, params FormattingInstruction[])

Resolves the rule for the given keyword

public FormattedRule ResolveKeyword(string keyword, params FormattingInstruction[] formattingInstructions)

Parameters

keyword string

the keyword

formattingInstructions FormattingInstruction[]

formatting instructions for this keyword

Returns

FormattedRule

a literal rule that represents matching the provided keyword

ResolveRule<T>()

Resolves the grammar rule of the given type

public T ResolveRule<T>() where T : Rule

Returns

T

the rule instance with the given rule type

Type Parameters

T

the rule type