antlr-ng Tool Class Hierarchy / index / GrammarRootAST
Class: GrammarRootAST
This is the root node for a grammar (for the top level grammarSpec rule).
Extends
GrammarASTWithOptions
Implements
IGrammarRootAST
Constructors
Constructor
new GrammarRootAST(node): GrammarRootAST;Parameters
node
GrammarRootAST
Returns
GrammarRootAST
Overrides
GrammarASTWithOptions.constructorConstructor
new GrammarRootAST(t, tokenStream): GrammarRootAST;Parameters
t
Token
tokenStream
TokenStream
Returns
GrammarRootAST
Overrides
GrammarASTWithOptions.constructorConstructor
new GrammarRootAST(
type,
t,
tokenStream): GrammarRootAST;Parameters
type
number
t
Token
tokenStream
TokenStream
Returns
GrammarRootAST
Overrides
GrammarASTWithOptions.constructorConstructor
new GrammarRootAST(
type,
t,
text,
tokenStream): GrammarRootAST;Parameters
type
number
t
Token
text
string
tokenStream
TokenStream
Returns
GrammarRootAST
Overrides
GrammarASTWithOptions.constructorProperties
astType
readonly astType: string = "GrammarASTWithOptions";A discriminator to distinguish between different grammar AST types without creating a circular dependency.
Implementation of
IGrammarRootAST.astTypeInherited from
GrammarASTWithOptions.astTypeatnState?
optional atnState: ATNState;If we build an ATN, we make AST node point at left edge of ATN construct
Implementation of
IGrammarRootAST.atnStateInherited from
GrammarASTWithOptions.atnStatechildIndex
childIndex: number = -1;What index is this node in the child list? Range: 0..n-1
Implementation of
IGrammarRootAST.childIndexInherited from
GrammarASTWithOptions.childIndexchildren
children: CommonTree[] = [];Implementation of
IGrammarRootAST.childrenInherited from
GrammarASTWithOptions.childrenfileName
fileName: string;Implementation of
IGrammarRootAST.fileNameg
g: Grammar;For process AST nodes from imported grammars.
Implementation of
IGrammarRootAST.gInherited from
GrammarASTWithOptions.ggrammarType
grammarType: GrammarType;Implementation of
IGrammarRootAST.grammarTypehasErrors
hasErrors: boolean = false;Implementation of
IGrammarRootAST.hasErrorsparent
parent: null | CommonTree = null;Who is the parent node of this node? If null, implies node is root.
Implementation of
IGrammarRootAST.parentInherited from
GrammarASTWithOptions.parentstartIndex
startIndex: number = -1;What token indexes bracket all tokens associated with this node and below?
Implementation of
IGrammarRootAST.startIndexInherited from
GrammarASTWithOptions.startIndexstopIndex
stopIndex: number = -1;What token indexes bracket all tokens associated with this node and below?
Implementation of
IGrammarRootAST.stopIndexInherited from
GrammarASTWithOptions.stopIndextextOverride
textOverride: string;Implementation of
IGrammarRootAST.textOverrideInherited from
GrammarASTWithOptions.textOverridetoken?
optional token: Token;A single token is the payload.
Implementation of
IGrammarRootAST.tokenInherited from
GrammarASTWithOptions.tokentokenStream
readonly tokenStream: TokenStream;Track stream used to create this tree
Implementation of
IGrammarRootAST.tokenStreamtoolConfiguration?
optional toolConfiguration: IToolConfiguration;Implementation of
IGrammarRootAST.toolConfigurationMethods
addChild()
addChild(t?): void;Adds t as child of this node.
Warning: if t has no children, but child does and child isNil then this routine moves children to t via t.children = child.children, i.e., without copying the array.
Parameters
t?
The child to add.
Returns
void
Implementation of
IGrammarRootAST.addChildInherited from
GrammarASTWithOptions.addChildaddChildren()
addChildren(kids): void;Adds all elements of kids list as children of this node.
Parameters
kids
The children to add.
Returns
void
Implementation of
IGrammarRootAST.addChildrenInherited from
GrammarASTWithOptions.addChildrendeleteChild()
Call Signature
deleteChild(i): null | CommonTree;Parameters
i
number
Returns
null | CommonTree
Implementation of
IGrammarRootAST.deleteChildInherited from
GrammarASTWithOptions.deleteChildCall Signature
deleteChild(t): boolean;Parameters
t
Returns
boolean
Implementation of
IGrammarRootAST.deleteChildInherited from
GrammarASTWithOptions.deleteChilddupNode()
dupNode(): GrammarRootAST;Returns
GrammarRootAST
Implementation of
IGrammarRootAST.dupNodeOverrides
GrammarASTWithOptions.dupNodefreshenParentAndChildIndexes()
freshenParentAndChildIndexes(offset?): void;Sets the parent and child index values for all child of t.
Parameters
offset?
number
The index to start from.
Returns
void
Implementation of
IGrammarRootAST.freshenParentAndChildIndexesInherited from
GrammarASTWithOptions.freshenParentAndChildIndexesgetAllChildrenWithType()
getAllChildrenWithType(type): GrammarAST[];Parameters
type
number
Returns
Implementation of
IGrammarRootAST.getAllChildrenWithTypeInherited from
GrammarASTWithOptions.getAllChildrenWithTypegetAltLabel()
getAltLabel(): null | string;Walk ancestors of this node until we find ALT with alt!=null or leftRecursiveAltInfo!=null. Then grab label if any. If not a rule element, just returns null.
Returns
null | string
Implementation of
IGrammarRootAST.getAltLabelInherited from
GrammarASTWithOptions.getAltLabelgetAncestor()
getAncestor(ttype): null | CommonTree;Walks upwards and get first ancestor with this token type.
Parameters
ttype
number
The token type to check for.
Returns
null | CommonTree
The first ancestor of this node with the specified token type, or null if no ancestor with the type exists.
Implementation of
IGrammarRootAST.getAncestorInherited from
GrammarASTWithOptions.getAncestorgetAncestors()
protected getAncestors(): null | CommonTree[];Returns
null | CommonTree[]
a list of all ancestors of this node. The first node of list is the root and the last is the parent of this node.
Implementation of
IGrammarRootAST.getAncestorsInherited from
GrammarASTWithOptions.getAncestorsgetCharPositionInLine()
getCharPositionInLine(): number;Returns
number
Implementation of
IGrammarRootAST.getCharPositionInLineInherited from
GrammarASTWithOptions.getCharPositionInLinegetFirstChildWithType()
getFirstChildWithType(type): null | CommonTree;Parameters
type
number
Returns
null | CommonTree
Implementation of
IGrammarRootAST.getFirstChildWithTypeInherited from
GrammarASTWithOptions.getFirstChildWithTypegetFirstDescendantWithType()
getFirstDescendantWithType(typeOrTypes): null | CommonTree;Parameters
typeOrTypes
number | BitSet
Returns
null | CommonTree
Implementation of
IGrammarRootAST.getFirstDescendantWithTypeInherited from
GrammarASTWithOptions.getFirstDescendantWithTypegetGrammarName()
getGrammarName(): null | string;Returns
null | string
Implementation of
IGrammarRootAST.getGrammarNamegetLine()
getLine(): number;Returns
number
Implementation of
IGrammarRootAST.getLineInherited from
GrammarASTWithOptions.getLinegetNodesWithType()
getNodesWithType(typeOrTypes): GrammarAST[];Parameters
typeOrTypes
null | number | IntervalSet
Returns
Implementation of
IGrammarRootAST.getNodesWithTypeInherited from
GrammarASTWithOptions.getNodesWithTypegetNodesWithTypePreorderDFS()
getNodesWithTypePreorderDFS(types): GrammarAST[];Parameters
types
IntervalSet
Returns
Implementation of
IGrammarRootAST.getNodesWithTypePreorderDFSInherited from
GrammarASTWithOptions.getNodesWithTypePreorderDFSgetNodeWithTokenIndex()
getNodeWithTokenIndex(index): null | GrammarAST;Parameters
index
number
Returns
null | GrammarAST
Implementation of
IGrammarRootAST.getNodeWithTokenIndexInherited from
GrammarASTWithOptions.getNodeWithTokenIndexgetNumberOfOptions()
getNumberOfOptions(): number;Returns
number
Implementation of
IGrammarRootAST.getNumberOfOptionsInherited from
GrammarASTWithOptions.getNumberOfOptionsgetOptionAST()
getOptionAST(key): undefined | GrammarAST;Gets AST node holding value for option key; ignores default options and command-line forced options.
Parameters
key
string
Returns
undefined | GrammarAST
Implementation of
IGrammarRootAST.getOptionASTInherited from
GrammarASTWithOptions.getOptionASTgetOptions()
getOptions(): Map<string, null | GrammarAST>;Returns
Map<string, null | GrammarAST>
Implementation of
IGrammarRootAST.getOptionsInherited from
GrammarASTWithOptions.getOptionsgetOptionString()
getOptionString(key): undefined | string;Parameters
key
string
Returns
undefined | string
Implementation of
IGrammarRootAST.getOptionStringOverrides
GrammarASTWithOptions.getOptionStringgetSourceInterval()
getSourceInterval(): Interval;Returns
Interval
Implementation of
IGrammarRootAST.getSourceIntervalInherited from
GrammarASTWithOptions.getSourceIntervalgetText()
getText(): string;Returns
string
Implementation of
IGrammarRootAST.getTextInherited from
GrammarASTWithOptions.getTextgetTokenStartIndex()
getTokenStartIndex(): number;Returns
number
Implementation of
IGrammarRootAST.getTokenStartIndexInherited from
GrammarASTWithOptions.getTokenStartIndexgetTokenStopIndex()
getTokenStopIndex(): number;Returns
number
Implementation of
IGrammarRootAST.getTokenStopIndexInherited from
GrammarASTWithOptions.getTokenStopIndexgetType()
getType(): number;Returns
number
Implementation of
IGrammarRootAST.getTypeInherited from
GrammarASTWithOptions.getTypeinsertChild()
insertChild(i, t): void;Inserts child t at child position i (0..n - 1) by shifting children i + 1..n - 1 to the right one position. Sets parent/indexes properly but does NOT collapse nil-rooted t's that come in here like addChild.
Parameters
i
number
The index to insert the child at.
t
The child to insert.
Returns
void
Implementation of
IGrammarRootAST.insertChildInherited from
GrammarASTWithOptions.insertChildisNil()
isNil(): boolean;Returns
boolean
Implementation of
IGrammarRootAST.isNilInherited from
GrammarASTWithOptions.isNilreplaceChildren()
replaceChildren(
startChildIndex,
stopChildIndex,
t): void;Deletes children from start to stop and replaces with t even if t is a list (nil-root tree). Number of children can increase or decrease. For huge child lists, inserting children can force walking rest of children to set their child index - could be slow.
Parameters
startChildIndex
number
The index to start deleting children.
stopChildIndex
number
The index to stop deleting children.
t
The tree to replace the deleted children with.
Returns
void
Implementation of
IGrammarRootAST.replaceChildrenInherited from
GrammarASTWithOptions.replaceChildrensanityCheckParentAndChildIndexes()
Call Signature
sanityCheckParentAndChildIndexes(): void;Returns
void
Implementation of
IGrammarRootAST.sanityCheckParentAndChildIndexesInherited from
GrammarASTWithOptions.sanityCheckParentAndChildIndexesCall Signature
sanityCheckParentAndChildIndexes(parent, i): void;Parameters
parent
undefined | CommonTree
i
number
Returns
void
Implementation of
IGrammarRootAST.sanityCheckParentAndChildIndexesInherited from
GrammarASTWithOptions.sanityCheckParentAndChildIndexessetChild()
setChild(i, t): void;Parameters
i
number
t
Returns
void
Implementation of
IGrammarRootAST.setChildInherited from
GrammarASTWithOptions.setChildsetOption()
setOption(key, node): void;Parameters
key
string
node
null | GrammarAST
Returns
void
Implementation of
IGrammarRootAST.setOptionInherited from
GrammarASTWithOptions.setOptionsetText()
setText(text): void;Parameters
text
string
Returns
void
Implementation of
IGrammarRootAST.setTextInherited from
GrammarASTWithOptions.setTextsetTokenStartIndex()
setTokenStartIndex(index): void;Parameters
index
number
Returns
void
Implementation of
IGrammarRootAST.setTokenStartIndexInherited from
GrammarASTWithOptions.setTokenStartIndexsetTokenStopIndex()
setTokenStopIndex(index): void;Parameters
index
number
Returns
void
Implementation of
IGrammarRootAST.setTokenStopIndexInherited from
GrammarASTWithOptions.setTokenStopIndexsetType()
setType(type): void;Parameters
type
number
Returns
void
Implementation of
IGrammarRootAST.setTypeInherited from
GrammarASTWithOptions.setTypesetUnknownTokenBoundaries()
setUnknownTokenBoundaries(): void;For every node in this subtree, make sure it's start/stop token's are set. Walks depth first, visits bottom up. Only updates nodes with at least one token index < 0.
Returns
void
Implementation of
IGrammarRootAST.setUnknownTokenBoundariesInherited from
GrammarASTWithOptions.setUnknownTokenBoundariestoString()
toString(): string;Returns
string
Implementation of
IGrammarRootAST.toStringInherited from
GrammarASTWithOptions.toStringtoStringTree()
toStringTree(): string;Prints out a whole tree not just a node.
Returns
string
A string representation of the tree.
Implementation of
IGrammarRootAST.toStringTreeInherited from
GrammarASTWithOptions.toStringTreevisit()
visit<T>(v): T;Type Parameters
T
T
Parameters
v
IGrammarASTVisitor<T>
Returns
T
Implementation of
IGrammarRootAST.visitOverrides
GrammarASTWithOptions.visit