kjosib / booze-tools

Booze Tools will become the complete programming-language development workbench, all written in Python 3.9 (for now).
MIT License
14 stars 1 forks source link

Idea: Generic Parse-Nodes #38

Open kjosib opened 3 years ago

kjosib commented 3 years ago

Presently, parse drivers are flush with parse_this and parse_that which simply delegate to creating a node structure of some kind. Suppose instead the standard mechanism could handle this part for you, most of the time, based on a "generic" node structure and a tag. Throw in a convenient double-dispatch/visitation mechanism.

You save a bunch of noise in parse drivers, and you can also meld semantic modules together for doing things like sharing the regex language between miniscan and macroparse. With any luck, much of the current bootstrapping code also goes away.

The idea is incomplete, but a quick observation is this: in support/runtime.py, the function parse_action_bindings(...) has a subfunction bind(...) which interprets the (symbolic) messages of the message catalog. In contrast, the miniparse path sends the actual parse-action functions through as the messages attached to the grammar. Thus, miniparse would need an extra rule-type method, and MacroParse would need some way to say the same thing -- possibly a semicolon where a (full) colon currently goes in front of the (final) action on a production rule. (Internal actions probably do not change.)