Skip to content

Commit

Permalink
Prepare for benchmarking and profiling.
Browse files Browse the repository at this point in the history
  • Loading branch information
azenla committed Sep 5, 2023
1 parent 2f0ee43 commit 7de8f8c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
13 changes: 13 additions & 0 deletions tool/src/main/kotlin/gay/pizza/pork/tool/RunCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down

0 comments on commit 7de8f8c

Please sign in to comment.