A buffered stream of tree nodes. Nodes can be from a tree of ANY kind.

This node stream sucks all nodes out of the tree specified in the constructor during construction and makes pointers into the tree using an array of Object pointers. The stream necessarily includes pointers to DOWN and UP and EOF nodes.

This stream knows how to mark/release for backtracking.

This stream is most suitable for tree interpreters that need to jump around a lot or for tree parsers requiring speed (at cost of memory). There is some duplicated functionality here with UnBufferedTreeNodeStream but just in bookkeeping, not tree walking etc...

TARGET DEVELOPERS:

This is the old CommonTreeNodeStream that buffered up entire node stream. No need to implement really as new CommonTreeNodeStream is much better and covers what we need.

see

CommonTreeNodeStream

Hierarchy

  • BufferedTreeNodeStream

Implements

Index

Constructors

constructor

Properties

DEFAULT_INITIAL_BUFFER_SIZE

DEFAULT_INITIAL_BUFFER_SIZE: number = 100

INITIAL_CALL_STACK_SIZE

INITIAL_CALL_STACK_SIZE: number = 10

adaptor

adaptor: ITreeAdaptor

What tree adaptor was used to build these trees

Protected calls

calls: Stack<number>

Stack of indexes used for push/pop calls

down

down: any

eof

eof: any

Protected lastMarker

lastMarker: number

Track the last mark() call result value for use in rewind().

maxLookBehind

maxLookBehind: number = Number.MAX_VALUE

nodes

nodes: List<any>

The complete mapping from stream index to tree node. This buffer includes pointers to DOWN, UP, and EOF nodes. It is built upon ctor invocation. The elements are type Object as we don't what the trees look like.

Load upon first need of the buffer so we can set token types of interest for reverseIndexing. Slows us down a wee bit to do all of the if p==-1 testing everywhere though.

Protected p

p: number = -1

The index into the nodes list of the current node (next node to consume). If -1, nodes array not filled yet.

Protected root

root: any

Pull nodes from which tree?

Protected tokens

tokens: ITokenStream

IF this tree (root) was created from a token stream, track it.

uniqueNavigationNodes

uniqueNavigationNodes: boolean = false

Reuse same DOWN, UP navigation nodes unless this is true

up

up: any

Accessors

count

  • get count(): number
  • Returns number

index

  • get index(): number
  • Returns number

lastRealToken

lastToken

sourceName

  • get sourceName(): string
  • Returns string

tokenStream

treeAdaptor

treeSource

  • get treeSource(): any
  • Returns any

Methods

Protected addNavigationNode

  • addNavigationNode(ttype: number): void
  • As we flatten the tree, we use UP, DOWN nodes to represent the tree structure. When debugging we need unique nodes so instantiate new ones when uniqueNavigationNodes is true.

    Parameters

    • ttype: number

    Returns void

consume

  • consume(): void

fillBuffer

  • fillBuffer(): void
  • Walk tree with depth-first-search and fill nodes buffer. Don't do DOWN, UP nodes if its a list (t is isNil).

    Returns void

fillBuffer2

  • fillBuffer2(t: any): void
  • Parameters

    • t: any

    Returns void

get

  • get(i: number): any

getCurrentSymbol

  • getCurrentSymbol(): any
  • Returns any

Protected getNodeIndex

  • getNodeIndex(node: any): number
  • What is the stream index for node? 0..n-1 Return -1 if node not found.

    Parameters

    • node: any

    Returns number

implements

  • implements(): any[]
  • Returns any[]

iterator

  • iterator(): List<any>

la

  • la(i: number): number

Protected lb

  • lb(k: number): any
  • Look backwards k nodes

    Parameters

    • k: number

    Returns any

lt

  • lt(k: number): any

mark

  • mark(): number

pop

  • pop(): number
  • Seek back to previous index saved during last push() call. Return top of stack (return index).

    Returns number

push

  • push(index: number): void
  • Make stream jump to a new location, saving old location. Switch back with pop().

    Parameters

    • index: number

    Returns void

release

  • release(marker: number): void

replaceChildren

  • replaceChildren(parent: any, startChildIndex: number, stopChildIndex: number, t: any): void

reset

  • reset(): void
  • Returns void

rewind

  • rewind(): void
  • Returns void

rewind2

  • rewind2(marker: number): void
  • Parameters

    • marker: number

    Returns void

seek

  • seek(index: number): void

toString

  • toString(start: any, stop: any): string

toTokenString

  • toTokenString(start: number, stop: number): string
  • Parameters

    • start: number
    • stop: number

    Returns string

toTokenTypeString

  • toTokenTypeString(): string
  • Used for testing, just return the token type stream

    Returns string

Generated using TypeDoc