示例#1
0
        public void Parse()
        {
            tree = Program.compiler.Parse();

            treeView1.Nodes.Clear();

            this.fillTree(treeView1.Nodes, tree);
            treeView1.ExpandAll();
        }
示例#2
0
        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;
            }
        }
示例#3
0
 public Parser.treeNode Parse()
 {
     this.parser = new Parser(this.getTokens());
     Parser.treeNode tree = this.parser.Parse();
     return(tree);
 }