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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2407, Wed Jul 31 04:52:25 2013 UTC revision 2424, Mon Sep 16 14:57:35 2013 UTC
# Line 13  Line 13 
13    
14      fun printerE (Ein.EIN{params, index, body}) = let      fun printerE (Ein.EIN{params, index, body}) = let
15            fun printer2 term = (case term            fun printer2 term = (case term
16                   of E.Tensor(id, [])  => String.concat[" S",Int.toString(id)]                   of E.Value(id)=> String.concat[" CI-",Int.toString(id)]
17                    | E.Tensor(id, mx) =>  String.concat[" T",Int.toString(id),intList(mx)]  
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                    | E.Const e => Real.toString(e)                    | E.Const e => Real.toString(e)
23                    | E.Field(id, []) => String.concat ["F",Int.toString(id)]                    | E.Field(id, [],[]) => String.concat ["F",Int.toString(id)]
24                    | E.Field(id, mx) => String.concat ["F",Int.toString(id),"_",intList(mx)]                    | E.Field(id, mx,[]) => String.concat ["F",Int.toString(id),"_",intList(mx)]
25                    | E.Add e        => String.concatWith "+" (List.map printer2 e)                    | 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                      | E.Add e        => String.concat["(",String.concatWith "+" (List.map printer2 e),")"]
29                    | E.Sub(a,b)      => String.concat ["(",printer2(a),"- ",printer2(b), ")"]                    | E.Sub(a,b)      => String.concat ["(",printer2(a),"- ",printer2(b), ")"]
30                    | E.Div(a,b)      => String.concat ["(",printer2(a),"/ ",printer2(b), ")"]                    | E.Div(a,b)      => String.concat ["(",printer2(a),"/ ",printer2(b), ")"]
31                    | E.Prod e       => String.concatWith "*" (List.map printer2 e)                    | E.Prod [e1,e2,e3]       => String.concatWith "*" (List.map printer2 [e1,e2,e3])
32                      | E.Prod e       => String.concatWith "^^" (List.map printer2 e)
33                    | E.Delta(i,j)    => String.concat [" Delta_",Int.toString(i),Int.toString(j)]                    | 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) ]                    | E.Epsilon(i,j,k)=> String.concat ["E_",Int.toString(i),Int.toString(j),Int.toString(k) ]
35                    | E.Conv(v,deltas,k,n) => let                    | E.Conv(k,deltas) => let
36                          val n= length(deltas)
37                        fun imp([])=""                        fun imp([])=""
38                        | imp([(i,j)])=  String.concat [" Delta_",Int.toString(i),Int.toString(j)]                        | 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)]                        | imp((i,j)::es)= String.concat[" Delta_",Int.toString(i),Int.toString(j)," ",imp(es)]
40                        in                        in
41                          String.concat [v,"*",k,"{",imp(deltas),"}_",Int.toString(n)]                          String.concat ["V (*)",printer2(k),"{",imp(deltas),"}_",Int.toString(n)]
42                        end                        end
43                    | E.Partial e  => String.concat ["d^",Int.toString(length(e)),"/dx_",intList(e)]                    | E.Partial e  => String.concat ["d^",Int.toString(length(e)),"/dx_",intList(e)]
44                    | E.Probe(a,b) => String.concat ["(",printer2(a), ")","@","T",Int.toString(b)]                    | E.Probe(a,b) => String.concat ["",printer2(a), "","@", printer2(b)]
45                    | E.Apply(a,b) => String.concat [ printer2(a)," ", printer2(b)," "]                    | E.Apply(a,b) => String.concat [ printer2(a)," ", printer2(b)," "]
46                    | E.Sum (id,a) => String.concat [" Sigma:", Int.toString(id), " ",printer2(a)]                    | E.Sum (id,a) => String.concat [" Sigma:", Int.toString(id), " ",printer2(a)]
47                    | _ =>("newbie")                    | _ =>("newbie")
48                  (* end case *))                  (* end case *))
49            fun Index ((E.IX(dim))::i, count) = String.concat["(", Int.toString count,            fun Index ((E.IX(dim))::i, count) = String.concat["(", Int.toString count,
50                  " DIM:", Int.toString dim, ")", Index(i,count+1)]                  " DIM:", Int.toString dim, ")", Index(i,count+1)]
51              | Index ((E.SX(dim))::i, count) = String.concat[ "} {Summation:(",Int.toString(count),              | Index ((E.SX(lb,ub))::i, count) = String.concat[ "} {Summation:(",Int.toString(count),
52                  " DIM:",Int.toString(dim),")", Index(i,count+1)]                  " DIM:",Int.toString(lb),",", Int.toString(ub),")", Index(i,count+1)]
53              | Index (_, count) = ""              | Index (_, count) = ""
54            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    
58            val str=String.concat [Param(params, 0)," \n<",printer2(body),">","\n _{",Index(index,0),"} \n "]
59              in              in
60                  String.concat ["\n<",printer2(body),">","_{",Index(index,0),"}"]              print str
61              end              end
62    
63         (* fun printerApp(R.App(e,l))= printerE(e)         (* fun printerApp(R.App(e,l))= printerE(e)

Legend:
Removed from v.2407  
changed lines
  Added in v.2424

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