Class ParseContext
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
Grammarthe grammar for this context
matcher
Matcherthe matcher for the context
stringComparison
StringComparisonthe string comparison mode
Properties
Errors
Gets the errors that occured while parsing
public IEnumerable<DiagnosticItem> Errors { get; }
Property Value
Grammar
Gets the grammar for this context
public Grammar Grammar { get; }
Property Value
Imports
Gets a collection of imports
public List<string> Imports { get; }
Property Value
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
LastSuccessfulRootRuleApplication
Gets the last successful root rule application
public RuleApplication LastSuccessfulRootRuleApplication { get; }
Property Value
Matcher
Gets the matcher used in this parse context
public Matcher Matcher { get; }
Property Value
Root
Gets the semantic root of the parsed text
public object Root { get; }
Property Value
RootRule
Gets the root rule of this parse context
public Rule RootRule { get; }
Property Value
RootRuleApplication
Gets or sets the current root rule application
public RuleApplication RootRuleApplication { get; }
Property Value
StringComparison
Gets the string comparison mode
public StringComparison StringComparison { get; }
Property Value
Methods
AcceptOneOrMoreAdd(OneOrMoreRule, RuleApplication, List<RuleApplication>)
protected virtual bool AcceptOneOrMoreAdd(OneOrMoreRule rule, RuleApplication toAdd, List<RuleApplication> added)
Parameters
rule
OneOrMoreRuletoAdd
RuleApplicationadded
List<RuleApplication>
Returns
AcceptSequenceAdd(SequenceRule, ref RuleApplication, List<RuleApplication>)
protected virtual bool AcceptSequenceAdd(SequenceRule sequence, ref RuleApplication toAdd, List<RuleApplication> added)
Parameters
sequence
SequenceRuletoAdd
RuleApplicationadded
List<RuleApplication>
Returns
AcceptZeroOrMoreAdd(ZeroOrMoreRule, RuleApplication, List<RuleApplication>)
protected virtual bool AcceptZeroOrMoreAdd(ZeroOrMoreRule star, RuleApplication toAdd, List<RuleApplication> added)
Parameters
star
ZeroOrMoreRuletoAdd
RuleApplicationadded
List<RuleApplication>
Returns
AddDefinition(object, RuleApplication)
Add a rule application to the list of definitions in the document
public void AddDefinition(object key, RuleApplication value)
Parameters
key
objectThe semantic element of the rule application
value
RuleApplicationThe rule application
AddDiagnosticItem(DiagnosticItem)
Adds the given diagnostic item
public void AddDiagnosticItem(DiagnosticItem diagnosticItem)
Parameters
diagnosticItem
DiagnosticItemthe 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
objectThe semantic element of the rule application
value
RuleApplicationThe rule application
EnqueueResolveAction(ParseResolveAction)
Enqueues the given resolve action
public virtual void EnqueueResolveAction(ParseResolveAction action)
Parameters
action
ParseResolveActionthe 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
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
objectThe semantic element of the rule application
RemoveDiagnosticItem(DiagnosticItem)
Removes the given diagnostic item
public bool RemoveDiagnosticItem(DiagnosticItem diagnosticItem)
Parameters
diagnosticItem
DiagnosticItemthe 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
objectThe semantic element of the referenced rule application
value
RuleApplicationThe 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
RuleApplicationthe 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
objectThe semantic element of the rule application
definition
RuleApplicationThe 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
objectThe 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
objectthe element in the context of which the string is resolved
input
stringthe textual reference
resolved
Tthe resolved reference or the default
Returns
- bool
true, if the reference could be resolved, otherwise false
Type Parameters
T