package omgrofl;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import omgrofl.interpreter.Memory;
import omgrofl.interpreter.Script;
import omgrofl.interpreter.ScriptParser;
import omgrofl.interpreter.exceptions.ScriptParseException;
import omgrofl.interpreter.exceptions.ScriptRuntimeException;

public class Main {
    
    public static void main(String[] args) throws IOException {
        File examplesDirectory = new File("examples");
        String[] files = examplesDirectory.list();
        
        Arrays.sort(files);
        
        ScriptParser scriptParser = new ScriptParser();
        
        for (String filename : files) {
            if (filename.endsWith(".omgrofl")) {
                System.out.print(filename);
                System.out.println(":");
                
                Memory memory = new Memory();
                
                try {
                    File input = new File(examplesDirectory, filename);
                    Script script = scriptParser.parse(input, memory);
                    script.run();
                } catch (ScriptParseException e) {
                    System.out.print("[failed to parse]");
                } catch (ScriptRuntimeException e) {
                    System.out.print("[runtime exception]");
                }
                
                System.out.println();
                System.out.println();
            }
        }
    }
}

@@ -1165,16 +1165,18 @@
 ut.print
+ln
 (%22%5Bfaile
@@ -1186,24 +1186,65 @@
 o parse%5D%22);%0A
+                    System.out.print(e);%0A
             
@@ -1320,16 +1320,18 @@
 ut.print
+ln
 (%22%5Brunti
@@ -1355,33 +1355,56 @@
                 
-%7D
+    System.out.print(e);
 %0A               
@@ -1396,32 +1396,43 @@
                 
+%7D finally %7B
 %0A               
@@ -1424,32 +1424,36 @@
                 
+    
 System.out.print
@@ -1466,32 +1466,36 @@
                 
+    
 System.out.print
@@ -1492,32 +1492,50 @@
 .out.println();%0A
+                %7D%0A
             %7D%0A  

Print additional information when exception occurs