Click or drag to resize

TreeParser Class

A parser for a stream of tree nodes. "tree grammars" result in a subclass of this. All the error reporting and recovery is shared with Parser via the BaseRecognizer superclass.
Inheritance Hierarchy

Namespace:  Stimulsoft.Data.Expressions.Antlr.Runtime.Tree
Assembly:  Stimulsoft.Data (in Stimulsoft.Data.dll) Version: 2019.3.1.0
Syntax
public class TreeParser : BaseRecognizer

The TreeParser type exposes the following members.

Constructors
  NameDescription
Public methodTreeParser(ITreeNodeStream)
Initializes a new instance of the TreeParser class
Public methodTreeParser(ITreeNodeStream, RecognizerSharedState)
Initializes a new instance of the TreeParser class
Top
Properties
  NameDescription
Public propertyBacktrackingLevel (Inherited from BaseRecognizer.)
Public propertyFailed
Return whether or not a backtracking attempt failed.
(Inherited from BaseRecognizer.)
Public propertyGrammarFileName
For debugging and other purposes, might want the grammar name. Have ANTLR generate an implementation for this method.
(Inherited from BaseRecognizer.)
Public propertyNumberOfSyntaxErrors
Get number of recognition errors (lexer, parser, tree parser). Each recognizer tracks its own number. So parser and lexer each have separate count. Does not count the spurious errors found between an error and next valid token match
(Inherited from BaseRecognizer.)
Public propertySourceName (Overrides BaseRecognizerSourceName.)
Public propertyTokenNames
Used to print out token names like ID during debugging and error reporting. The generated parsers implement a method that overrides this to point to their String[] tokenNames.
(Inherited from BaseRecognizer.)
Public propertyTraceDestination (Inherited from BaseRecognizer.)
Top
Methods
  NameDescription
