示例#1
0
        private int DrawAST(CommonAST AST, ref Graph g)
        {
            if (AST != null)
            {
                int thisNodeIndex = ASTforGLEEIndex++;

                ASTorderedByGraphIndex.Add(AST);

                Node thisNode = (Node)g.AddNode(thisNodeIndex.ToString());
                thisNode.Attr.Label = AST.getText();

                CommonAST ChildAST = (CommonAST)AST.getFirstChild();

                int previousChildIndex = -1;

                for (int i = 0; i < AST.getNumberOfChildren(); i++)
                {
                    int childIndex = DrawAST(ChildAST, ref g);

                    if (childIndex != -1)
                    {
                        g.AddEdge(thisNodeIndex.ToString(), childIndex.ToString());

                        /*                        if (previousChildIndex != -1)
                         *                      {
                         *                          Edge SiblingEdge = (Edge)g.AddEdge(previousChildIndex.ToString(),
                         *                                                              childIndex.ToString());
                         *                          SiblingEdge.Attr.Styles = new Style[] { Microsoft.Glee.Drawing.Style.Dashed };
                         *                      }
                         */
                    }

                    previousChildIndex = childIndex;

                    ChildAST = (CommonAST)ChildAST.getNextSibling();
                }

                return(thisNodeIndex);
            }
            else
            {
                return(-1);
            }
        }