// ** This class was generated with DemFGen (vers:09/27/2009)

package gen;

import edu.neu.ccs.demeterf.lib.*;
import edu.neu.ccs.demeterf.*;
import edu.neu.ccs.demeterf.lib.*;




/** Representation of Num */
public class Num extends Exp{
    protected final int val;

    /** Construct a(n) Num Instance */
    public Num(int val){
        this.val = val;
    }
    /** Is the given object Equal to this Num? */
    public boolean equals(Object o){
        if(!(o instanceof Num))return false;
        if(o == this)return true;
        Num oo = (Num)o;
        return (((Object)val).equals(oo.val));
    }
    /** Parse an instance of Num from the given String */
    public static Num parse(String inpt) throws ParseException{
        return new TheParser(new java.io.StringReader(inpt)).parse_Num();
    }
    /** Parse an instance of Num from the given Stream */
    public static Num parse(java.io.InputStream inpt) throws ParseException{
        return new TheParser(inpt).parse_Num();
    }
    /** Parse an instance of Num from the given Reader */
    public static Num parse(java.io.Reader inpt) throws ParseException{
        return new TheParser(inpt).parse_Num();
    }

    /** Field Class for Num.val */
    public static class val extends edu.neu.ccs.demeterf.control.Fields.any{}

    public int eval(Env ev){ return val; }
    public List<Op> compile(List<ident> env){
        return List.<Op>create(new Push(val));
    }
    public <X> X accept(Vis<X> v){ return v.visit(this); }
    public boolean isNum(){ return true; }
    public Exp simplify(){ return val == 0?new Zero():this; }
    public int maxEnv(){ return 0; }
 
    /** DGP method from Class Print */
    public String print(){ return gen.Print.PrintM(this); }
    /** Getter for field Num.val */
    public int getVal(){ return val; }

}