Subclasses describe ordered actions (typically, matches) to be made.
This base class provides support for constructing and connecting nodes,
cloning them, and displaying them in GraphViz.
For automatic cloning, subclasses should have a public attribute for each
constructor karg (and no additional public attributes). Note that graph
nodes are not exposed as part of the public API - they are purely internal
to RXPY.
This class is designed to support both simple nodes (an instance is a
graph node) and complex nodes (an instance describes some subset of
the graph with a single entry node, and which will be given a single exit
node). Complex nodes are used during construction of the graph (eg for
sequences and alternatives), but final connection of nodes connects the
individual sub-nodes.
|
|
__init__(self,
consumer=True,
size=None)
Subclasses should pay attention to the relationship between
constructor kargs and attributes assumed in .clone. |
source code
|
|
|
|
consumer(self)
Does this node consume data from the input string? This is used to
detect errors (if False, repeating with * or + would not terminate). |
source code
|
|
|
|
size(self,
groups)
The number of characters matched by this and subsequence nodes, if
known, otherwise None. |
source code
|
|
|
|
|
|
|
|
|
|
__repr__(self)
Generate a description of this node and accessible children which can
be used to plot the graph in GraphViz. |
source code
|
|
|
|
__str__(self)
Subclasses must implement something useful here, which will be
displayed in the graphviz node (see repr). |
source code
|
|
|
|
clone(self,
cache=None)
Duplicate this node (necessary when replacing a numbered repeat with
explicit, repeated, instances, for example). |
source code
|
|
|
|
__clone_next(self,
cache)
Clone child nodes, using the cache where appropriate. |
source code
|
|
|
|
|
|
|
deep_eq(self,
other)
Used only for testing. |
source code
|
|
|
|
|
|
|
visit(self,
visitor,
state=None)
The visitor pattern - used to evaluate the graph by an interpreter,
for example. |
source code
|
|
|
Inherited from object:
__delattr__,
__format__,
__getattribute__,
__hash__,
__new__,
__reduce__,
__reduce_ex__,
__setattr__,
__sizeof__,
__subclasshook__
|