Beispiel #1
0
    public GolLangParseNode(GolLangLine keywords)
    {
        this.line = keywords.clone();

        parents = null;

        leftSibling = null;

        rightSibling = null;

        children = new List <GolLangParseNode>();

        isVisited = false;
    }
Beispiel #2
0
    public void addChild(GolLangParseNode child)
    {
        children.Add(child);

        child.parents = this;

        if (children.Count > 1)
        {
            GolLangParseNode now = children[0];

            while (now.rightSibling != null)
            {
                now = now.rightSibling;
            }

            now.rightSibling  = child;
            child.leftSibling = now;
        }
    }
Beispiel #3
0
    //후위 순회 Enumerator
    public IEnumerator GetEnumerator()
    {
        head.unvisit();

        now = head;

        while (true)
        {
            GolLangParseNode temp = now.getFirstUnvisitedChild();

            if (temp == null)
            {
                if (!now.isVisited)
                {
                    now.isVisited = true;

                    yield return(now);
                }

                if (now.hasRightSibling())
                {
                    now = now.rightSibling;
                }
                else if (now.parents != null)
                {
                    now = now.parents;
                }
                else
                {
                    break;
                }
            }
            else
            {
                now = temp;
            }
        }
    }
Beispiel #4
0
 public GolLangParseTree(GolLangParseNode head)
 {
     this.head = head;
 }
Beispiel #5
0
 public GolLangParseTree()
 {
     head = null;
 }