in util/src/main/java/java_cup/Main.java [286:379]
protected static void parse_args(String argv[])
{
int len = argv.length;
int i;
/* parse the options */
for (i=0; i<len; i++)
{
/* try to get the various options */
if (argv[i].equals("-package"))
{
/* must have an arg */
if (++i >= len || argv[i].startsWith("-") ||
argv[i].endsWith(".cup"))
usage("-package must have a name argument");
/* record the name */
emit.package_name = argv[i];
}
else if (argv[i].equals("-parser"))
{
/* must have an arg */
if (++i >= len || argv[i].startsWith("-") ||
argv[i].endsWith(".cup"))
usage("-parser must have a name argument");
/* record the name */
emit.parser_class_name = argv[i];
}
else if (argv[i].equals("-symbols"))
{
/* must have an arg */
if (++i >= len || argv[i].startsWith("-") ||
argv[i].endsWith(".cup"))
usage("-symbols must have a name argument");
/* record the name */
emit.symbol_const_class_name = argv[i];
}
else if (argv[i].equals("-nonterms"))
{
include_non_terms = true;
}
else if (argv[i].equals("-expect"))
{
/* must have an arg */
if (++i >= len || argv[i].startsWith("-") ||
argv[i].endsWith(".cup"))
usage("-expect must have a name argument");
/* record the number */
try {
expect_conflicts = Integer.parseInt(argv[i]);
} catch (NumberFormatException e) {
usage("-expect must be followed by a decimal integer");
}
}
else if (argv[i].equals("-compact_red")) opt_compact_red = true;
else if (argv[i].equals("-nosummary")) no_summary = true;
else if (argv[i].equals("-nowarn")) emit.nowarn = true;
else if (argv[i].equals("-dump_states")) opt_dump_states = true;
else if (argv[i].equals("-dump_tables")) opt_dump_tables = true;
else if (argv[i].equals("-progress")) print_progress = true;
else if (argv[i].equals("-dump_grammar")) opt_dump_grammar = true;
else if (argv[i].equals("-dump"))
opt_dump_states = opt_dump_tables = opt_dump_grammar = true;
else if (argv[i].equals("-time")) opt_show_timing = true;
else if (argv[i].equals("-debug")) opt_do_debug = true;
/* frankf 6/18/96 */
else if (argv[i].equals("-nopositions")) lr_values = false;
/* CSA 12/21/97 */
else if (argv[i].equals("-interface")) sym_interface = true;
/* CSA 23-Jul-1999 */
else if (argv[i].equals("-noscanner")) suppress_scanner = true;
/* CSA 23-Jul-1999 */
else if (argv[i].equals("-version")) {
System.out.println(version.title_str);
System.exit(1);
}
/* CSA 24-Jul-1999; suggestion by Jean Vaucher */
else if (!argv[i].startsWith("-") && i==len-1) {
/* use input from file. */
try {
System.setIn(new FileInputStream(argv[i]));
} catch (java.io.FileNotFoundException e) {
usage("Unable to open \"" + argv[i] +"\" for input");
}
}
else
{
usage("Unrecognized option \"" + argv[i] + "\"");
}
}
}