Updated Application overview (markdown)
@@ -311,17 +311,6 @@ class DefaultInterpreter {
|
|||||||
return run(lines, "<inline>", environment, printTokens, printAst, dryRun)
|
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(
|
private fun run(
|
||||||
lines: List<String>,
|
lines: List<String>,
|
||||||
source: String,
|
source: String,
|
||||||
@@ -333,21 +322,29 @@ class DefaultInterpreter {
|
|||||||
environment.loadModule("smnp.lang")
|
environment.loadModule("smnp.lang")
|
||||||
|
|
||||||
val tokens = tokenizer.tokenize(lines, source)
|
val tokens = tokenizer.tokenize(lines, source)
|
||||||
if (printTokens) println(tokens)
|
|
||||||
|
|
||||||
val ast = parser.parse(tokens)
|
val ast = parser.parse(tokens)
|
||||||
if (printAst) ast.node.pretty()
|
|
||||||
|
|
||||||
if (!dryRun) {
|
if (!dryRun) {
|
||||||
val result = evaluator.evaluate(ast.node, environment)
|
evaluator.evaluate(ast.node, environment)
|
||||||
|
}
|
||||||
|
|
||||||
if (result.result == EvaluationResult.FAILED) {
|
if (printTokens) println(tokens)
|
||||||
throw RuntimeException("Evaluation failed")
|
if (printAst) ast.node.pretty()
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return environment
|
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