/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * 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:AnalysisHeader
package $0$;

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

public interface Analysis extends Switch
{
    Object getIn(Node node);
    void setIn(Node node, Object in);
    Object getOut(Node node);
    void setOut(Node node, Object out);


$
Macro:AnalysisStart
    void caseStart(Start node);

$

Macro:AnalysisBody
    void case$0$($0$ node);

$

Macro:AnalysisTail
    void caseEOF(EOF node);
}

$

Macro:AnalysisAdapterHeader
package $0$;

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

public class AnalysisAdapter implements Analysis
{
    private Hashtable in;
    private Hashtable out;

    public Object getIn(Node node)
    {
        if(in == null)
        {
            return null;
        }

        return in.get(node);
    }

    public void setIn(Node node, Object in)
    {
        if(this.in == null)
        {
            this.in = new Hashtable(1);
        }

        if(in != null)
        {
            this.in.put(node, in);
        }
        else
        {
            this.in.remove(node);
        }
    }

    public Object getOut(Node node)
    {
        if(out == null)
        {
            return null;
        }

        return out.get(node);
    }

    public void setOut(Node node, Object out)
    {
        if(this.out == null)
        {
            this.out = new Hashtable(1);
        }

        if(out != null)
        {
            this.out.put(node, out);
        }
        else
        {
            this.out.remove(node);
        }
    }

$

Macro:AnalysisAdapterStart
    public void caseStart(Start node)
    {
        defaultCase(node);
    }

$

Macro:AnalysisAdapterBody

    public void case$0$($0$ node)
    {
        defaultCase(node);
    }

$

Macro:AnalysisAdapterTail

    public void caseEOF(EOF node)
    {
        defaultCase(node);
    }

    public void defaultCase(Node node)
    {
    }
}

$

Macro:DepthFirstAdapterHeader
package $0$;

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

public class DepthFirstAdapter extends AnalysisAdapter
{
    public void inStart(Start node)
    {
    }

    public void outStart(Start node)
    {
    }

    public void caseStart(Start node)
    {
        inStart(node);
        node.get$2$().apply(this);
        node.getEOF().apply(this);
        outStart(node);
    }

$

Macro:ReversedDepthFirstAdapterHeader
package $0$;

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

public class ReversedDepthFirstAdapter extends AnalysisAdapter
{
    public void inStart(Start node)
    {
    }

    public void outStart(Start node)
    {
    }

    public void caseStart(Start node)
    {
        inStart(node);
        node.getEOF().apply(this);
        node.get$2$().apply(this);
        outStart(node);
    }

$

Macro:DepthFirstAdapterInOut

    public void in$0$($0$ node)
    {
    }

    public void out$0$($0$ node)
    {
    }

$

Macro:DepthFirstAdapterCaseHeader

    public void case$0$($0$ node)
    {
        in$0$(node);

$

Macro:DepthFirstAdapterCaseBodyNode
        if(node.get$0$() != null)
        {
            node.get$0$().apply(this);
        }

$

Macro:DepthFirstAdapterCaseBodyList
        {
            Object temp[] = node.get$0$().toArray();
            for(int i = 0; i < temp.length; i++)
            {
                (($1$) temp[i]).apply(this);
            }
        }

$

Macro:ReversedDepthFirstAdapterCaseBodyList
        {
            Object temp[] = node.get$0$().toArray();
            for(int i = temp.length - 1; i >= 0; i--)
            {
                (($1$) temp[i]).apply(this);
            }
        }

$

Macro:DepthFirstAdapterCaseTail
        out$0$(node);
    }

$

Macro:DepthFirstAdapterTail
}

$

