mirror of
				https://github.com/GayPizzaSpecifications/pork.git
				synced 2025-11-03 17:39:38 +00:00 
			
		
		
		
	Prepare for benchmarking and profiling.
This commit is contained in:
		@ -16,7 +16,7 @@ class AttributeCommand : CliktCommand(help = "Attribute AST", name = "attribute"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    val coalescer = NodeCoalescer { node ->
 | 
					    val coalescer = NodeCoalescer { node ->
 | 
				
			||||||
      val tokens = attribution.assembleTokens(node)
 | 
					      val tokens = attribution.assembleTokens(node)
 | 
				
			||||||
      println("node ${node.toString().replace("\n", "^")}")
 | 
					      println("node ${node.type.name}")
 | 
				
			||||||
      for (token in tokens) {
 | 
					      for (token in tokens) {
 | 
				
			||||||
        println("token $token")
 | 
					        println("token $token")
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
				
			|||||||
@ -2,14 +2,27 @@ package gay.pizza.pork.tool
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import com.github.ajalt.clikt.core.CliktCommand
 | 
					import com.github.ajalt.clikt.core.CliktCommand
 | 
				
			||||||
import com.github.ajalt.clikt.parameters.arguments.argument
 | 
					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 com.github.ajalt.clikt.parameters.types.path
 | 
				
			||||||
import gay.pizza.pork.evaluator.CallableFunction
 | 
					import gay.pizza.pork.evaluator.CallableFunction
 | 
				
			||||||
import gay.pizza.pork.evaluator.Scope
 | 
					import gay.pizza.pork.evaluator.Scope
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class RunCommand : CliktCommand(help = "Run Program", name = "run") {
 | 
					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)
 | 
					  val path by argument("file").path(mustExist = true, canBeDir = false)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  override fun run() {
 | 
					  override fun run() {
 | 
				
			||||||
 | 
					    if (loop) {
 | 
				
			||||||
 | 
					      while (true) {
 | 
				
			||||||
 | 
					        runProgramOnce()
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      runProgramOnce()
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  private fun runProgramOnce() {
 | 
				
			||||||
    val tool = FileTool(path)
 | 
					    val tool = FileTool(path)
 | 
				
			||||||
    val scope = Scope()
 | 
					    val scope = Scope()
 | 
				
			||||||
    scope.define("println", CallableFunction { arguments ->
 | 
					    scope.define("println", CallableFunction { arguments ->
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user