public void Parse() { tree = Program.compiler.Parse(); treeView1.Nodes.Clear(); this.fillTree(treeView1.Nodes, tree); treeView1.ExpandAll(); }
private void fillTree(TreeNodeCollection collection, Parser.treeNode treenode) { Parser.treeNode temp = treenode; while (temp != null) { string text = ""; switch (temp.nodekind) { case Parser.nodeKind.Stmt: text += temp.stmtkind; break; case Parser.nodeKind.Exp: text += temp.expkind; break; } if (temp.name != "") { text += " (" + temp.name + ")"; } if (temp.val != null) { text += " (" + temp.val + ")"; } if (temp.expkind == Parser.expKind.Op) { text += " (" + temp.tokentype.Value.token_Type + ")"; } TreeNode last_node = collection.Add(text); foreach (Parser.treeNode child in temp.child) { if (child == null) { break; } fillTree(last_node.Nodes, child); } temp = temp.sibling; } }
public Parser.treeNode Parse() { this.parser = new Parser(this.getTokens()); Parser.treeNode tree = this.parser.Parse(); return(tree); }