bskinn / pent

pent Extracts Numerical Text -- Mini-language driven parser for structured numerical data in text
MIT License
20 stars 3 forks source link

Class-based paradigm for pattern construction #101

Open bskinn opened 2 years ago

bskinn commented 2 years ago

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.