+ operator always constructs Line objects. & always constructs Pattern objects. & has lower operator precedence, which should make complex expressions coalesce in a sane way.
__repr__() for each class should be dovetailed with the objects' constructors to allow re-instantiation of the object.
The head, body, and tail of Parser then will really just take Pattern instances (as well as Parser instances), though automatic promotion of Token --> Line --> Pattern would make sense as a helper.
Token
,Line
, andPattern
objects+
operator always constructsLine
objects.&
always constructsPattern
objects.&
has lower operator precedence, which should make complex expressions coalesce in a sane way.__repr__()
for each class should be dovetailed with the objects' constructors to allow re-instantiation of the object.The
head
,body
, andtail
ofParser
then will really just takePattern
instances (as well asParser
instances), though automatic promotion ofToken
-->Line
-->Pattern
would make sense as a helper.