A record of the rules used to match a token sequence. The tokens end up as the leaves of this tree and rule nodes are the interior nodes. This really adds no functionality, it is just an alias for CommonTree that is more meaningful (specific) and holds a String to display for a node.

Hierarchy

Implements

Index

Constructors

constructor

Properties

Protected _text

_text: string

_tokenStartIndex

_tokenStartIndex: number = 0

_tokenStopIndex

_tokenStopIndex: number = 0

_type

_type: number = 0

charPositionInLine

charPositionInLine: number

childIndex

childIndex: number = 0

BaseTree doesn't track child indexes.

children

children: List<ITree>

Get the children internal List; note that if you directly mess with the list, do so at your own risk.

hiddenTokens

hiddenTokens: List<IToken>

line

line: number

parent

parent: ITree = null

BaseTree doesn't track parent pointers.

payload

payload: any

Accessors

childCount

  • get childCount(): number

isNil

  • get isNil(): boolean

text

  • get text(): string

tokenStartIndex

  • get tokenStartIndex(): number
  • set tokenStartIndex(value: number): void

tokenStopIndex

  • get tokenStopIndex(): number
  • set tokenStopIndex(value: number): void

type

  • get type(): number
  • set type(value: number): void

Methods

addChild

  • addChild(t: ITree): void
  • Add 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

    Returns void

addChildren

createChildrenList

deleteChild

  • deleteChild(i: number): any

dupNode

freshenParentAndChildIndexes

  • freshenParentAndChildIndexes(offset?: number): void

freshenParentAndChildIndexesDeeply

  • freshenParentAndChildIndexesDeeply(offset?: number): void

getAncestor

  • getAncestor(ttype: number): ITree

getAncestors

getChild

  • getChild(i: number): ITree

getFirstChildWithType

  • getFirstChildWithType(type: number): ITree

hasAncestor

  • hasAncestor(ttype: number): boolean

implements

  • implements(): any[]

insertChild

  • insertChild(i: number, t: ITree): void
  • Insert child t at child position i (0..n-1) by shifting children i+1..n-1 to the right one position. Set parent / indexes properly but does NOT collapse nil-rooted t's that come in here like addChild.

    Parameters

    Returns void

replaceChildren

  • replaceChildren(startChildIndex: number, stopChildIndex: number, t: any): void
  • Delete children from start to stop and replace with t even if t is a list (nil-root tree). num of children can increase or decrease. For huge child lists, inserting children can force walking rest of children to set their childindex; could be slow.

    Parameters

    • startChildIndex: number
    • stopChildIndex: number
    • t: any

    Returns void

sanityCheckParentAndChildIndexes

  • sanityCheckParentAndChildIndexes(parent?: ITree, i?: number): void

setChild

  • setChild(i: number, t: ITree): void

toInputString

  • toInputString(): string
  • Print out the leaves of this tree, which means printing original input back out.

    Returns string

toString

  • toString(): string

Protected toStringLeaves

  • toStringLeaves(buf: string): void
  • Parameters

    • buf: string

    Returns void

toStringTree

  • toStringTree(): string

toStringWithHiddenTokens

  • toStringWithHiddenTokens(): string
  • Emit a token and all hidden nodes before. EOF node holds all hidden tokens after last real token.

    Returns string

Generated using TypeDoc