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

"Void Terminal" declarations #23

Closed kjosib closed 4 years ago

kjosib commented 5 years ago

Main Idea

In any given language, there are likely to be terminals which contribute only syntactic, not semantic information. Examples include most punctuation and reserved words. Let's call these "void terminals", because the type of their semantic content is -- well -- vacuous.

If we have a list of (or criterion for recognizing) void terminals, then there's no need to explicitly filter them out of the set of right-hand-side symbols relevant to a parse-action. This could result in cleaner-looking production rules.

For Example:

Expanding on the Idea:

Relatedly:

This suggests perhaps "Precedence" is the wrong name for its block. Perhaps it should be called "Declarations", of which precedence and associativity rules are just one kind.

Caveat: This is not, and cannot be, a perfect be-all, end-all solution. But it should make a big dent in the vast majority of

kjosib commented 4 years ago

This concept is now supported on the miniparse side with the void_symbols parser attribute. While I see how to add it to the macroparse side, it seems the best approach might be to reconsider the design of the macroparse module in light of certain recent developments.

kjosib commented 4 years ago

The "void token" idea does have an interaction with the macro system: if a macro's production rule fails to explicitly specify semantic capture positions, then textual substitution of different tokens could yield inconsistent behavior. The system ought to decide which positions in macro-rules to capture once only, rather than again for each instantiation of the macro. And indeed this is how it works.