J2CPS.java 2.5 KB

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