// ** This file was generated with DemFGen (vers:05/23/2010)

package edu.neu.ccs.demeterf.demfgen.classes;

import edu.neu.ccs.demeterf.Fields;
import edu.neu.ccs.demeterf.lib.ident;
import edu.neu.ccs.demeterf.lib.verbatim;
import edu.neu.ccs.demeterf.lib.*;
import edu.neu.ccs.demeterf.lib.*;
import edu.neu.ccs.demeterf.demfgen.*;
import edu.neu.ccs.demeterf.demfgen.dgp.DGPFunc;
import edu.neu.ccs.demeterf.demfgen.traversals.Travs;
import edu.neu.ccs.demeterf.demfgen.pcdgp.PCDGPFunc;
import edu.neu.ccs.demeterf.dispatch.*;
import edu.neu.ccs.demeterf.*;
import edu.neu.ccs.demeterf.demfgen.ClassHier.InhrtPair;
import edu.neu.ccs.demeterf.demfgen.DemFGenMain;
import java.io.*;
import java.io.FileInputStream;
import edu.neu.ccs.demeterf.util.Util;
import edu.neu.ccs.demeterf.util.CLI;



/** Computes a String representation in CD Syntax */
public class Print extends edu.neu.ccs.demeterf.FC{
   /** Static stub method for calling print */
   public static String PrintM(Object o){
      return new edu.neu.ccs.demeterf.Traversal(new Print(),edu.neu.ccs.demeterf.Control.builtins()).<Print._LT>traverse(o).toString();
   }

   public _LT combine(byte _h_){ return empty.append(new _S(""+_h_)); }
   public _LT combine(short _h_){ return empty.append(new _S(""+_h_)); }
   public _LT combine(int _h_){ return empty.append(new _S(""+_h_)); }
   public _LT combine(long _h_){ return empty.append(new _S(""+_h_)); }
   public _LT combine(float _h_){ return empty.append(new _S(""+_h_)); }
   public _LT combine(double _h_){ return empty.append(new _S(""+_h_)); }
   public _LT combine(char _h_){ return empty.append(new _S("\'"+escape(""+_h_)+"\'")); }
   public _LT combine(boolean _h_){ return empty.append(new _S(""+_h_)); }
   public _LT combine(String _h_){ return empty.append(new _S("\""+escape(""+_h_)+"\"")); }
   public _LT combine(ident _h_){ return empty.append(new _S(""+_h_)); }
   public _LT combine(verbatim _h_){ return empty.append(new _S(""+_h_)); }

