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

package gen;

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




/** Representation of OpCons */
public class OpCons extends OpList{
    protected final Op first;
    protected final OpList rest;

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

    /** Field Class for OpCons.first */
    public static class first extends edu.neu.ccs.demeterf.control.Fields.any{}
    /** Field Class for OpCons.rest */
    public static class rest extends edu.neu.ccs.demeterf.control.Fields.any{}

  public OpList append(Op o){ return new OpCons(first, rest.append(o)); }
  public OpList append(OpList ol){ return new OpCons(first, rest.append(ol)); }
  public ExecStack eval(ExecStack s){ return first.eval(s,rest); }
  List<CodeEntry> labels(List<CodeEntry> e){
    return rest.labels((first instanceof Label)?
           e.push(new CodeEntry(((Label)first).id.toString(),rest)):e);
  }

    /** DGP method from Class Print */
    public String print(){ return gen.Print.PrintM(this); }
    /** Getter for field OpCons.rest */
    public OpList getRest(){ return rest; }
    /** Getter for field OpCons.first */
    public Op getFirst(){ return first; }

}