-
Notifications
You must be signed in to change notification settings - Fork 38
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
Refactor Compiler Pipeline #37
Comments
In addition to scoping variables, we also need to scope macros and type definitions. This will be interesting. |
This is happening in the |
Regarding macros I just saw Unseemly and thought it might be a really good place to take some inspiration from as it offers "typed macros" and seeing it in practice kind of sparked my interest in that idea (syntax aside 😉). |
Another way to do types macros is to leverage a two-level lambda calculus with a kind-based macro system. I'll give Unseemly a look, I wonder if its using a similar system under the hood. Update: Holy cow, Unseemly is pretty cool! I'm a huge fan of how the language is bootstrapped from first principles, the examples are pretty incredible. I like the way it does syntactic extension:
There's this really nice mapping between patterns and expressions. I'd love to figure out a better syntax for this idea, and explore the ergonomics a bit. The link you shared kinda started a rabbit hole, here are some links I've found interesting:
I highly recommend the youtube video. |
I propose to move This is how GHC (Haskell compiler) does it. [reference]
PS: I am not sure where to place |
Passerine reports the original location of all error messages because it uses a span-based error reporting system. In essence, every artifact produced by the compiler keeps track of set of spans of source code used to produce it. This allows for accurate error reporting everywhere in the compiler, including at runtime.
This, however, is a good thing! My only concern is that operating on the parse tree (for type inference, specifically) may add extra redundancy to those passes. For example, there are a few constructs like:
If type inference were done before desugaring, we'd have to handle both these cases separately, even they both are just different ways to write function calls.
Hoist is a fairly simple step that consistently renames all variables that refer to the same value to the same name, and builds a set of which variables are captured by each function/scope. This step needs to happen before I guess the main idea is that desugar does not convert the parse tree to a small core language, it just reduces the tree to a normalized representation that is easier to work with in later passes. Some compilers would include the equivalent of passerine's |
We've added two new compiler features, but haven't done much in the way of project restructuring to accommodate this change. Referencing #33, the new compiler pipeline should be:
With the syntax trees moved out to another module. I think we should implement some traits that represent a compilation step / syntax tree.
This, along with the goals outlined in #34, will be the target of the 0.9.3 release.
The text was updated successfully, but these errors were encountered: