/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * This file is part of SableCC.                             *
 * See the file "LICENSE" for copyright information and the  *
 * terms and conditions for copying, distribution and        *
 * modification of SableCC.                                  *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

Macro:Start
/* This file was generated by SableCC (http://www.sablecc.org/). */

package $0$;

import $1$.*;

@SuppressWarnings("nls")
public final class Start extends Node
{
    private $2$ _$3$_;
    private EOF _eof_;

    public Start()
    {
        // Empty body
    }

    public Start(
        @SuppressWarnings("hiding") $2$ _$3$_,
        @SuppressWarnings("hiding") EOF _eof_)
    {
        set$2$(_$3$_);
        setEOF(_eof_);
    }

    @Override
    public Object clone()
    {
        return new Start(
            cloneNode(this._$3$_),
            cloneNode(this._eof_));
    }

    @Override
    public void apply(Switch sw)
    {
        ((Analysis) sw).caseStart(this);
    }

    public $2$ get$2$()
    {
        return this._$3$_;
    }

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

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

            node.parent(this);
        }

        this._$3$_ = node;
    }

    public EOF getEOF()
    {
        return this._eof_;
    }

    public void setEOF(EOF node)
    {
        if(this._eof_ != null)
        {
            this._eof_.parent(null);
        }

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

            node.parent(this);
        }

        this._eof_ = node;
    }

    @Override
    void removeChild(Node child)
    {
        if(this._$3$_ == child)
        {
            this._$3$_ = null;
            return;
        }

        if(this._eof_ == child)
        {
            this._eof_ = null;
            return;
        }

        throw new RuntimeException("Not a child.");
    }

    @Override
    void replaceChild(Node oldChild, Node newChild)
    {
        if(this._$3$_ == oldChild)
        {
            set$2$(($2$) newChild);
            return;
        }

        if(this._eof_ == oldChild)
        {
            setEOF((EOF) newChild);
            return;
        }

        throw new RuntimeException("Not a child.");
    }

    @Override
    public String toString()
    {
        return "" +
            toString(this._$3$_) +
            toString(this._eof_);
    }
}

$

Macro:EOF
/* This file was generated by SableCC (http://www.sablecc.org/). */

package $0$;

import $1$.*;

@SuppressWarnings("nls")
public final class EOF extends Token
{
    public EOF()
    {
        setText("");
    }

    public EOF(int line, int pos)
    {
        setText("");
        setLine(line);
        setPos(pos);
    }

    @Override
    public Object clone()
    {
        return new EOF(getLine(), getPos());
    }

    @Override
    public void apply(Switch sw)
    {
        ((Analysis) sw).caseEOF(this);
    }
}

$

Macro:InvalidToken
/* This file was generated by SableCC (http://www.sablecc.org/). */

package $0$;

import $1$.*;

@SuppressWarnings("nls")
public final class InvalidToken extends Token
{
    public InvalidToken(String text)
    {
        setText(text);
    }

    public InvalidToken(String text, int line, int pos)
    {
        setText(text);
        setLine(line);
        setPos(pos);
    }

    @Override
    public Object clone()
    {
        return new InvalidToken(getText(), getLine(), getPos());
    }

    @Override
    public void apply(Switch sw)
    {
        ((Analysis) sw).caseInvalidToken(this);
    }
}

$

Macro:Token
/* This file was generated by SableCC (http://www.sablecc.org/). */

package $0$;

@SuppressWarnings("nls")
public abstract class Token extends Node
{
    private String text;
    private int line;
    private int pos;

    public String getText()
    {
        return this.text;
    }

    public void setText(@SuppressWarnings("hiding") String text)
    {
        this.text = text;
    }

    public int getLine()
    {
        return this.line;
    }

    public void setLine(@SuppressWarnings("hiding") int line)
    {
        this.line = line;
    }

    public int getPos()
    {
        return this.pos;
    }

    public void setPos(@SuppressWarnings("hiding") int pos)
    {
        this.pos = pos;
    }

    @Override
    public String toString()
    {
        return this.text + " ";
    }

    @Override
    void removeChild(@SuppressWarnings("unused") Node child)
    {
        throw new RuntimeException("Not a child.");
    }

    @Override
    void replaceChild(@SuppressWarnings("unused") Node oldChild, @SuppressWarnings("unused") Node newChild)
    {
        throw new RuntimeException("Not a child.");
    }
}

$

Macro:Node
/* This file was generated by SableCC (http://www.sablecc.org/). */

package $0$;

import java.util.*;

@SuppressWarnings("nls")
public abstract class Node implements Switchable, Cloneable
{
    private Node parent;

    @Override
    public abstract Object clone();

    public Node parent()
    {
        return this.parent;
    }

    void parent(@SuppressWarnings("hiding") Node parent)
    {
        this.parent = parent;
    }

    abstract void removeChild(Node child);
    abstract void replaceChild(Node oldChild, Node newChild);

    public void replaceBy(Node node)
    {
        this.parent.replaceChild(this, node);
    }

    protected String toString(Node node)
    {
        if(node != null)
        {
            return node.toString();
        }

        return "";
    }

    protected String toString(List<?> list)
    {
        StringBuffer s = new StringBuffer();

        for(Iterator<?> i = list.iterator(); i.hasNext();)
        {
            s.append(i.next());
        }

        return s.toString();
    }

    @SuppressWarnings("unchecked")
    protected <T extends Node> T cloneNode(T node)
    {
        if(node != null)
        {
            return (T) node.clone();
        }

        return null;
    }

    @SuppressWarnings("unchecked")
    protected <T extends Node> List<T> cloneList(List<T> list)
    {
        List<T> clone = new LinkedList<T>();

        for(T n : list)
        {
            clone.add((T) n.clone());
        }

        return clone;
    }
}

$

Macro:Switch
/* This file was generated by SableCC (http://www.sablecc.org/). */

package $0$;

public interface Switch
{
        // Empty body
}

$

Macro:Switchable
/* This file was generated by SableCC (http://www.sablecc.org/). */

package $0$;

public interface Switchable
{
    void apply(Switch sw);
}

$
