Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] View of /branches/charisee_dev/src/compiler/ein/printer.sml
ViewVC logotype

View of /branches/charisee_dev/src/compiler/ein/printer.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2399 - (download) (annotate)
Sun Jul 7 02:22:44 2013 UTC (6 years, 2 months ago) by cchiw
Original Path: branches/charisee/src/compiler/ein/printer.sml
File size: 2716 byte(s)
Tester
(*printer Function returns String*)
structure Printer = struct

    local
      structure G = GenericEin
      structure E = Ein
      structure S = Specialize
     (* structure R = Rewrite*)
    in 

    fun intList l = String.concatWith "," (List.map Int.toString l)
	
    fun printerE (Ein.EIN{params, index, body}) = let            
          fun printer2 term = (case term
                 of E.Tensor(id, [])  => String.concat[" S",Int.toString(id)]
                  | E.Tensor(id, mx) =>  String.concat[" T",Int.toString(id), "_",intList(mx)]
                  | E.Const e => Real.toString(e)
                  | E.Field(id, mx) => String.concat ["F",Int.toString(id),"_",intList(mx)]
                  | E.Add e        => String.concatWith "+" (List.map printer2 e)
                  | E.Sub(a,b)      => String.concat ["(",printer2(a),"- ",printer2(b), ")"]
                  | E.Div(a,b)      => String.concat ["(",printer2(a),"/ ",printer2(b), ")"]
                  | E.Prod e       => String.concatWith "*" (List.map printer2 e)
                  | E.Delta(i,j)    => String.concat [" Delta_",Int.toString(i),Int.toString(j)]
                  | E.Epsilon(i,j,k)=> String.concat ["E_",Int.toString(i),Int.toString(j),Int.toString(k) ]
                  | E.Conv(v,deltas,k,n) => let
                      fun imp([])=""
                      | imp([(i,j)])=  String.concat [" Delta_",Int.toString(i),Int.toString(j)]
                      | imp((i,j)::es)= String.concat[" Delta_",Int.toString(i),Int.toString(j)," ",imp(es)]
                      in
                        String.concat [v,"*",k,"{",imp(deltas),"}_",Int.toString(n)]
                      end
                  | E.Partial e  => String.concat ["d",Int.toString(length(e)),"/dx_",intList(e)]
                  | E.Probe(a,b) => String.concat ["(",printer2(a), ")","@","T",Int.toString(b)]
                  | E.Apply(a,b) => String.concat [ printer2(a)," ", printer2(b)," "]
                  | E.Sum (id,a) => String.concat [" Sigma:", Int.toString(id), " ",printer2(a)]
                  | _ =>("newbie")
                (* end case *))
          fun Index ((E.IX(dim))::i, count) = String.concat["(", Int.toString count,
                " DIM:", Int.toString dim, ")", Index(i,count+1)]
            | Index ((E.SX(dim))::i, count) = String.concat[ "} {Summation:(",Int.toString(count),
                " DIM:",Int.toString(dim),")", Index(i,count+1)]
            | Index (_, count) = ""
            in
                String.concat ["\n<",printer2(body),">","_{",Index(index,0),"}"]
            end

       (* fun printerApp(R.App(e,l))= printerE(e)
            | printerApp(_)= ""*)
                    
    end (* local *)
  end

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0