Updated Application overview (markdown)
@@ -311,17 +311,6 @@ class DefaultInterpreter {
|
||||
return run(lines, "<inline>", environment, printTokens, printAst, dryRun)
|
||||
}
|
||||
|
||||
fun run(
|
||||
file: File,
|
||||
environment: Environment = DefaultEnvironment(),
|
||||
printTokens: Boolean = false,
|
||||
printAst: Boolean = false,
|
||||
dryRun: Boolean = false
|
||||
): Environment {
|
||||
val lines = file.readLines()
|
||||
return run(lines, file.canonicalPath, environment, printTokens, printAst, dryRun)
|
||||
}
|
||||
|
||||
private fun run(
|
||||
lines: List<String>,
|
||||
source: String,
|
||||
@@ -333,21 +322,29 @@ class DefaultInterpreter {
|
||||
environment.loadModule("smnp.lang")
|
||||
|
||||
val tokens = tokenizer.tokenize(lines, source)
|
||||
if (printTokens) println(tokens)
|
||||
|
||||
val ast = parser.parse(tokens)
|
||||
if (printAst) ast.node.pretty()
|
||||
|
||||
if (!dryRun) {
|
||||
val result = evaluator.evaluate(ast.node, environment)
|
||||
|
||||
if (result.result == EvaluationResult.FAILED) {
|
||||
throw RuntimeException("Evaluation failed")
|
||||
}
|
||||
evaluator.evaluate(ast.node, environment)
|
||||
}
|
||||
|
||||
if (printTokens) println(tokens)
|
||||
if (printAst) ast.node.pretty()
|
||||
|
||||
return environment
|
||||
}
|
||||
|
||||
fun run(
|
||||
file: File,
|
||||
environment: Environment = DefaultEnvironment(),
|
||||
printTokens: Boolean = false,
|
||||
printAst: Boolean = false,
|
||||
dryRun: Boolean = false
|
||||
): Environment {
|
||||
val lines = file.readLines()
|
||||
return run(lines, file.canonicalPath, environment, printTokens, printAst, dryRun)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user