J2CPS.java 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**********************************************************************/
  2. /* Main class for J2CPS */
  3. /* */
  4. /* (c) copyright QUT */
  5. /**********************************************************************/
  6. package J2CPS;
  7. import java.io.IOException;
  8. public class J2CPS {
  9. /**
  10. * Main program. Takes a package name as a parameter, produces the
  11. * Component Pascal symbol file.
  12. */
  13. public static void main(String args[]) {
  14. int argLen = args.length;
  15. boolean anonPack = false;
  16. J2CPSFiles.GetPaths();
  17. String filename = null;
  18. TypeDesc.InitTypes();
  19. if (argLen == 0) {
  20. System.err.println("J2CPS version 1.3.12 (Nov. 2011)");
  21. System.err.println("Usage: java J2CPS [options] packagename");
  22. System.err.println("Options may be in any order.");
  23. System.err.println(" -d dir symbol file directory");
  24. System.err.println(" -u use unique names");
  25. System.err.println(" -v verbose diagnostic messages");
  26. System.exit(0);
  27. }
  28. else {
  29. int argIx = 0;
  30. filename = args[argIx];
  31. while (filename.startsWith("-")) {
  32. /* parse options here */
  33. if (filename.charAt(1) == 'v') {
  34. ClassDesc.verbose = true;
  35. } else if (filename.charAt(1) == 'f') {
  36. System.out.println("Class not package");
  37. anonPack = true;
  38. } else if (filename.charAt(1) == 'u') {
  39. System.out.println("Using unique names");
  40. ClassDesc.overloadedNames = false;
  41. } else if (filename.charAt(1) == 'd') {
  42. if (argIx + 1 < argLen) {
  43. filename = args[++argIx];
  44. J2CPSFiles.SetSymDir(filename);
  45. } else {
  46. System.err.println("-d option is missing directory name");
  47. }
  48. } else {
  49. System.err.println("Unknown option " + filename);
  50. }
  51. if (argIx + 1 < argLen) {
  52. filename = args[++argIx];
  53. } else {
  54. System.err.println("No package name given, terminating");
  55. System.exit(1);
  56. }
  57. }
  58. }
  59. try {
  60. PackageDesc thisPackage = PackageDesc.MakeNewPackageDesc(filename, anonPack);
  61. PackageDesc.ReadPackages();
  62. PackageDesc.WriteSymbolFiles();
  63. }
  64. catch (IOException e) {
  65. System.err.println("IOException occurs while reading input file.");
  66. System.err.println("Aborting...");
  67. System.exit(1);
  68. }
  69. }
  70. }