Skip to content

Commit

Permalink
Make QuitException catch nonempty
Browse files Browse the repository at this point in the history
  • Loading branch information
ysthakur committed May 25, 2023
1 parent 6d3b981 commit 05a6cf9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions shared/src/main/scala/Interpreter.scala
Expand Up @@ -20,12 +20,16 @@ object Interpreter:
if Lexer.hasSugar(sbcsified) then ctx.globals.printFn(ast.toVyxal)
if ctx.settings.logLevel == LogLevel.Debug then
println(s"Executing '$code' (ast: $ast)")

try execute(ast)
catch
case _: QuitException => // Program quit using Q
// todo implicit output according to settings
if !ctx.isStackEmpty && ctx.settings.endPrintMode == EndPrintMode.Default
then vyPrintln(ctx.peek)
case _: QuitException =>
if ctx.settings.logLevel == LogLevel.Debug then
println(s"Program quit using Q")

// todo implicit output according to settings
if !ctx.isStackEmpty && ctx.settings.endPrintMode == EndPrintMode.Default
then vyPrintln(ctx.peek)
case Left(error) =>
throw new Error(s"Error while executing $code: $error")
end execute
Expand Down

0 comments on commit 05a6cf9

Please sign in to comment.