Miksilo
Miksilo copied to clipboard
Allow using Scala traits to access and create AST nodes in an idiomatic way
Enable defining delta's like this:
trait Compilation {
def visit<T>(action: T => ()) {
}
def getFactory<T>: T
}
trait BlockStatementFactory {
def create(statements: Seq[Node]): BlockStatement
}
trait BlockStatement {
def statements: Seq[Node]
def statements_(statements: Seq[Node]): Unit
}
object BlockDelta extends LanguageExtension {
def factoryType = typeTag[BlockStatementFactory]
def tranformProgram(compilation: Compilation) {
val blockFactory = compilation.getFactory(factoryType)
program.visit<BlockStatement>(block => {
val newStatements = blockFactory.create(Seq.empty[Node])
block.statements = Seq(newStatements);
});
}
}