diprism / perpl

The PERPL Compiler
MIT License
10 stars 5 forks source link

Eliminate repetitions in FGG #110

Closed davidweichiang closed 1 year ago

davidweichiang commented 1 year ago

Make RuleM accumulate "blocks" of rules (all rules with a given lhs) instead of individual rules. This lets it drop duplicate blocks but not duplicate rules within a block, so that it's not necessary to keep track of repetition counts. That might be exchanging one wrinkle for another, but this way seems more conceptually correct to me.

In addition, RuleM really is a Monad now; it's just Writer [Rule]. A lot of the code associated with RuleM can therefore be deleted.

To keep externs to compile correctly, we need to distinguish between TmVarG when the global variable is a define versus an extern.

davidweichiang commented 1 year ago

This ended up being a rather large set of changes. Most of them are confined to the FGG generation code; however, the renaming of GlobalVar and its constructors made changes throughout. @ccshan you don't have to review this in detail, IMO, but I'll hold off on merging in case you are working on something related to #103 in parallel.