Ejemplo n.º 1
0
            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();
                }
            }
Ejemplo n.º 2
0
Archivo: Main.cs Proyecto: nobled/mono
	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;
	}
Ejemplo n.º 3
0
		/// <summary>
		/// </summary>
		/// <param name="host"></param>
		public StringHelper (ILTokenizer host) : base (host)
		{
		}
Ejemplo n.º 4
0
 /// <summary>
 /// </summary>
 /// <param name="host"></param>
 public StringHelper(ILTokenizer host) : base(host)
 {
 }
Ejemplo n.º 5
0
 /// <summary>
 /// </summary>
 /// <param name="host"></param>
 public StringHelperBase(ILTokenizer host)
 {
     this.host = host;
     mode      = Token.UNKNOWN;
 }
Ejemplo n.º 6
0
                        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 ();
				}
                        }
Ejemplo n.º 7
0
		/// <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();
 }
Ejemplo n.º 9
0
 /// <summary>
 /// </summary>
 /// <param name="host"></param>
 public NumberHelper (ILTokenizer host) : base (host)
 {
         Reset ();
 }