diff graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java @ 13836:64c77f0577bb

More documentation and improvements of Simple Language
author Christian Wimmer <christian.wimmer@oracle.com>
date Thu, 30 Jan 2014 17:53:27 -0800
parents b16ec83edc73
children f9b934e1e172
line wrap: on
line diff
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java	Thu Jan 30 17:52:24 2014 -0800
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java	Thu Jan 30 17:53:27 2014 -0800
@@ -116,18 +116,21 @@
     /**
      * The main entry point. Use the mx command "mx sl" to run it with the correct class path setup.
      */
-    public static void main(String[] args) {
+    public static void main(String[] args) throws IOException {
+        SourceManager sourceManager = new SourceManager();
+
+        Source source;
         if (args.length == 0) {
-            throw new SLException("SL source file must be specified as the first argument");
+            source = sourceManager.get("stdin", System.in);
+        } else {
+            source = sourceManager.get(args[0]);
         }
-        String fileName = args[0];
+
         int repeats = 1;
         if (args.length >= 2) {
             repeats = Integer.parseInt(args[1]);
         }
 
-        SourceManager sourceManager = new SourceManager();
-        Source source = sourceManager.get(fileName);
         SLContext context = new SLContext(sourceManager, new BufferedReader(new InputStreamReader(System.in)), System.out);
         run(context, source, System.out, repeats);
     }