*
* @param args the command-line arguments
* @param grammar the grammar to use
*/
private static void writeCSharpCode(String[] args, Grammar grammar) {
CSharpParserGenerator gen = new CSharpParserGenerator(grammar);
// Read command-line arguments
for (int i = 1; i < args.length; i++) {
if (args[i].equals("--csoutput")) {
gen.setBaseDir(new File(args[++i]));
} else if (args[i].equals("--csnamespace")) {
gen.setNamespace(args[++i]);
} else if (args[i].equals("--csclassname")) {
gen.setBaseName(args[++i]);
} else if (args[i].equals("--cspublic")) {
gen.setPublicAccess(true);
} else {
printHelp("unrecognized option: " + args[i]);
System.exit(1);
}
}
// Write parser source code
try {
System.out.println("Writing C# parser source code...");
gen.write();
System.out.println("Done.");
} catch (IOException e) {
printError(e);
System.exit(1);
}