11package com .annimon .ownlang ;
22
33import com .annimon .ownlang .exceptions .LexerException ;
4+ import com .annimon .ownlang .exceptions .StoppedException ;
45import com .annimon .ownlang .parser .Beautifier ;
56import com .annimon .ownlang .parser .Lexer ;
67import com .annimon .ownlang .parser .Linter ;
@@ -167,7 +168,7 @@ private static void run(String input, Options options) {
167168 final Statement program ;
168169 if (options .optimizationLevel > 0 ) {
169170 measurement .start ("Optimization time" );
170- program = Optimizer .optimize (parsedProgram , options .optimizationLevel );
171+ program = Optimizer .optimize (parsedProgram , options .optimizationLevel , options . showAst );
171172 measurement .stop ("Optimization time" );
172173 if (options .showAst ) {
173174 System .out .println (program .toString ());
@@ -179,6 +180,8 @@ private static void run(String input, Options options) {
179180 try {
180181 measurement .start ("Execution time" );
181182 program .execute ();
183+ } catch (StoppedException ex ) {
184+ // skip
182185 } catch (Exception ex ) {
183186 Console .handleException (Thread .currentThread (), ex );
184187 } finally {
@@ -220,6 +223,8 @@ private static void repl() {
220223 program .execute ();
221224 } catch (LexerException lex ) {
222225 continue ;
226+ } catch (StoppedException ex ) {
227+ // skip
223228 } catch (Exception ex ) {
224229 Console .handleException (Thread .currentThread (), ex );
225230 }
0 commit comments