   static _LT empty = new _LT();
   public  static class _LT{
     edu.neu.ccs.demeterf.lib.List<_T> l;
     public _LT(){ l = new edu.neu.ccs.demeterf.lib.Empty<_T>(); }
     public _LT(edu.neu.ccs.demeterf.lib.List<_T> ll){ l = ll; }
     public _LT push(_T t){ return new _LT(l.push(t)); }
     public _LT append(_T t){ return new _LT(l.append(t)); }
     public _LT append(_LT t){ return new _LT(l.append(t.l)); }
     public String toString(){ return l.fold(new _F(),""); }
     public _LT compress(){ return l.isEmpty()?this:compress(new _E(), l); }
     public static _LT compress(_S s, edu.neu.ccs.demeterf.lib.List<_T> r){
        if(r.isEmpty())return (s.isE())?empty:empty.push(s);
          _T top = r.top();
          if(top.isS())return compress(s.append((_S)top), r.pop());
          if(s.isE())return compress(s, r.pop()).push(top);
          return compress(new _E(), r.pop()).push(top).push(s);
     }
   }
   public static class _T{
     public boolean isS(){ return false; }
     public boolean isE(){ return false; }
   }
   public static class _P extends _T{ public static _P p = new _P(); }
   public static class _M extends _T{ public static _M m = new _M(); }
   public static class _N extends _T{ public static _N n = new _N(); }
   public static class _R extends _T{ public static _R r = new _R(); }
   public static class _S extends _T{
     public StringBuffer s;
     public _S(String ss){ s = new StringBuffer(ss); }
     public _S append(_S ss){ s.append(ss.s); return this; }
     public  boolean isS(){ return true; }
   }
   public static class _E extends _S{
     public _E(){ super("");}
     public  boolean isS(){ return true; }
   }
   public static class _F extends edu.neu.ccs.demeterf.lib.List.Fold<_T,String>{
     int idt = 0;
     public  String fold(_T t, String s){
        if(t == _P.p)plus();
        else if(t == _M.m)minus();
        else if(t == _R.r)s += "\r";
        else if(t == _N.n)s += "\n"+indent();
        else s += ((_S)t).s;
        return s;
     }
     void plus(){ idt++; }
     void minus(){ idt--; }
     String indent(){ return indent(idt); }
     static String indent(int i){ return (i <= 0)?"":"   "+indent(i-1); }
   }
   public static String escape(String s){
      char str[] = s.toCharArray();
      StringBuffer ret = new StringBuffer("");
      for(char c:str)ret.append(escape(c));
      return ret.toString();
   }
   public static String escape(char c){
      switch(c){
      case '\n':return "\\n";  case '\t':return "\\t";
      case '\b':return "\\b";  case '\r':return "\\r";
      case '\f':return "\\f";  case '\\':return "\\\\";
      case '\'':return "\\'"; case '\"':return "\\\"";
      default: return ""+c;
      }
   }
   public _LT combine(CDFile _h_, _LT incl, _LT dgpuse, _LT pkg, _LT look, _LT imports, _LT types){
      return empty.append(incl).append(dgpuse).append(pkg).append(look).append(imports).append(types).compress();
   }
   public _LT combine(Include _h_, _LT gen, _LT file){
      return empty.append(gen).append(new _S("include")).append(new _S(" ")).append(file).append(new _S(";")).compress();
   }
   public _LT combine(IncludeCons _h_, _LT first, _LT rest){
      return empty.append(first).append(_N.n).append(rest).compress();
   }
   public _LT combine(IncludeEmpty _h_){
      return empty.append(_N.n).compress();
   }
   public _LT combine(DGPUse _h_, _LT pkg){
      return empty.append(new _S("using")).append(new _S(" ")).append(pkg).append(new _S(";")).append(_N.n).compress();
   }
   public _LT combine(NoDGPUse _h_){
      return empty;
   }
   public _LT combine(Package _h_, _LT pkg){
      return empty.append(new _S("package")).append(new _S(" ")).append(pkg).append(new _S(";")).append(_N.n).compress();
   }
   public _LT combine(NoPackage _h_){
      return empty;
   }
   public _LT combine(LookAhead _h_, _LT n){
      return empty.append(new _S("lookahead")).append(new _S(" ")).append(new _S("=")).append(new _S(" ")).append(n).append(new _S(";")).append(_N.n).compress();
   }
   public _LT combine(NoLook _h_){
      return empty;
   }
   public _LT combine(Import _h_, _LT pkg){
      return empty.append(new _S("import")).append(new _S(" ")).append(pkg).append(new _S(";")).compress();
   }
   public _LT combine(NEPkgList _h_, _LT id, _LT rest){
      return empty.append(id).append(rest).compress();
   }
   public _LT combine(PkgCons _h_, _LT id, _LT rest){
      return empty.append(new _S(".")).append(id).append(rest).compress();
   }
   public _LT combine(PkgStar _h_){
      return empty.append(new _S(".*")).compress();
   }
   public _LT combine(PkgEmpty _h_){
      return empty;
   }
   public _LT combine(ImportCons _h_, _LT first, _LT rest){
      return empty.append(first).append(_N.n).append(rest).compress();
   }
   public _LT combine(ImportEmpty _h_){
      return empty;
   }
   public _LT combine(IntfcDef _h_, _LT gen, _LT name, _LT tparams, _LT subtypes){
      return empty.append(new _S("    ")).append(gen).append(new _S("interface")).append(new _S(" ")).append(name).append(tparams).append(new _S(" ")).append(new _S("=")).append(new _S(" ")).append(subtypes).append(new _S(".")).compress();
   }
   public _LT combine(ClassDef _h_, _LT gen, _LT name, _LT tparams, _LT subtypes, _LT fields, _LT ext){
      return empty.append(new _S("    ")).append(gen).append(name).append(tparams).append(new _S(" ")).append(new _S("=")).append(new _S(" ")).append(subtypes).append(new _S(" ")).append(fields).append(new _S(" ")).append(ext).append(new _S(".")).compress();
   }
   public _LT combine(NoGen _h_){
      return empty.append(new _S("nogen")).append(new _S(" ")).compress();
   }
   public _LT combine(NoParse _h_){
      return empty.append(new _S("noparse")).append(new _S(" ")).compress();
   }
   public _LT combine(Extern _h_){
      return empty.append(new _S("extern")).append(new _S(" ")).compress();
   }
   public _LT combine(YesGen _h_){
      return empty;
   }
   public _LT combine(DefParams _h_, _LT types){
      return empty.append(new _S("(")).append(types).append(new _S(")")).compress();
   }
   public _LT combine(EmptyDefParams _h_){
      return empty;
   }
   public _LT combine(NameDef _h_, _LT id, _LT bnd){
      return empty.append(id).append(bnd).compress();
   }
   public _LT combine(ClassBound _h_, _LT bound){
      return empty.append(new _S(":")).append(bound).compress();
   }
   public _LT combine(NoBound _h_){
      return empty;
   }
   public _LT combine(NoImpl _h_){
      return empty;
   }
   public _LT combine(IntfImpl _h_, _LT intf){
      return empty.append(new _S("implements")).append(new _S(" ")).append(intf).compress();
   }
   public _LT combine(NENameList _h_, _LT first, _LT rest){
      return empty.append(first).append(rest).compress();
   }
   public _LT combine(NameCons _h_, _LT first, _LT rest){
      return empty.append(new _S(",")).append(new _S(" ")).append(first).append(rest).compress();
   }
   public _LT combine(NameEmpty _h_){
      return empty;
   }
   public _LT combine(TypeUse _h_, _LT name, _LT tparams){
      return empty.append(name).append(tparams).compress();
   }
   public _LT combine(UseParams _h_, _LT types){
      return empty.append(new _S("(")).append(types).append(new _S(")")).compress();
   }
   public _LT combine(EmptyUseParams _h_){
      return empty;
   }
   public _LT combine(NETypeUseList _h_, _LT first, _LT rest){
      return empty.append(first).append(rest).compress();
   }
   public _LT combine(TypeUseCons _h_, _LT first, _LT rest){
      return empty.append(new _S(",")).append(new _S(" ")).append(first).append(rest).compress();
   }
   public _LT combine(TypeUseEmpty _h_){
      return empty;
   }
   public _LT combine(Field _h_, _LT name, _LT type){
      return empty.append(new _S("<")).append(name).append(new _S(">")).append(new _S(" ")).append(type).compress();
   }
   public _LT combine(AddSpace _h_){
      return empty.append(new _S("*s")).compress();
   }
   public _LT combine(AddTab _h_){
      return empty.append(new _S("*t")).compress();
   }
   public _LT combine(AddLine _h_){
      return empty.append(new _S("*l")).compress();
   }
   public _LT combine(AddReturn _h_){
      return empty.append(new _S("*r")).compress();
   }
   public _LT combine(Plus _h_){
      return empty.append(new _S("+")).compress();
   }
   public _LT combine(Minus _h_){
      return empty.append(new _S("-")).compress();
   }
   public _LT combine(AddToken _h_, _LT str){
      return empty.append(str).compress();
   }
   public _LT combine(TheEOF _h_){
      return empty.append(new _S("EOF")).compress();
   }
   public _LT combine(RealToken _h_, _LT str){
      return empty.append(str).compress();
   }
   public _LT combine(EmptyToken _h_){
      return empty;
   }
   public _LT combine(TypeDefCons _h_, _LT first, _LT rest){
      return empty.append(first).append(_N.n).append(rest).compress();
   }
   public _LT combine(TypeDefEmpty _h_){
      return empty;
   }
   public _LT combine(FieldCons _h_, _LT first, _LT rest){
      return empty.append(first).append(new _S(" ")).append(rest).compress();
   }
   public _LT combine(FieldEmpty _h_){
      return empty;
   }
   public _LT combine(NESubtypeList _h_, _LT first, _LT rest){
      return empty.append(first).append(rest).compress();
   }
   public _LT combine(SubtypeCons _h_, _LT first, _LT rest){
      return empty.append(new _S(" ")).append(new _S("|")).append(new _S(" ")).append(first).append(rest).compress();
   }
   public _LT combine(SubtypeEmpty _h_){
      return empty;
   }
   public _LT combine(BehFile _h_, _LT incl, _LT behs){
      return empty.append(incl).append(_N.n).append(behs).append(_N.n).compress();
   }
   public _LT combine(BehDefCons _h_, _LT first, _LT rest){
      return empty.append(first).append(_N.n).append(rest).compress();
   }
   public _LT combine(BehDefEmpty _h_){
      return empty;
   }
   public _LT combine(BehDef _h_, _LT name, _LT body){
      return empty.append(name).append(body).compress();
   }
   public _LT combine(TE _h_){
      return empty;
   }
   public _LT combine(RTParseException _h_){
      return empty;
   }
   public _LT combine(RTFileNotFound _h_){
      return empty;
   }
   public _LT combine(DummyDGP _h_, _LT behavior){
      return empty.append(behavior).compress();
   }
   public _LT combine(DummyTrav _h_, _LT dfgl, _LT tdl, _LT dgpl, _LT otdl, _LT flds){
      return empty.append(dfgl).append(tdl).append(dgpl).append(otdl).append(flds).compress();
   }
   public _LT combine(RED _h_){
      return empty.append(new _S("red")).compress();
   }
   public _LT combine(BLACK _h_){
      return empty.append(new _S("black")).compress();
   }

   public _LT combine(Empty _h_){
      return empty;
   }
   public _LT combine(Cons _h_, _LT first, _LT rest){
      return empty.append(first).append(new _S(" ")).append(rest).compress();
   }
   public _LT combine(None _h_){
      return empty;
   }
   public _LT combine(Some _h_, _LT just){
      return empty.append(just).compress();
   }


}