public static List<File> parseOptions(String argv[]) throws SilentExit { List<File> files = new ArrayList<File>(); for (int i = 0; i < argv.length; i++) { if (argv[i].equals("-d") || argv[i].equals("--outdir")) { // $NON-NLS-1$ //$NON-NLS-2$ if (++i >= argv.length) { Out.error(ErrorMessages.NO_DIRECTORY); throw new GeneratorException(); } Options.setDir(argv[i]); continue; } if (argv[i].equals("--skel") || argv[i].equals("-skel")) { // $NON-NLS-1$ //$NON-NLS-2$ if (++i >= argv.length) { Out.error(ErrorMessages.NO_SKEL_FILE); throw new GeneratorException(); } Options.setSkeleton(new File(argv[i])); continue; } if (argv[i].equals("-jlex") || argv[i].equals("--jlex")) { // $NON-NLS-1$ //$NON-NLS-2$ Options.jlex = true; continue; } if (argv[i].equals("-v") || argv[i].equals("--verbose") || argv[i].equals("-verbose")) { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ Options.verbose = true; Options.progress = true; continue; } if (argv[i].equals("-q") || argv[i].equals("--quiet") || argv[i].equals("-quiet")) { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ Options.verbose = false; Options.progress = false; continue; } if (argv[i].equals("--dump") || argv[i].equals("-dump")) { // $NON-NLS-1$ //$NON-NLS-2$ Options.dump = true; continue; } if (argv[i].equals("--time") || argv[i].equals("-time")) { // $NON-NLS-1$ //$NON-NLS-2$ Options.time = true; continue; } if (argv[i].equals("--version") || argv[i].equals("-version")) { // $NON-NLS-1$ //$NON-NLS-2$ Out.println(ErrorMessages.THIS_IS_JFLEX, version); throw new SilentExit(); } if (argv[i].equals("--dot") || argv[i].equals("-dot")) { // $NON-NLS-1$ //$NON-NLS-2$ Options.dot = true; continue; } if (argv[i].equals("--help") || argv[i].equals("-h") || argv[i].equals("/h")) { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ printUsage(); throw new SilentExit(); } if (argv[i].equals("--info") || argv[i].equals("-info")) { // $NON-NLS-1$ //$NON-NLS-2$ Out.printSystemInfo(); throw new SilentExit(); } if (argv[i].equals("--nomin") || argv[i].equals("-nomin")) { // $NON-NLS-1$ //$NON-NLS-2$ Options.no_minimize = true; continue; } if (argv[i].equals("--pack") || argv[i].equals("-pack")) { // $NON-NLS-1$ //$NON-NLS-2$ Options.gen_method = Options.PACK; continue; } if (argv[i].equals("--table") || argv[i].equals("-table")) { // $NON-NLS-1$ //$NON-NLS-2$ Options.gen_method = Options.TABLE; continue; } if (argv[i].equals("--switch") || argv[i].equals("-switch")) { // $NON-NLS-1$ //$NON-NLS-2$ Options.gen_method = Options.SWITCH; continue; } if (argv[i].equals("--nobak") || argv[i].equals("-nobak")) { // $NON-NLS-1$ //$NON-NLS-2$ Options.no_backup = true; continue; } if (argv[i].equals("--legacydot") || argv[i].equals("-legacydot")) { // $NON-NLS-1$ //$NON-NLS-2$ Options.legacy_dot = true; continue; } // TODO: In the JFlex version after 1.6, --inputstreamctor will be removed. if (argv[i].equals("--inputstreamctor") || argv[i].equals("-inputstreamctor")) { // $NON-NLS-1$ //$NON-NLS-2$ Options.emitInputStreamCtor = true; continue; } // TODO: In the JFlex version after 1.6, --noinputstreamctor will be removed. if (argv[i].equals("--noinputstreamctor") || argv[i].equals("-noinputstreamctor")) { // $NON-NLS-1$ //$NON-NLS-2$ Options.emitInputStreamCtor = false; continue; } if (argv[i].equals("--uniprops") || argv[i].equals("-uniprops")) { // $NON-NLS-1$ //$NON-NLS-2$ if (++i >= argv.length) { Out.error( ErrorMessages.PROPS_ARG_REQUIRES_UNICODE_VERSION, UnicodeProperties.UNICODE_VERSIONS); throw new GeneratorException(); } String unicodeVersion = argv[i]; try { printUnicodePropertyValuesAndAliases(unicodeVersion); } catch (UnicodeProperties.UnsupportedUnicodeVersionException e) { Out.error( ErrorMessages.UNSUPPORTED_UNICODE_VERSION_SUPPORTED_ARE, UnicodeProperties.UNICODE_VERSIONS); throw new GeneratorException(); } throw new SilentExit(); } if (argv[i].startsWith("-")) { // $NON-NLS-1$ Out.error(ErrorMessages.UNKNOWN_COMMANDLINE, argv[i]); printUsage(); throw new SilentExit(); } // if argv[i] is not an option, try to read it as file File f = new File(argv[i]); if (f.isFile() && f.canRead()) files.add(f); else { Out.error("Sorry, couldn't open \"" + f + "\""); // $NON-NLS-2$ throw new GeneratorException(); } } return files; }
public static Vector parseOptions(String argv[]) throws SilentExit { Vector files = new Vector(); for (int i = 0; i < argv.length; i++) { if (argv[i].equals("-d") || argv[i].equals("--outdir")) { // $NON-NLS-1$ //$NON-NLS-2$ if (++i >= argv.length) { Out.error(ErrorMessages.NO_DIRECTORY); throw new GeneratorException(); } Options.setDir(argv[i]); continue; } if (argv[i].equals("--skel") || argv[i].equals("-skel")) { // $NON-NLS-1$ //$NON-NLS-2$ if (++i >= argv.length) { Out.error(ErrorMessages.NO_SKEL_FILE); throw new GeneratorException(); } Options.setSkeleton(new File(argv[i])); continue; } if (argv[i].equals("-jlex") || argv[i].equals("--jlex")) { // $NON-NLS-1$ //$NON-NLS-2$ Options.jlex = true; continue; } if (argv[i].equals("-v") || argv[i].equals("--verbose") || argv[i].equals("-verbose")) { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ Options.verbose = true; Options.progress = true; continue; } if (argv[i].equals("-q") || argv[i].equals("--quiet") || argv[i].equals("-quiet")) { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ Options.verbose = false; Options.progress = false; continue; } if (argv[i].equals("--dump") || argv[i].equals("-dump")) { // $NON-NLS-1$ //$NON-NLS-2$ Options.dump = true; continue; } if (argv[i].equals("--time") || argv[i].equals("-time")) { // $NON-NLS-1$ //$NON-NLS-2$ Options.time = true; continue; } if (argv[i].equals("--version") || argv[i].equals("-version")) { // $NON-NLS-1$ //$NON-NLS-2$ Out.println(ErrorMessages.THIS_IS_JFLEX, version); throw new SilentExit(); } if (argv[i].equals("--dot") || argv[i].equals("-dot")) { // $NON-NLS-1$ //$NON-NLS-2$ Options.dot = true; continue; } if (argv[i].equals("--help") || argv[i].equals("-h") || argv[i].equals("/h")) { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ printUsage(); throw new SilentExit(); } if (argv[i].equals("--info") || argv[i].equals("-info")) { // $NON-NLS-1$ //$NON-NLS-2$ Out.printSystemInfo(); throw new SilentExit(); } if (argv[i].equals("--nomin") || argv[i].equals("-nomin")) { // $NON-NLS-1$ //$NON-NLS-2$ Options.no_minimize = true; continue; } if (argv[i].equals("--pack") || argv[i].equals("-pack")) { // $NON-NLS-1$ //$NON-NLS-2$ Options.gen_method = Options.PACK; continue; } if (argv[i].equals("--table") || argv[i].equals("-table")) { // $NON-NLS-1$ //$NON-NLS-2$ Options.gen_method = Options.TABLE; continue; } if (argv[i].equals("--switch") || argv[i].equals("-switch")) { // $NON-NLS-1$ //$NON-NLS-2$ Options.gen_method = Options.SWITCH; continue; } if (argv[i].equals("--nobak") || argv[i].equals("-nobak")) { // $NON-NLS-1$ //$NON-NLS-2$ Options.no_backup = true; continue; } if (argv[i].startsWith("-")) { // $NON-NLS-1$ Out.error(ErrorMessages.UNKNOWN_COMMANDLINE, argv[i]); printUsage(); throw new SilentExit(); } // if argv[i] is not an option, try to read it as file File f = new File(argv[i]); if (f.isFile() && f.canRead()) files.addElement(f); else { Out.error("Sorry, couldn't open \"" + f + "\""); // $NON-NLS-2$ throw new GeneratorException(); } } return files; }