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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2424 - (view) (download)

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 : cchiw 2407 fun intList l = String.concat[String.concatWith "," (List.map Int.toString l)]
13 : jhr 2391
14 :     fun printerE (Ein.EIN{params, index, body}) = let
15 :     fun printer2 term = (case term
16 : cchiw 2424 of E.Value(id)=> String.concat[" CI-",Int.toString(id)]
17 :    
18 :     | E.Tensor(id, E.c mx) => String.concat[" T",Int.toString(id),"_",Int.toString(mx)]
19 :     | E.Tensor(id, E.m []) => String.concat[" S",Int.toString(id)]
20 :     | E.Tensor(id, E.m mx) => String.concat[" T",Int.toString(id),"_",intList(mx)]
21 :     | E.Pair e => String.concat["(",String.concatWith "," (List.map printer2 e),")"]
22 : cchiw 2394 | E.Const e => Real.toString(e)
23 : cchiw 2424 | E.Field(id, [],[]) => String.concat ["F",Int.toString(id)]
24 :     | E.Field(id, mx,[]) => String.concat ["F",Int.toString(id),"_",intList(mx)]
25 :     | E.Field(id, [],dx) => String.concat ["F,",Int.toString(id),",",intList(dx)]
26 :     | E.Field(id, mx,dx) => String.concat ["F",Int.toString(id),"_",intList(mx),",",intList(dx)]
27 :    
28 : cchiw 2409 | E.Add e => String.concat["(",String.concatWith "+" (List.map printer2 e),")"]
29 : cchiw 2424 | E.Sub(a,b) => String.concat ["(",printer2(a),"-",printer2(b), ")"]
30 : cchiw 2394 | E.Div(a,b) => String.concat ["(",printer2(a),"/ ",printer2(b), ")"]
31 : cchiw 2424 | E.Prod [e1,e2,e3] => String.concatWith "*" (List.map printer2 [e1,e2,e3])
32 :     | E.Prod e => String.concatWith "^^" (List.map printer2 e)
33 : cchiw 2394 | E.Delta(i,j) => String.concat [" Delta_",Int.toString(i),Int.toString(j)]
34 :     | E.Epsilon(i,j,k)=> String.concat ["E_",Int.toString(i),Int.toString(j),Int.toString(k) ]
35 : cchiw 2414 | E.Conv(k,deltas) => let
36 :     val n= length(deltas)
37 : jhr 2391 fun imp([])=""
38 : cchiw 2394 | imp([(i,j)])= String.concat [" Delta_",Int.toString(i),Int.toString(j)]
39 :     | imp((i,j)::es)= String.concat[" Delta_",Int.toString(i),Int.toString(j)," ",imp(es)]
40 :     in
41 : cchiw 2414 String.concat ["V (*)",printer2(k),"{",imp(deltas),"}_",Int.toString(n)]
42 : cchiw 2394 end
43 : cchiw 2407 | E.Partial e => String.concat ["d^",Int.toString(length(e)),"/dx_",intList(e)]
44 : cchiw 2424 | E.Probe(a,b) => String.concat ["",printer2(a), "","@", printer2(b)]
45 : cchiw 2394 | E.Apply(a,b) => String.concat [ printer2(a)," ", printer2(b)," "]
46 : cchiw 2399 | E.Sum (id,a) => String.concat [" Sigma:", Int.toString(id), " ",printer2(a)]
47 : jhr 2391 | _ =>("newbie")
48 : cchiw 2394 (* end case *))
49 :     fun Index ((E.IX(dim))::i, count) = String.concat["(", Int.toString count,
50 :     " DIM:", Int.toString dim, ")", Index(i,count+1)]
51 : cchiw 2424 | Index ((E.SX(lb,ub))::i, count) = String.concat[ "} {Summation:(",Int.toString(count),
52 :     " DIM:",Int.toString(lb),",", Int.toString(ub),")", Index(i,count+1)]
53 : jhr 2391 | Index (_, count) = ""
54 : cchiw 2412 fun Param(E.TEN::param, i)=String.concat[Int.toString(i), ":TEN ", Param(param, i+1)]
55 :     | Param(E.FLD(d)::param, i)= String.concat[Int.toString(i), ":FLD-", intList d," ",Param(param, i+1)]
56 :     | Param(_,_)=""
57 : cchiw 2424
58 :     val str=String.concat [Param(params, 0)," \n<",printer2(body),">","\n _{",Index(index,0),"} \n "]
59 :     in
60 :     print str
61 :     end
62 : cchiw 2383
63 : cchiw 2395 (* fun printerApp(R.App(e,l))= printerE(e)
64 :     | printerApp(_)= ""*)
65 : cchiw 2394
66 : jhr 2391 end (* local *)
67 :     end

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