Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pattern-based transforms #33

Merged
merged 7 commits into from
Jun 23, 2018
Merged

Pattern-based transforms #33

merged 7 commits into from
Jun 23, 2018

Conversation

jdpage
Copy link
Collaborator

@jdpage jdpage commented Jun 18, 2018

Add support for implementing compiler passes using a pattern/template system, similar to Scheme R5RS syntax-rules. See ExplicitScopes in binding.py for a particularly neat (imho) example of how to use this.

This is implemented on top of the existing pass system, so all existing passes still work; some passes still have to be procedural, in particular scope-aware passes. (I don't think there's a theoretical reason that these couldn't be supported, but it would require some thought about how those interact.)

This has merge conflicts with #30; I'll address them once that's merged. (Or the other way around, I guess; I'm not sure which one would be harder to merge.)

Patterns are now defined using a decorator on a generator. This is
mostly to make it easy to add docstrings. We now also have the ability
to match multiple child nodes with a single pattern object, the use of
which can be observed in the now-implemented ExplicitScopes.

Additionally, patterns can now be either ascending or descending.
(Before, only ascending was possible.) Ascending patterns attempt to
transform nodes as they exit them, while descending patterns attempt to
do so as they enter.
@coveralls
Copy link

coveralls commented Jun 18, 2018

Pull Request Test Coverage Report for Build 192

  • 207 of 237 (87.34%) changed or added relevant lines in 9 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.7%) to 83.549%

Changes Missing Coverage Covered Lines Changed/Added Lines %
jeff65/gold/passes/resolve.py 12 20 60.0%
jeff65/gold/pattern.py 164 186 88.17%
Totals Coverage Status
Change from base Build 190: 0.7%
Covered Lines: 1127
Relevant Lines: 1322

💛 - Coveralls

@jdpage jdpage added this to the Hello world! milestone Jun 18, 2018
@jdpage jdpage merged commit 0a714e9 into master Jun 23, 2018
@jdpage
Copy link
Collaborator Author

jdpage commented Jun 23, 2018

Merged based on verbal confirmation from @woodrowbarlow

@jdpage jdpage deleted the pattern-transform branch August 9, 2018 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants