I’m thinking of writing a partial evaluator in Scala. Do you know if anyone has done this before, or if there are good Scala libraries for parsing, AST optimization, and code generation?
For parsing, analysis and rewriting, what you want is probably Scalameta.
Failing that, you could use the legacy Scala reflection API, which is exposed via macros or at runtime, but it’s quite hard to use correctly.
If you want higher-level type-safe capabilities to do code rewriting, and if you don’t mind restricting yourself to a subset of Scala (no class and method definitions), you could try Squid, which is a project I am working on.