KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > kawa > lang > CompileFile


1 package kawa.lang;
2 import java.io.*;
3 import gnu.mapping.*;
4 import gnu.bytecode.ClassType;
5 import gnu.expr.*;
6 import gnu.text.SourceMessages;
7
8 /** Procedure to read and compile and entire file.
9  * Creates a .zip archive containing the resulting classes.
10  * @author Per Bothner
11  */

12
13 public class CompileFile
14 {
15   public static final Compilation read (String JavaDoc name, SourceMessages messages)
16     throws java.io.IOException JavaDoc, gnu.text.SyntaxException
17   {
18     try
19       {
20     InPort fstream = InPort.openFile(name);
21     Compilation result = read(fstream, messages);
22     fstream.close();
23     return result;
24       }
25     catch (java.io.FileNotFoundException JavaDoc e)
26       {
27     throw new WrappedException("compile-file: file not found: " + name, e);
28       }
29     catch (java.io.IOException JavaDoc e)
30       {
31     throw new WrappedException("compile-file: read-error: " + name, e);
32       }
33   }
34
35   public static final Compilation read (InPort port, SourceMessages messages)
36     throws java.io.IOException JavaDoc, gnu.text.SyntaxException
37   {
38     return Language.getDefaultLanguage().parse(port, messages, 0);
39   }
40 }
41
Popular Tags