Added some instructions to build the AST of a program (for testing).
authorCésar Natarén <cesar@mono-cvs.ximian.com>
Mon, 9 Jun 2003 06:25:58 +0000 (06:25 -0000)
committerCésar Natarén <cesar@mono-cvs.ximian.com>
Mon, 9 Jun 2003 06:25:58 +0000 (06:25 -0000)
svn path=/trunk/mcs/; revision=15224

mcs/class/Microsoft.JScript/Microsoft.JScript/driver.cs

index e9bb65f087e5801bea56030fc50139f080f7d6b5..deb680f8b0a92c796ab133d1e10330468b0ea93d 100644 (file)
@@ -39,24 +39,31 @@ namespace Microsoft.JScript
                        moduleBuilder = assemblyBuilder.DefineDynamicModule (JSCRIPT_MODULE, basename + ".exe", false);
                }
 
-               public void  GetAST (string filename)
+               public ASTList GetAST (string filename)
                {
                        StreamReader reader = new StreamReader (filename);
                        JScriptLexer lexer = new JScriptLexer (reader);
                        JScriptParser parser = new JScriptParser (lexer);
 
-                       parser.program ();
+                       ASTList astList = new ASTList ();                       
+                       parser.program (astList);
+
+                       return astList;
                }
 
+
                public static void Main (string [] args)
                {
                        try {                   
                                string basename = Path.GetFileNameWithoutExtension (args [0]);
                                Jsc compiler = new Jsc (basename);
-                               compiler.GetAST (args [0]);
-                       
+
+                               ASTList astList = compiler.GetAST (args [0]);
+
+                               Console.WriteLine (astList.ToString ());
+
                        } catch (IndexOutOfRangeException) {
-                               Console.WriteLine ("Usage: [mono] mjsc.exe filename.js");
+                               Console.WriteLine ("Usage: [mono] mjs.exe filename.js");
                        }
                }
        }