Prepare for benchmarking and profiling.

This commit is contained in:
2023-09-05 01:02:13 -07:00
parent 2f0ee43556
commit 7de8f8cd63
2 changed files with 14 additions and 1 deletions

View File

@ -16,7 +16,7 @@ class AttributeCommand : CliktCommand(help = "Attribute AST", name = "attribute"
val coalescer = NodeCoalescer { node ->
val tokens = attribution.assembleTokens(node)
println("node ${node.toString().replace("\n", "^")}")
println("node ${node.type.name}")
for (token in tokens) {
println("token $token")
}

View File

@ -2,14 +2,27 @@ package gay.pizza.pork.tool
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.arguments.argument
import com.github.ajalt.clikt.parameters.options.flag
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.types.path
import gay.pizza.pork.evaluator.CallableFunction
import gay.pizza.pork.evaluator.Scope
class RunCommand : CliktCommand(help = "Run Program", name = "run") {
val loop by option("--loop", help = "Loop Program").flag()
val path by argument("file").path(mustExist = true, canBeDir = false)
override fun run() {
if (loop) {
while (true) {
runProgramOnce()
}
} else {
runProgramOnce()
}
}
private fun runProgramOnce() {
val tool = FileTool(path)
val scope = Scope()
scope.define("println", CallableFunction { arguments ->