Table of Contents

Class ParseContext

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

The context in which a text is parsed

public class ParseContext
Inheritance
ParseContext
Derived
Inherited Members

Constructors

ParseContext(Grammar, Matcher, StringComparison)

Creates a new instance

public ParseContext(Grammar grammar, Matcher matcher, StringComparison stringComparison = StringComparison.OrdinalIgnoreCase)

Parameters

grammar Grammar

the grammar for this context

matcher Matcher

the matcher for the context

stringComparison StringComparison

the string comparison mode

Properties

Errors

Gets the errors that occured while parsing

public IEnumerable<DiagnosticItem> Errors { get; }

Property Value

IEnumerable<DiagnosticItem>

Grammar

Gets the grammar for this context

public Grammar Grammar { get; }

Property Value

Grammar

Imports

Gets a collection of imports

public List<string> Imports { get; }

Property Value

List<string>

Input

Gets or sets the input text in lines

public string[] Input { get; }

Property Value

string[]

IsLastUpdateSuccessful

Indicates whether the last update sent to the parser was successful

public bool IsLastUpdateSuccessful { get; }

Property Value

bool

LastSuccessfulRootRuleApplication

Gets the last successful root rule application

public RuleApplication LastSuccessfulRootRuleApplication { get; }

Property Value

RuleApplication

Matcher

Gets the matcher used in this parse context

public Matcher Matcher { get; }

Property Value

Matcher

Root

Gets the semantic root of the parsed text

public object Root { get; }

Property Value

object

RootRule

Gets the root rule of this parse context

public Rule RootRule { get; }

Property Value

Rule

RootRuleApplication

Gets or sets the current root rule application

public RuleApplication RootRuleApplication { get; }

Property Value

RuleApplication

StringComparison

Gets the string comparison mode

public StringComparison StringComparison { get; }

Property Value

StringComparison

Methods

AcceptOneOrMoreAdd(OneOrMoreRule, RuleApplication, List<RuleApplication>)

protected virtual bool AcceptOneOrMoreAdd(OneOrMoreRule rule, RuleApplication toAdd, List<RuleApplication> added)

Parameters

rule OneOrMoreRule
toAdd RuleApplication
added List<RuleApplication>

Returns

bool

AcceptSequenceAdd(SequenceRule, ref RuleApplication, List<RuleApplication>)

protected virtual bool AcceptSequenceAdd(SequenceRule sequence, ref RuleApplication toAdd, List<RuleApplication> added)

Parameters

sequence SequenceRule
toAdd RuleApplication
added List<RuleApplication>

Returns

bool

AcceptZeroOrMoreAdd(ZeroOrMoreRule, RuleApplication, List<RuleApplication>)

protected virtual bool AcceptZeroOrMoreAdd(ZeroOrMoreRule star, RuleApplication toAdd, List<RuleApplication> added)

Parameters

star ZeroOrMoreRule
toAdd RuleApplication
added List<RuleApplication>

Returns

bool

AddDefinition(object, RuleApplication)

Add a rule application to the list of definitions in the document

public void AddDefinition(object key, RuleApplication value)

Parameters

key object

The semantic element of the rule application

value RuleApplication

The rule application

AddDiagnosticItem(DiagnosticItem)

Adds the given diagnostic item

public void AddDiagnosticItem(DiagnosticItem diagnosticItem)

Parameters

diagnosticItem DiagnosticItem

the diagnostic item to add

AddReference(object, RuleApplication)

Add a rule application to the list of references in the document

public void AddReference(object key, RuleApplication value)

Parameters

key object

The semantic element of the rule application

value RuleApplication

The rule application

EnqueueResolveAction(ParseResolveAction)

Enqueues the given resolve action

public virtual void EnqueueResolveAction(ParseResolveAction action)

Parameters

action ParseResolveAction

the resolve action

GetPotentialReferences<T>(object, string)

Retrieves all potential references for a given context element.

public virtual IEnumerable<T> GetPotentialReferences<T>(object contextElement, string input)

Parameters

contextElement object

The context element.

input string

The input from the user

Returns

IEnumerable<T>

A collection of references.

Type Parameters

T

The type of references to retrieve.

RefreshRoot()

Refreshes the current root value

public void RefreshRoot()

RemoveDefinition(object)

Remove a rule application from the list of definitions

public void RemoveDefinition(object key)

Parameters

key object

The semantic element of the rule application

RemoveDiagnosticItem(DiagnosticItem)

Removes the given diagnostic item

public bool RemoveDiagnosticItem(DiagnosticItem diagnosticItem)

Parameters

diagnosticItem DiagnosticItem

the diagnostic item

Returns

bool

true, if the diagnostic item was present, otherwise false

RemoveReference(object, RuleApplication)

Remove a reference of an object from the corresponding list of references

public void RemoveReference(object key, RuleApplication value)

Parameters

key object

The semantic element of the referenced rule application

value RuleApplication

The the referencing rule application to be removed

RestoreContextElement(RuleApplication)

Calculates the context element for the given rule application

public object RestoreContextElement(RuleApplication ruleApplication)

Parameters

ruleApplication RuleApplication

the rule application

Returns

object

A restored semantic context element or null, if it cannot be restored

TryGetDefinition(object, out RuleApplication)

Get the rule application for a definition

public bool TryGetDefinition(object key, out RuleApplication definition)

Parameters

key object

The semantic element of the rule application

definition RuleApplication

The rule application for the definition

Returns

bool

True, if a definition is present for the given key

TryGetReferences(object, out ICollection<RuleApplication>)

Get the rule applications for references

public bool TryGetReferences(object key, out ICollection<RuleApplication> references)

Parameters

key object

The semantic element of the referenced rule application

references ICollection<RuleApplication>

A list of rule applications that reference the rule application

Returns

bool

True, if references are present for the given key

TryResolveReference<T>(object, string, out T)

Resolves the given input

public virtual bool TryResolveReference<T>(object contextElement, string input, out T resolved)

Parameters

contextElement object

the element in the context of which the string is resolved

input string

the textual reference

resolved T

the resolved reference or the default

Returns

bool

true, if the reference could be resolved, otherwise false

Type Parameters

T