/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * SableCC version 2.1                                                     *
 * Copyright (C) 1997, 1998 Etienne Gagnon (gagnon@sable.mcgill.ca).  All  *
 * rights reserved.                                                        *
 *                                                                         *
 * This program is free software; you can redistribute it and/or modify    *
 * it under the terms of the GNU General Public License as published by    *
 * the Free Software Foundation; either version 2 of the License, or       *
 * (at your option) any later version.                                     *
 *                                                                         *
 * This program is distributed in the hope that it will be useful,         *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of          *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
 * GNU General Public License for more details.                            *
 *                                                                         *
 * You should have received a copy of the GNU General Public License along *
 * with this program; if not, write to the Free Software Foundation, Inc., *
 * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                 *
 *                                                                         *
 * The GNU General Public License does not permit incorporating this       *
 * program into proprietary programs. If you would like to obtain a        *
 * different license for a version that has not been modified in any way   *
 * from a version released by Etienne Gagnon, please write to:             *
 * Etienne Gagnon, 11348 Brunet, Montreal-Nord, Quebec, H1G 5G1, CANADA.   *
 * e-mail: gagnon@sable.mcgill.ca.                                         *
 *                                                                         *
 * To submit a bug, send a comment or get the latest news on SableCC and   *
 * other Sable Research Group projects, please visit the web site:         *
 * http://www.sable.mcgill.ca/                                             *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

Macro:AlternativeHeader
package $0$;

import ca.mcgill.sable.util.*;
import $1$.*;

public final class $2$ extends $3$
{

$

Macro:NodeElement
    private $0$ _$1$_;

$

Macro:ListElement
    private final LinkedList _$1$_ = new TypedLinkedList(new $0$_Cast());

$

Macro:ConstructorHeader

    public $0$(
$

Macro:ConstructorHeaderDeclNode

        $0$ _$1$_$2$
$

Macro:ConstructorHeaderDeclList

        $0$ _$1$_$2$
$

Macro:ConstructorBodyHeader
)
    {

$

Macro:ConstructorBodyNode
        set$0$(_$1$_);


$

Macro:ConstructorBodyList
        {
            Object temp[] = _$0$_.toArray();
            for(int i = 0; i < temp.length; i++)
            {
                this._$0$_.add(temp[i]);
            }
        }


$

Macro:ConstructorBodyQMark
        if(_$2$_ instanceof X1QMark$1$)
        {
            set$0$(((X1QMark$1$) _$2$_).get$1$());
        }
        else
        {
            set$0$(null);
        }


$

Macro:ConstructorBodyStar
        while(_$0$_ instanceof X1Star$1$)
        {
            this._$0$_.add(((X1Star$1$) _$0$_).get$1$());
            _$0$_ = ((X1Star$1$) _$0$_).getXStar$1$();
        }


$

Macro:ConstructorBodyPlus
        if(_$0$_ != null)
        {
            while(_$0$_ instanceof X1$1$)
            {
                this._$0$_.addFirst(((X1$1$) _$0$_).get$1$());
                _$0$_ = ((X1$1$) _$0$_).getX$1$();
            }
            this._$0$_.addFirst(((X2$1$) _$0$_).get$1$());
        }


$

Macro:ConstructorBodyTail
    }

$

Macro:CloneHeader
    public Object clone()
    {
        return new $0$(
$

Macro:CloneBodyNode

            ($0$) cloneNode(_$1$_)$2$
$

Macro:CloneBodyList

            cloneList(_$0$_)$1$
$

Macro:CloneTail
);
    }

$

Macro:Apply

    public void apply(Switch sw)
    {
        ((Analysis) sw).case$0$(this);
    }

$

Macro:GetSetNode

    public $0$ get$1$()
    {
        return _$2$_;
    }

    public void set$1$($0$ node)
    {
        if(_$2$_ != null)
        {
            _$2$_.parent(null);
        }

        if(node != null)
        {
            if(node.parent() != null)
            {
                node.parent().removeChild(node);
            }

            node.parent(this);
        }

        _$2$_ = node;
    }

$

Macro:GetSetList

    public LinkedList get$0$()
    {
        return _$1$_;
    }

    public void set$0$(List list)
    {
        Object temp[] = list.toArray();
        for(int i = 0; i < temp.length; i++)
        {
            _$1$_.add(temp[i]);
        }
    }

$

Macro:ToStringHeader

    public String toString()
    {
        return ""
$

Macro:ToStringBodyNode

            + toString(_$0$_)
$

Macro:ToStringBodyList

            + toString(_$0$_)
$

Macro:ToStringTail
;
    }

$

Macro:RemoveChildHeader

    void removeChild(Node child)
    {

$

Macro:RemoveChildNode
        if(_$0$_ == child)
        {
            _$0$_ = null;
            return;
        }


$

Macro:RemoveChildList
        if(_$0$_.remove(child))
        {
            return;
        }


$

Macro:RemoveChildTail
    }

$

Macro:ReplaceChildHeader

    void replaceChild(Node oldChild, Node newChild)
    {

$

Macro:ReplaceChildNode
        if(_$0$_ == oldChild)
        {
            set$1$(($2$) newChild);
            return;
        }


$

Macro:ReplaceChildList
        for(ListIterator i = _$0$_.listIterator(); i.hasNext();)
        {
            if(i.next() == oldChild)
            {
                if(newChild != null)
                {
                    i.set(newChild);
                    oldChild.parent(null);
                    return;
                }

                i.remove();
                oldChild.parent(null);
                return;
            }
        }


$

Macro:ReplaceChildTail
    }

$

Macro:Cast

    private class $0$_Cast implements Cast
    {
        public Object cast(Object o)
        {
            $1$ node = ($1$) o;

            if((node.parent() != null) &&
                (node.parent() != $2$.this))
            {
                node.parent().removeChild(node);
            }

            if((node.parent() == null) ||
                (node.parent() != $2$.this))
            {
                node.parent($2$.this);
            }

            return node;
        }
    }

$

Macro:AlternativeTail
}

$


