* @param arg Command line arguments
*/
static public void main(String[] arg)
{
// Create a compiler object
RECompiler r = new RECompiler();
// Print usage if arguments are incorrect
if (arg.length <= 0 || arg.length % 2 != 0)
{
System.out.println("Usage: recompile <patternname> <pattern>");
System.exit(0);
}
// Loop through arguments, compiling each
for (int i = 0; i < arg.length; i += 2)
{
try
{
// Compile regular expression
String name = arg[i];
String pattern = arg[i+1];
String instructions = name + "PatternInstructions";
// Output program as a nice, formatted character array
System.out.print("\n // Pre-compiled regular expression '" + pattern + "'\n"
+ " private static char[] " + instructions + " = \n {");
// Compile program for pattern
REProgram program = r.compile(pattern);
// Number of columns in output
int numColumns = 7;
// Loop through program