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 2436, Sat Sep 21 15:57:18 2013 UTC revision 2437, Mon Sep 23 22:28:42 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)=> Int.toString(cx)          of E.C(cx)=> String.concat["'",Int.toString(cx),"'"]
16          |  E.V(ix)=> Int.toString(ix)          |  E.V(ix)=> Int.toString(ix)
17      )      )
18    
19      fun printAlpha alpha= String.concat[String.concatWith "," (List.map printIndex alpha)]      fun printAlpha alpha= String.concat[String.concatWith "," (List.map printIndex alpha)]
20    
21    
22      fun handleBeta(a,b)=String.concat[printIndex a, ",", printIndex b]      fun handleBeta(a,b)=String.concat["Delta_(",printIndex a, ",", printIndex b,")"]
   
   
23    
24      fun printerE (Ein.EIN{params, index, body}) = let      fun printerE (Ein.EIN{params, index, body}) = let
25            fun printbody term = (case term            fun printbody term = (case term
# Line 31  Line 29 
29              | E.Field(id, []) =>String.concat[" F",Int.toString(id)]              | E.Field(id, []) =>String.concat[" F",Int.toString(id)]
30              | E.Field(id, alpha) =>String.concat[" F",Int.toString(id),"_",printAlpha alpha]              | E.Field(id, alpha) =>String.concat[" F",Int.toString(id),"_",printAlpha alpha]
31              | E.Kernel([]) =>String.concat["h"]              | E.Kernel([]) =>String.concat["h"]
32              | E.Kernel(betas) =>String.concat["h^",String.concat(List.map handleBeta betas)]              | E.Kernel(betas) =>String.concat["h^{",String.concat(List.map handleBeta betas),"}"]
33              | E.Delta(ix) => String.concat["Delta_", handleBeta ix]              | E.Delta(ix) =>  handleBeta ix
34              | E.Value(ix)=> String.concat["c-",Int.toString(ix)]              | E.Value(ix)=> String.concat["_",Int.toString(ix),"_"]
35              | E.Epsilon(ix, jx, kx) => String.concat["E_",Int.toString(ix), Int.toString(jx), Int.toString(kx)]              | E.Epsilon(ix, jx, kx) => String.concat["E_",Int.toString(ix), Int.toString(jx), Int.toString(kx)]
36              | E.Sum (count,e1)=> String.concat["Sigma:", Int.toString(count), printbody e1]              | E.Sum (count,e1)=> String.concat["Sigma:", Int.toString(count)," ", printbody e1]
37              | E.Neg e1 => String.concat["-", printbody e1]              | E.Neg e1 => String.concat["-", printbody e1]
38              | E.Add el => String.concat["(",String.concatWith "+" (List.map printbody el),")"]              | E.Add el => String.concat["(",String.concatWith "+" (List.map printbody el),")"]
39              | E.Sub(e1, e2) => String.concat ["(",printbody(e1),"- ",printbody(e2), ")"]              | E.Sub(e1, e2) => String.concat ["(",printbody(e1),"- ",printbody(e2), ")"]
# Line 44  Line 42 
42              | E.Partial alpha => String.concat["d/dx_",printAlpha alpha]              | E.Partial alpha => String.concat["d/dx_",printAlpha alpha]
43              | E.Apply(e1, e2)=> String.concat [ printbody(e1)," ", printbody(e2)," "]              | E.Apply(e1, e2)=> String.concat [ printbody(e1)," ", printbody(e2)," "]
44              | E.Conv(e1, [])=> String.concat[printbody(e1), "(*)h"]              | E.Conv(e1, [])=> String.concat[printbody(e1), "(*)h"]
45              | E.Conv(e1, alpha)=> String.concat[printbody(e1), "(*)h^",printAlpha alpha]              | E.Conv(e1, alpha)=> String.concat[printbody(e1), "(*) d/dx_{",printAlpha alpha,"}h"]
46              | E.Probe (e1,e2)=> String.concat ["",printbody(e1), "","@", printbody(e2)]              | E.Probe (e1,e2)=> String.concat ["",printbody(e1), "","@", printbody(e2)]
47              | E.Image(e1::es)=> let              | E.Image(e1::es)=> let
48                      val position=  String.concatWith "," (List.map printbody es)                      val position=  String.concatWith "," (List.map printbody es)
49                  in                  in
50                      String.concat ["",printbody(e1),"[", position,"]"]                      String.concat [printbody(e1),"[", position,"]"]
51                  end                  end
52              (* end case *))              (* end case *))
53    
# Line 59  Line 57 
57                  " DIM:",Int.toString(lb),",", Int.toString(ub),")", Index(i,count+1)]                  " DIM:",Int.toString(lb),",", Int.toString(ub),")", Index(i,count+1)]
58              | Index (_, count) = ""              | Index (_, count) = ""
59          fun Param(E.TEN::param, i)=String.concat[Int.toString(i), ":TEN ", Param(param, i+1)]          fun Param(E.TEN::param, i)=String.concat[Int.toString(i), ":TEN ", Param(param, i+1)]
60              | 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-", Int.toString d," ",Param(param, i+1)]
61              | Param(_,_)=""              | Param(_,_)=""
62    
63          val str=String.concat [Param(params, 0)," \n<",printbody(body),">","\n _{",Index(index,0),"} \n \n \n "]          val str=String.concat ["\n\t" ,Param(params, 0)," \n \t <",printbody(body),">","\n \t _{",Index(index,0),"} \n "]
64          in          in
65              print str; str              print str; str
66          end          end

Legend:
Removed from v.2436  
changed lines
  Added in v.2437

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