Token, Line, and Pattern objects
+ 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, andPatternobjects+operator always constructsLineobjects.&always constructsPatternobjects.&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, andtailofParserthen will really just takePatterninstances (as well asParserinstances), though automatic promotion ofToken-->Line-->Patternwould make sense as a helper.