01: package kawa.lang;
02:
03: import gnu.mapping.*;
04: import gnu.bytecode.ClassType;
05: import gnu.expr.*;
06: import gnu.text.SourceMessages;
07:
08: /** Procedure to read and compile and entire file.
09: * Creates a .zip archive containing the resulting classes.
10: * @author Per Bothner
11: */
12:
13: public class CompileFile {
14: public static final Compilation read(String name,
15: SourceMessages messages) throws java.io.IOException,
16: gnu.text.SyntaxException {
17: try {
18: InPort fstream = InPort.openFile(name);
19: Compilation result = read(fstream, messages);
20: fstream.close();
21: return result;
22: } catch (java.io.FileNotFoundException e) {
23: throw new WrappedException("compile-file: file not found: "
24: + name, e);
25: } catch (java.io.IOException e) {
26: throw new WrappedException("compile-file: read-error: "
27: + name, e);
28: }
29: }
30:
31: public static final Compilation read(InPort port,
32: SourceMessages messages) throws java.io.IOException,
33: gnu.text.SyntaxException {
34: return Language.getDefaultLanguage().parse(port, messages, 0);
35: }
36: }
|