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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2395 - (view) (download)
Original Path: branches/charisee/src/compiler/ein/printer.sml

1 : cchiw 2383
2 : cchiw 2387 (*printer Function returns String*)
3 : cchiw 2383 structure Printer = struct
4 :    
5 :     local
6 : jhr 2391 structure G = GenericEin
7 :     structure E = Ein
8 :     structure S = Specialize
9 : cchiw 2395 (* structure R = Rewrite*)
10 : jhr 2391 in
11 : cchiw 2383
12 : jhr 2391 fun intList l = String.concatWith "," (List.map Int.toString l)
13 :    
14 :     fun printerE (Ein.EIN{params, index, body}) = let
15 :     fun printer2 term = (case term
16 : cchiw 2394 of E.Tensor(id, []) => String.concat[" S",Int.toString(id)]
17 :     | E.Tensor(id, mx) => String.concat[" T",Int.toString(id), "_",intList(mx)]
18 :     | E.Const e => Real.toString(e)
19 :     | E.Field(id, mx) => String.concat ["F",Int.toString(id),"_",intList(mx)]
20 :     | E.Add e => String.concatWith "+" (List.map printer2 e)
21 :     | E.Sub(a,b) => String.concat ["(",printer2(a),"- ",printer2(b), ")"]
22 :     | E.Div(a,b) => String.concat ["(",printer2(a),"/ ",printer2(b), ")"]
23 :     | E.Prod e => String.concatWith "*" (List.map printer2 e)
24 :     | E.Delta(i,j) => String.concat [" Delta_",Int.toString(i),Int.toString(j)]
25 :     | E.Epsilon(i,j,k)=> String.concat ["E_",Int.toString(i),Int.toString(j),Int.toString(k) ]
26 :     | E.Conv(v,deltas,k,n) => let
27 : jhr 2391 fun imp([])=""
28 : cchiw 2394 | imp([(i,j)])= String.concat [" Delta_",Int.toString(i),Int.toString(j)]
29 :     | imp((i,j)::es)= String.concat[" Delta_",Int.toString(i),Int.toString(j)," ",imp(es)]
30 :     in
31 :     String.concat [v,"*",k,"{",imp(deltas),"}_",Int.toString(n)]
32 :     end
33 :     | E.Partial e => String.concat ["d",Int.toString(length(e)),"/dx_",intList(e)]
34 :     | E.Probe(a,b) => String.concat ["(",printer2(a), ")","@","T",Int.toString(b)]
35 :     | E.Apply(a,b) => String.concat [ printer2(a)," ", printer2(b)," "]
36 :     | E.Sum (id,a) => String.concat [" Sigma:", Int.toString(id), printer2(a)]
37 : jhr 2391 | _ =>("newbie")
38 : cchiw 2394 (* end case *))
39 :     fun Index ((E.IX(dim))::i, count) = String.concat["(", Int.toString count,
40 :     " DIM:", Int.toString dim, ")", Index(i,count+1)]
41 :     | Index ((E.SX(dim))::i, count) = String.concat[ "} {Summation:(",Int.toString(count),
42 :     " DIM:",Int.toString(dim),")", Index(i,count+1)]
43 : jhr 2391 | Index (_, count) = ""
44 : cchiw 2383 in
45 : cchiw 2394 String.concat ["\n<",printer2(body),">","_{",Index(index,0),"}"]
46 : cchiw 2387 end
47 : cchiw 2383
48 : cchiw 2395 (* fun printerApp(R.App(e,l))= printerE(e)
49 :     | printerApp(_)= ""*)
50 : cchiw 2394
51 : jhr 2391 end (* local *)
52 :     end

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