comparison 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
comparison
equal deleted inserted replaced
13835:67e4e7f56911 13836:64c77f0577bb
114 public class SLMain { 114 public class SLMain {
115 115
116 /** 116 /**
117 * The main entry point. Use the mx command "mx sl" to run it with the correct class path setup. 117 * The main entry point. Use the mx command "mx sl" to run it with the correct class path setup.
118 */ 118 */
119 public static void main(String[] args) { 119 public static void main(String[] args) throws IOException {
120 SourceManager sourceManager = new SourceManager();
121
122 Source source;
120 if (args.length == 0) { 123 if (args.length == 0) {
121 throw new SLException("SL source file must be specified as the first argument"); 124 source = sourceManager.get("stdin", System.in);
122 } 125 } else {
123 String fileName = args[0]; 126 source = sourceManager.get(args[0]);
127 }
128
124 int repeats = 1; 129 int repeats = 1;
125 if (args.length >= 2) { 130 if (args.length >= 2) {
126 repeats = Integer.parseInt(args[1]); 131 repeats = Integer.parseInt(args[1]);
127 } 132 }
128 133
129 SourceManager sourceManager = new SourceManager();
130 Source source = sourceManager.get(fileName);
131 SLContext context = new SLContext(sourceManager, new BufferedReader(new InputStreamReader(System.in)), System.out); 134 SLContext context = new SLContext(sourceManager, new BufferedReader(new InputStreamReader(System.in)), System.out);
132 run(context, source, System.out, repeats); 135 run(context, source, System.out, repeats);
133 } 136 }
134 137
135 /** 138 /**