kellysmith12.21
2021-3-9 21:46:26

I’m beginning to work on a compiler for my lang, and what I’d like to use for building it is something that blends syntax-parse with nanopass.


kellysmith12.21
2021-3-9 21:47:03

I think that I can hack something together with carefully-designed syntax classes and some contracts.


kellysmith12.21
2021-3-9 21:49:46

A more robust solution would be a dedicated DSL that uses a more efficient IR and employs fusion to merge passes for speed.


soegaard2
2021-3-9 21:58:20

I am not entirely sure what kind of “blending” you are thinking of, but in Urlang a parse function turns syntax objects into Nanopass structures. Syntax classes are used to implement the parse function. Syntax objects are used to keep track of source location information.

https://github.com/soegaard/urlang/blob/master/urlang/main.rkt


kellysmith12.21
2021-3-9 22:13:19

To be more specific, I’m thinking of something that, like nanopass, uses grammar-based contracts to ensure the passes produce well-formed IR terms and automatically derives catamorphisms, but uses syntax objects (or something similar) so that syntax properties can be used and the scope mechanisms are used to ensure transformations respect scoping rules and are hygienic.