parser: various code and quality enhancements

This commit is contained in:
2023-10-08 04:46:23 -07:00
parent fdac4fb96a
commit 73a458b673
23 changed files with 316 additions and 193 deletions

View File

@ -193,6 +193,11 @@ class AstStandardCodegen(pkg: String, outputDirectory: Path, world: AstWorld) :
"NodeCoalescer",
inherits = mutableListOf("NodeVisitor<Unit>"),
members = mutableListOf(
KotlinMember(
"followChildren",
"Boolean",
value = "true"
),
KotlinMember(
"handler",
"(Node) -> Unit"
@ -227,7 +232,9 @@ class AstStandardCodegen(pkg: String, outputDirectory: Path, world: AstWorld) :
)
)
handleFunction.body.add("handler(node)")
handleFunction.body.add("node.visitChildren(this)")
handleFunction.body.add("if (followChildren) {")
handleFunction.body.add(" node.visitChildren(this)")
handleFunction.body.add("}")
coalescerClass.functions.add(handleFunction)
write("NodeCoalescer.kt", KotlinWriter(coalescerClass))