private void ProcessFile(string file_path)
{
if (!File.Exists(file_path))
{
Console.WriteLine("File does not exist: {0}",
file_path);
Environment.Exit(2);
}
Report.AssembleFile(file_path, null,
target_string, output_file);
StreamReader reader = File.OpenText(file_path);
ILTokenizer scanner = new ILTokenizer(reader);
if (show_tokens)
{
scanner.NewTokenEvent += new NewTokenEvent(ShowToken);
}
//if (show_method_def)
// MethodTable.MethodDefinedEvent += new MethodDefinedEvent (ShowMethodDef);
//if (show_method_ref)
// MethodTable.MethodReferencedEvent += new MethodReferencedEvent (ShowMethodRef);
if (scan_only)
{
ILToken tok;
while ((tok = scanner.NextToken) != ILToken.EOF)
{
Console.WriteLine(tok);
}
return;
}
ILParser parser = new ILParser(codegen, scanner);
codegen.BeginSourceFile(file_path);
try {
if (show_parser)
{
parser.yyparse(new ScannerAdapter(scanner),
new yydebug.yyDebugSimple());
}
else
{
parser.yyparse(new ScannerAdapter(scanner), null);
}
} catch (ILTokenizingException ilte) {
Report.Error(ilte.Location, "syntax error at token '" + ilte.Token + "'");
} catch (Mono.ILASM.yyParser.yyException ye) {
Report.Error(scanner.Reader.Location, ye.Message);
} catch (ILAsmException ie) {
ie.FilePath = file_path;
ie.Location = scanner.Reader.Location;
throw;
} catch (Exception) {
Console.Write("{0} ({1}, {2}): ", file_path, scanner.Reader.Location.line, scanner.Reader.Location.column);
throw;
} finally {
codegen.EndSourceFile();
}
}