equal
deleted
inserted
replaced
60 |
60 |
61 /** The name of the compiler, for use in diagnostics. |
61 /** The name of the compiler, for use in diagnostics. |
62 */ |
62 */ |
63 String ownName; |
63 String ownName; |
64 |
64 |
|
65 /** The writer to use for normal output. |
|
66 */ |
|
67 PrintWriter stdOut; |
|
68 |
65 /** The writer to use for diagnostic output. |
69 /** The writer to use for diagnostic output. |
66 */ |
70 */ |
67 PrintWriter out; |
71 PrintWriter stdErr; |
68 |
72 |
69 /** The log to use for diagnostic output. |
73 /** The log to use for diagnostic output. |
70 */ |
74 */ |
71 public Log log; |
75 public Log log; |
72 |
76 |
100 /** |
104 /** |
101 * Construct a compiler instance. |
105 * Construct a compiler instance. |
102 * @param name the name of this tool |
106 * @param name the name of this tool |
103 */ |
107 */ |
104 public Main(String name) { |
108 public Main(String name) { |
105 this(name, new PrintWriter(System.err, true)); |
109 this.ownName = name; |
106 } |
110 } |
107 |
111 |
108 /** |
112 /** |
109 * Construct a compiler instance. |
113 * Construct a compiler instance. |
110 * @param name the name of this tool |
114 * @param name the name of this tool |
111 * @param out a stream to which to write messages |
115 * @param out a stream to which to write messages |
112 */ |
116 */ |
113 public Main(String name, PrintWriter out) { |
117 public Main(String name, PrintWriter out) { |
114 this.ownName = name; |
118 this.ownName = name; |
115 this.out = out; |
119 this.stdOut = this.stdErr = out; |
116 } |
120 } |
117 |
121 |
118 /** Report a usage error. |
122 /** Report a usage error. |
119 */ |
123 */ |
120 void error(String key, Object... args) { |
124 void error(String key, Object... args) { |
159 * @param argv the command line parameters |
163 * @param argv the command line parameters |
160 * @param context the context |
164 * @param context the context |
161 * @return the result of the compilation |
165 * @return the result of the compilation |
162 */ |
166 */ |
163 public Result compile(String[] argv, Context context) { |
167 public Result compile(String[] argv, Context context) { |
164 context.put(Log.outKey, out); |
168 if (stdOut != null) { |
|
169 context.put(Log.outKey, stdOut); |
|
170 } |
|
171 |
|
172 if (stdErr != null) { |
|
173 context.put(Log.errKey, stdErr); |
|
174 } |
|
175 |
165 log = Log.instance(context); |
176 log = Log.instance(context); |
166 |
177 |
167 if (argv.length == 0) { |
178 if (argv.length == 0) { |
168 Option.HELP.process(new OptionHelper.GrumpyHelper(log) { |
179 Option.HELP.process(new OptionHelper.GrumpyHelper(log) { |
169 @Override |
180 @Override |