Package rxpy :: Package engine :: Package simple :: Module engine :: Class Stack
[hide private]
[frames] | no frames]

Class Stack

source code

A stack of states. This extends a simple stack with the ability to compress repeated states (which is useful to avoid filling the stack with backtracking when something like ".*" is used to match a large string).

The compression is quite simple: if a state and group are pushed to the stack which are identical, apart from offset, with the existing top of the stack, then the stack is not extended. Instead, the new offset and increment are appended to the existing entry. The same occurs for further pushes that have the same increment.

On popping we create a new state, and adjust the offset as necessary.

For this to work correctly we must also be careful to preserve the original state, since that is the one that contains the most text. Later states have less text and so cannot be cloned "back" to having an earlier offset.

Instance Methods [hide private]
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
push(self, graph, state) source code
pop(self) source code
__bool__(self) source code
__nonzero__(self) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]


source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)