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...
UnBufferedTreeNodeStream
public var adaptor:TreeAdaptor
What tree adaptor was used to build these trees
protected var calls:Array
Stack of indexes used for push/pop calls
currentSymbol:Object
[read-only]Implementation
public function get currentSymbol():Object
protected var down:Object
protected var eof:Object
hasUniqueNavigationNodes:Boolean
[read-write]Implementation
public function get hasUniqueNavigationNodes():Boolean
public function set hasUniqueNavigationNodes(value:Boolean):void
index:int
[read-only]Implementation
public function get index():int
protected var lastMarker:int
Track the last mark() call result value for use in rewind().
protected var nodes:Array
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 var p:int = -1
The index into the nodes list of the current node (next node
to consume). If -1, nodes array not filled yet.
protected var root:Object
Pull nodes from which tree?
size:int
[read-only]Implementation
public function get size():int
sourceName:String
[read-only]Implementation
public function get sourceName():String
protected var tokens:TokenStream
IF this tree (root) was created from a token stream, track it.
tokenStream:TokenStream
[read-write]
Implementation
public function get tokenStream():TokenStream
public function set tokenStream(value:TokenStream):void
treeAdaptor:TreeAdaptor
[read-write]
Implementation
public function get treeAdaptor():TreeAdaptor
public function set treeAdaptor(value:TreeAdaptor):void
treeSource:Object
[read-only]Implementation
public function get treeSource():Object
protected var uniqueNavigationNodes:Boolean = false
Reuse same DOWN, UP navigation nodes unless this is true
protected var up:Object
public function CommonTreeNodeStream(tree:Object, adaptor:TreeAdaptor = null, initialBufferSize:int)
Parameters
| tree:Object |
|
| adaptor:TreeAdaptor (default = null )
|
|
| initialBufferSize:int |
protected function addNavigationNode(ttype:int):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
public function consume():void
protected function 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).
public function fillBufferTo(t:Object):void
Parameters
public function getNode(i:int):Object
Parameters
Returns
protected function getNodeIndex(node:Object):int
What is the stream index for node? 0..n-1
Return -1 if node not found.
Parameters
Returns
public function LA(i:int):int
Parameters
Returns
protected function LB(k:int):Object
Look backwards k nodes
Parameters
Returns
public function LT(k:int):Object
Parameters
Returns
public function mark():int
Returns
public function pop():int
Seek back to previous index saved during last push() call.
Return top of stack (return index).
Returns
public function push(index:int):void
Make stream jump to a new location, saving old location.
Switch back with pop().
Parameters
public function release(marker:int):void
Parameters
public function replaceChildren(parent:Object, startChildIndex:int, stopChildIndex:int, t:Object):void
Parameters
| parent:Object |
|
| startChildIndex:int |
|
| stopChildIndex:int |
|
| t:Object |
public function reset():void
public function rewind():void
public function rewindTo(marker:int):void
Parameters
public function seek(index:int):void
Parameters
public function toString():String
Used for testing, just return the token type stream
Returns
public function toStringWithRange(start:Object, stop:Object):String
Parameters
Returns
public function toTokenString(start:int, stop:int):String
Debugging
Parameters
Returns
public static const DEFAULT_INITIAL_BUFFER_SIZE:int = 100
public static const INITIAL_CALL_STACK_SIZE:int = 10