@@ -40,8 +40,7 @@ public static void main(String[] args) throws IOException {
40
40
return ;
41
41
}
42
42
43
- final Options options = new Options ();
44
- boolean beautifyMode = false ;
43
+ final RunOptions options = new RunOptions ();
45
44
String input = null ;
46
45
for (int i = 0 ; i < args .length ; i ++) {
47
46
switch (args [i ]) {
@@ -52,19 +51,19 @@ public static void main(String[] args) throws IOException {
52
51
53
52
case "-b" :
54
53
case "--beautify" :
55
- beautifyMode = true ;
54
+ options . beautifyMode = true ;
56
55
break ;
57
-
56
+
58
57
case "-t" :
59
58
case "--showtokens" :
60
59
options .showTokens = true ;
61
60
break ;
62
-
61
+
63
62
case "-m" :
64
63
case "--showtime" :
65
64
options .showMeasurements = true ;
66
65
break ;
67
-
66
+
68
67
case "-o" :
69
68
case "--optimize" :
70
69
if (i + 1 < args .length ) {
@@ -88,7 +87,7 @@ public static void main(String[] args) throws IOException {
88
87
case "--lint" :
89
88
options .lintMode = true ;
90
89
return ;
91
-
90
+
92
91
case "-f" :
93
92
case "--file" :
94
93
if (i + 1 < args .length ) {
@@ -104,7 +103,7 @@ public static void main(String[] args) throws IOException {
104
103
System .arraycopy (ownlangArgs , 0 , newArgs , 0 , ownlangArgs .length );
105
104
Sandbox .main (newArgs );
106
105
return ;
107
-
106
+
108
107
default :
109
108
if (input == null ) {
110
109
input = args [i ];
@@ -116,20 +115,15 @@ public static void main(String[] args) throws IOException {
116
115
if (input == null ) {
117
116
throw new IllegalArgumentException ("Empty input" );
118
117
}
119
- if (beautifyMode ) {
118
+ if (options . beautifyMode ) {
120
119
System .out .println (Beautifier .beautify (input ));
121
120
return ;
122
121
}
123
122
run (input , options );
124
123
}
125
124
126
125
private static void runDefault () throws IOException {
127
- final Options options = new Options ();
128
- options .showAst = false ;
129
- options .showTokens = false ;
130
- options .showMeasurements = false ;
131
- options .lintMode = false ;
132
- options .optimizationLevel = 0 ;
126
+ final RunOptions options = new RunOptions ();
133
127
run (SourceLoader .readSource ("program.own" ), options );
134
128
}
135
129
@@ -153,7 +147,7 @@ private static void createOwnLangArgs(String[] javaArgs, int index) {
153
147
System .arraycopy (javaArgs , index , ownlangArgs , 0 , ownlangArgs .length );
154
148
}
155
149
156
- private static void run (String input , Options options ) {
150
+ private static void run (String input , RunOptions options ) {
157
151
options .validate ();
158
152
final TimeMeasurement measurement = new TimeMeasurement ();
159
153
measurement .start ("Tokenize time" );
@@ -209,16 +203,18 @@ private static void run(String input, Options options) {
209
203
}
210
204
}
211
205
212
- private static class Options {
206
+ private static class RunOptions {
213
207
boolean showTokens , showAst , showMeasurements ;
214
208
boolean lintMode ;
209
+ boolean beautifyMode ;
215
210
int optimizationLevel ;
216
211
217
- Options () {
212
+ RunOptions () {
218
213
showTokens = false ;
219
214
showAst = false ;
220
215
showMeasurements = false ;
221
216
lintMode = false ;
217
+ beautifyMode = false ;
222
218
optimizationLevel = 0 ;
223
219
}
224
220
0 commit comments