2 // driver.cs: Guides the compilation process through the different phases.
5 // Cesar Lopez Nataren (cesar@ciencias.unam.mx)
7 // (C) 2003, Cesar Lopez Nataren
10 namespace Microsoft.JScript.Tmp
14 using System.Collections;
15 using System.Reflection.Emit;
16 using System.Reflection;
17 using System.Runtime.CompilerServices;
24 SemanticAnaliser semAnalizer;
25 CodeGenerator codeGen;
27 public Jsc (string filename)
29 this.filename = filename;
30 this.assemblyName = Path.GetFileNameWithoutExtension (filename);
32 program = new ASTList ();
38 this.GetAST (filename);
39 Console.WriteLine (this.program.ToString ());
40 // this.SemanticAnalysis ();
43 this.codeGen.assemblyBuilder.Save (assemblyName + ".exe");
47 public void GenerateCode ()
49 this.codeGen = new CodeGenerator (assemblyName,
50 AssemblyBuilderAccess.RunAndSave);
52 this.codeGen.EmitJScript0 (this.program);
53 this.codeGen.EmitJScriptMain ();
57 public void GetAST (string filename)
59 StreamReader reader = new StreamReader (filename);
60 JScriptLexer lexer = new JScriptLexer (reader);
61 JScriptParser parser = new JScriptParser (lexer);
63 parser.program (program);
67 public static void Main (string [] args)
70 Jsc compiler = new Jsc (args [0]);
73 Console.WriteLine (compiler.program.ToString ());
75 } catch (IndexOutOfRangeException) {
76 Console.WriteLine ("Usage: [mono] mjs.exe filename.js");