mirror of
https://github.com/GayPizzaSpecifications/pork.git
synced 2025-08-03 05:10:55 +00:00
Prepare for benchmarking and profiling.
This commit is contained in:
parent
2f0ee43556
commit
7de8f8cd63
@ -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")
|
||||
}
|
||||
|
@ -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 ->
|
||||
|
Loading…
Reference in New Issue
Block a user