Public methodAlreadyParsedRule
Has this rule already parsed input at the current index in the input stream? Return the stop token index or MEMO_RULE_UNKNOWN. If we attempted but failed to parse properly before, return MEMO_RULE_FAILED.
(Inherited from BaseRecognizer.)
Public methodBeginResync
A hook to listen in on the token consumption during error recovery. The DebugParser subclasses this to fire events to the listenter.
(Inherited from BaseRecognizer.)
Protected methodCombineFollows (Inherited from BaseRecognizer.)
Protected methodComputeContextSensitiveRuleFOLLOW
Compute the context-sensitive FOLLOW set for current rule. This is set of token types that can follow a specific rule reference given a specific call chain. You get the set of viable tokens that can possibly come next (lookahead depth 1) given the current call chain. Contrast this with the definition of plain FOLLOW for rule r:
(Inherited from BaseRecognizer.)
Protected methodComputeErrorRecoverySet (Inherited from BaseRecognizer.)
Public methodConsumeUntil(IIntStream, BitSet)
Consume tokens until one matches the given token set
(Inherited from BaseRecognizer.)
Public methodConsumeUntil(IIntStream, Int32) (Inherited from BaseRecognizer.)
Protected methodDebugBeginBacktrack (Inherited from BaseRecognizer.)
Protected methodDebugEndBacktrack (Inherited from BaseRecognizer.)
Protected methodDebugEnterAlt (Inherited from BaseRecognizer.)
Protected methodDebugEnterDecision (Inherited from BaseRecognizer.)
Protected methodDebugEnterRule (Inherited from BaseRecognizer.)
Protected methodDebugEnterSubRule (Inherited from BaseRecognizer.)
Protected methodDebugExitDecision (Inherited from BaseRecognizer.)
Protected methodDebugExitRule (Inherited from BaseRecognizer.)
Protected methodDebugExitSubRule (Inherited from BaseRecognizer.)
Protected methodDebugLocation (Inherited from BaseRecognizer.)
Protected methodDebugRecognitionException (Inherited from BaseRecognizer.)
Protected methodDebugSemanticPredicate (Inherited from BaseRecognizer.)
Public methodDisplayRecognitionError (Inherited from BaseRecognizer.)
Public methodEmitErrorMessage
Override this method to change where error messages go
(Inherited from BaseRecognizer.)
Public methodEndResync (Inherited from BaseRecognizer.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Protected methodGetCurrentInputSymbol (Overrides BaseRecognizerGetCurrentInputSymbol(IIntStream).)
Public methodGetErrorHeader
Prefix error message with the grammar name because message is always intended for the programmer because the parser built the input tree not the user.
(Overrides BaseRecognizerGetErrorHeader(RecognitionException).)
Public methodGetErrorMessage
Tree parsers parse nodes they usually have a token object as payload. Set the exception token and do the default behavior.
(Overrides BaseRecognizerGetErrorMessage(RecognitionException, String).)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Protected methodGetMissingSymbol (Overrides BaseRecognizerGetMissingSymbol(IIntStream, RecognitionException, Int32, BitSet).)
Public methodGetRuleInvocationStack
Return IListT of the rules in your parser instance leading up to a call to this method. You could override if you want more details such as the file/line info of where in the parser java code a rule is invoked.
(Inherited from BaseRecognizer.)
Public methodGetRuleMemoization
Given a rule number and a start token index number, return MEMO_RULE_UNKNOWN if the rule has not parsed input starting from start index. If this rule has parsed input starting from the start index before, then return where the rule stopped parsing. It returns the index of the last token matched by the rule.
(Inherited from BaseRecognizer.)
Public methodGetRuleMemoizationCacheSize
return how many rule/input-index pairs there are in total.
(Inherited from BaseRecognizer.)
Public methodGetTokenErrorDisplay
How should a token be displayed in an error message? The default is to display just the text, but during development you might want to have a lot of information spit out. Override in that case to use t.ToString() (which, for CommonToken, dumps everything about the token). This is better than forcing you to override a method in your token objects because you don't have to go modify your lexer so that it creates a new Java type.
(Inherited from BaseRecognizer.)
Public methodGetTreeNodeStream
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodInitDFAs (Inherited from BaseRecognizer.)
Public methodMatch
Match current input symbol against ttype. Attempt single token insertion or deletion error recovery. If that fails, throw MismatchedTokenException.
(Inherited from BaseRecognizer.)
Public methodMatchAny
Match '.' in tree parser has special meaning. Skip node or entire tree if node has children. If children, scan until corresponding UP node.
(Overrides BaseRecognizerMatchAny(IIntStream).)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodMemoize
Record whether or not this rule parsed the input at this position successfully. Use a standard java hashtable for now.
(Inherited from BaseRecognizer.)
Public methodMismatchIsMissingToken (Inherited from BaseRecognizer.)
Public methodMismatchIsUnwantedToken (Inherited from BaseRecognizer.)
Protected methodPopFollow (Inherited from BaseRecognizer.)
Protected methodPushFollow
Push a rule's follow set using our own hardcoded stack
(Inherited from BaseRecognizer.)
Public methodRecover
Recover from an error found on the input stream. This is for NoViableAlt and mismatched symbol exceptions. If you enable single token insertion and deletion, this will usually not handle mismatched symbol exceptions but there could be a mismatched token that the match() routine could not recover from.
(Inherited from BaseRecognizer.)
Public methodRecoverFromMismatchedSet (Inherited from BaseRecognizer.)
Protected methodRecoverFromMismatchedToken
We have DOWN/UP nodes in the stream that have no line info; override. plus we want to alter the exception type. Don't try to recover from tree parser errors inline...
(Overrides BaseRecognizerRecoverFromMismatchedToken(IIntStream, Int32, BitSet).)
Public methodReportError
Report a recognition problem.
(Inherited from BaseRecognizer.)
Public methodReset (Overrides BaseRecognizerReset.)
Public methodSetState (Inherited from BaseRecognizer.)
Public methodSetTreeNodeStream
Set the input stream
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodToStrings
A convenience method for use most often with template rewrites. Convert a list of IToken to a list of String.
(Inherited from BaseRecognizer.)
Public methodTraceIn(String, Int32)
Public methodTraceIn(String, Int32, Object) (Inherited from BaseRecognizer.)
Public methodTraceOut(String, Int32)
Public methodTraceOut(String, Int32, Object) (Inherited from BaseRecognizer.)
Top
Fields
  NameDescription
Public fieldStatic memberDOWN
Protected fieldinput
Protected fieldstate
State of a lexer, parser, or tree parser are collected into a state object so the state can be shared. This sharing is needed to have one grammar import others and share same error variables and other state variables. It's a kind of explicit multiple inheritance via delegation of methods and shared state.
(Inherited from BaseRecognizer.)
Public fieldStatic memberUP
Top
See Also