CompileFile.java 1.0 KB

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