diff --git a/Compiler/.idea/.idea.Compiler/.idea/workspace.xml b/Compiler/.idea/.idea.Compiler/.idea/workspace.xml
index f264d19..3057778 100644
--- a/Compiler/.idea/.idea.Compiler/.idea/workspace.xml
+++ b/Compiler/.idea/.idea.Compiler/.idea/workspace.xml
@@ -21,7 +21,7 @@
-
+
@@ -85,8 +85,8 @@
-
+
@@ -147,7 +147,7 @@
-
+
@@ -181,22 +181,22 @@
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs
index ae27887..c44d3fd 100644
--- a/Compiler/Compiler.cs
+++ b/Compiler/Compiler.cs
@@ -18,17 +18,26 @@ namespace Compiler
foreach (string filepath in validFiles)
{
List tokens = TestLexer(filepath, 0);
- TestParser(tokens, filepath);
+ TestParser(tokens, filepath, 1);
}
foreach (string filepath in invalidFiles)
{
List tokens = TestLexer(filepath, 0);
- TestParser(tokens, filepath);
+ TestParser(tokens, filepath, 1);
}
}
- static List TestLexer(string path, int debug)
+ static void PrettyPrint(Node root, string indent)
+ {
+ Console.WriteLine(indent + root.NodeType);
+ foreach (Node child in root.Children)
+ {
+ PrettyPrint(child, indent + " ");
+ }
+ }
+
+ static List TestLexer(string path, int debugLevel)
{
//List> tokenLists = new List>();
//string[] files = Directory.GetFiles(path);
@@ -41,7 +50,7 @@ namespace Compiler
List tokens = lexer.Lex(contents);
Console.WriteLine("Lexed \"" + path.Split("/").Last() + "\"");
- if (debug > 0)
+ if (debugLevel > 0)
{
Console.WriteLine("-----------" + path + "-----------");
foreach (Token token in tokens)
@@ -56,13 +65,18 @@ namespace Compiler
return tokens;
}
- static void TestParser(List tokenList, string path)
+ static void TestParser(List tokenList, string path, int debugLevel)
{
Parser.Parser p = new Parser.Parser(tokenList);
try
{
Node programNode = p.Parse(NodeType.ProgramNode);
+ if (debugLevel > 0)
+ {
+ PrettyPrint(programNode, "");
+ }
+
Console.WriteLine("Parsed \"" + path.Split("/").Last() + "\"");
}
catch (Exception e)