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 2426, Mon Sep 16 20:16:19 2013 UTC revision 2427, Wed Sep 18 15:20:54 2013 UTC
# Line 12  Line 12 
12      fun intList l = String.concat[String.concatWith "," (List.map Int.toString l)]      fun intList l = String.concat[String.concatWith "," (List.map Int.toString l)]
13    
14      fun printIndex e= (case e      fun printIndex e= (case e
15          of E.c(cx)=> String.concat["c-",Int.toString(cx)]          of E.C(cx)=> String.concat["c{",intList(cx),"}"]
16          |  E.m([ix])=> Int.toString(ix)          |  E.V([ix])=> Int.toString(ix)
17          |  E.m(mx)=> intList(mx)          |  E.V(mx)=> intList(mx)
18      )      )
19      fun imp([])=""      fun imp([])=""
20      | imp([(i,j)])=  String.concat [" Delta_",printIndex(i),printIndex(j)]      | imp([(i,j)])=  String.concat [" Delta_",printIndex(i),printIndex(j)]
# Line 24  Line 24 
24      fun printerE (Ein.EIN{params, index, body}) = let      fun printerE (Ein.EIN{params, index, body}) = let
25            fun printer2 term = (case term            fun printer2 term = (case term
26                   of E.Value(id)=> String.concat[" CI-",Int.toString(id)]                   of E.Value(id)=> String.concat[" CI-",Int.toString(id)]
27                    | E.Tensor(id, E.m([])) =>String.concat[" S",Int.toString(id)]                    | E.Tensor(id, E.V([])) =>String.concat[" S",Int.toString(id)]
28                    | E.Tensor(id, ix) =>String.concat[" T",Int.toString(id),"_",printIndex ix]                    | E.Tensor(id, ix) =>String.concat[" T",Int.toString(id),"_",printIndex ix]
29                    | E.Pair e => String.concat["(",String.concatWith "," (List.map printer2 e),")"]                    | E.Pair e => String.concat["(",String.concatWith "," (List.map printer2 e),")"]
30                    | E.Const e => Real.toString(e)                    | E.Const e => Real.toString(e)
31                    | E.Field(id, E.m [],E.m []) => String.concat ["F",Int.toString(id)]                    | E.Field(id, E.V [],E.V []) => String.concat ["F",Int.toString(id)]
32                    | E.Field(id, mx,dx) => String.concat ["F",Int.toString(id),"_",printIndex(mx),",",printIndex(dx)]                    | E.Field(id, mx,dx) => String.concat ["F",Int.toString(id),"_",printIndex(mx),",",printIndex(dx)]
33    
34                    | E.Add e        => String.concat["(",String.concatWith "+" (List.map printer2 e),")"]                    | E.Add e        => String.concat["(",String.concatWith "+" (List.map printer2 e),")"]
# Line 36  Line 36 
36                    | E.Div(a,b)      => String.concat ["(",printer2(a),"/ ",printer2(b), ")"]                    | E.Div(a,b)      => String.concat ["(",printer2(a),"/ ",printer2(b), ")"]
37                    | E.Prod [e1,e2,e3]       => String.concatWith "*" (List.map printer2 [e1,e2,e3])                    | E.Prod [e1,e2,e3]       => String.concatWith "*" (List.map printer2 [e1,e2,e3])
38                    | E.Prod e       => String.concatWith "^^" (List.map printer2 e)                    | E.Prod e       => String.concatWith "^^" (List.map printer2 e)
39                    | E.Delta(dels)  => imp(dels)                    | E.Kernel [] =>  "h"
40                      | E.Kernel dels=> String.concat["h^",imp(dels)]
41                      | E.Delta dels  => imp(dels)
42                    | 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) ]
43                    | E.Conv(k,[]) => String.concat ["V (*)",printer2(k)]                    | E.Conv(k,[]) => String.concat ["V (*)",printer2(k)]
44                    | E.Conv(k,[E.Delta(dels)]) => let                    | E.Conv(k,[E.V(mx)]) =>let
45                         val n= length(dels)                          val n= length(mx)
46                            val ind= intList(mx)
47                      in                      in
48                          String.concat ["V (*)",printer2(k),"^",Int.toString(n),"{",imp(dels),"}"]                              String.concat ["V (*)",printer2(k),"^",Int.toString(n),"{",ind,"}"]
49                      end                      end
50                    | E.Conv(k,_) => "Incorrect convolution argument"                    | E.Conv(k,_) => "Incorrect convolution argument"
51                    | E.Partial(E.c(ix)) => String.concat ["d^1","/dx_",Int.toString(ix)]                    | E.Partial(E.C(ix)) => String.concat ["d^1","/dx_",intList(ix)]
52                    | E.Partial(E.m(mx))  => String.concat ["d^",Int.toString(length(mx)),"/dx_",intList(mx)]                    | E.Partial(E.V(mx))  => String.concat ["d^",Int.toString(length(mx)),"/dx_",intList(mx)]
53                    | E.Probe(a,b) => String.concat ["",printer2(a), "","@", printer2(b)]                    | E.Probe(a,b) => String.concat ["",printer2(a), "","@", printer2(b)]
54                    | E.Apply(a,b) => String.concat [ printer2(a)," ", printer2(b)," "]                    | E.Apply(a,b) => String.concat [ printer2(a)," ", printer2(b)," "]
55                    | E.Sum (id,a) => String.concat [" Sigma:", Int.toString(id), " ",printer2(a)]                    | E.Sum (id,a) => String.concat [" Sigma:", Int.toString(id), " ",printer2(a)]
# Line 61  Line 64 
64              | Param(E.FLD(d)::param, i)= String.concat[Int.toString(i), ":FLD-", intList d," ",Param(param, i+1)]              | Param(E.FLD(d)::param, i)= String.concat[Int.toString(i), ":FLD-", intList d," ",Param(param, i+1)]
65              | Param(_,_)=""              | Param(_,_)=""
66    
67          val str=String.concat [Param(params, 0)," \n<",printer2(body),">","\n _{",Index(index,0),"} \n "]          val str=String.concat [Param(params, 0)," \n<",printer2(body),">","\n _{",Index(index,0),"} \n \n \n "]
68          in          in
69              print str              print str; str
70          end          end
71    
72         (* fun printerApp(R.App(e,l))= printerE(e)         (* fun printerApp(R.App(e,l))= printerE(e)

Legend:
Removed from v.2426  
changed lines
  Added in v.2427

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