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(); } }
public static int Main (string [] args) { if (args.Length != 1) { Console.WriteLine ("Usage : ilasm [filename]"); return 1; } StreamReader reader = File.OpenText (args [0]); ILTokenizer scanner = new ILTokenizer (reader); bool testScanner = true; if (testScanner) { ILToken tok; while ((tok = scanner.NextToken) != ILToken.EOF) { Console.WriteLine (tok); } } else { ILParser parser = new ILParser (new CodeGen ()); parser.yyparse (new ScannerAdapter (scanner), new yydebug.yyDebugSimple ()); CodeGen cg = parser.CodeGen; int n = cg.ClassCount; cg.Emit (); } return 0; }
/// <summary> /// </summary> /// <param name="host"></param> public StringHelper (ILTokenizer host) : base (host) { }
/// <summary> /// </summary> /// <param name="host"></param> public StringHelper(ILTokenizer host) : base(host) { }
/// <summary> /// </summary> /// <param name="host"></param> public StringHelperBase(ILTokenizer host) { this.host = host; mode = Token.UNKNOWN; }
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 e){ Console.Write ("{0} ({1}, {2}): ",file_path, scanner.Reader.Location.line, scanner.Reader.Location.column); throw; } finally { codegen.EndSourceFile (); } }
/// <summary> /// </summary> /// <param name="host"></param> public StringHelperBase (ILTokenizer host) { this.host = host; mode = Token.UNKNOWN; }
/// <summary> /// </summary> /// <param name="host"></param> public NumberHelper(ILTokenizer host) : base(host) { Reset(); }
/// <summary> /// </summary> /// <param name="host"></param> public NumberHelper (ILTokenizer host) : base (host) { Reset (); }