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

@ -1,7 +1,7 @@
// GENERATED CODE FROM PORK AST CODEGEN
package gay.pizza.pork.ast.gen
class NodeCoalescer(val handler: (Node) -> Unit) : NodeVisitor<Unit> {
class NodeCoalescer(val followChildren: Boolean = true, val handler: (Node) -> Unit) : NodeVisitor<Unit> {
override fun visitArgumentSpec(node: ArgumentSpec): Unit =
handle(node)
@ -97,6 +97,8 @@ class NodeCoalescer(val handler: (Node) -> Unit) : NodeVisitor<Unit> {
fun handle(node: Node) {
handler(node)
node.visitChildren(this)
if (followChildren) {
node.visitChildren(this)
}
}
}