Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/src/cm/smlfile/skel-io.sml
ViewVC logotype

Diff of /sml/trunk/src/cm/smlfile/skel-io.sml

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

revision 279, Tue May 18 08:10:36 1999 UTC revision 286, Fri May 21 07:47:16 1999 UTC
# Line 24  Line 24 
24      val s2b = Byte.stringToBytes      val s2b = Byte.stringToBytes
25      val b2c = Byte.byteToChar      val b2c = Byte.byteToChar
26    
27      val version = "Decl 10\n"      val version = "Skeleton 1\n"
28    
29      fun makeset l = SS.addList (SS.empty, l)      fun makeset l = SS.addList (SS.empty, l)
30    
# Line 61  Line 61 
61    
62          fun w_path (SP.SPATH p, r) = w_list w_name (p, r)          fun w_path (SP.SPATH p, r) = w_list w_name (p, r)
63    
64          fun w_option w (NONE, r) = "-" :: r          fun w_decl (SK.Bind (name, def), r) =
65            | w_option w (SOME x, r) = "+" :: w (x, r)              "b" :: w_name (name, w_modExp (def, r))
66              | w_decl (SK.Local (x, y), r) = "l" :: w_decl (x, w_decl (y, r))
67          fun w_decl (SK.StrDecl l, r) =            | w_decl (SK.Par l, r) = "p" :: w_list w_decl (l, r)
68              let            | w_decl (SK.Seq l, r) = "q" :: w_list w_decl (l, r)
69                  fun w_item ({ name, def, constraint }, r) =            | w_decl (SK.Open d, r) = "o" :: w_modExp (d, r)
70                      w_name (name,            | w_decl (SK.Ref s, r) = "r" :: w_list w_name (SS.listItems s, r)
71                              w_strExp (def,  
72                                        w_option w_strExp (constraint, r)))          and w_modExp (SK.Var p, r) = "v" :: w_path (p, r)
73              in            | w_modExp (SK.Decl d, r) = "d" :: w_decl (d, r)
74                  "s" :: w_list w_item (l, r)            | w_modExp (SK.App (p, l), r) =
75              end              "a" :: w_path (p, w_list w_modExp (l, r))
76            | w_decl (SK.FctDecl l, r) = let            | w_modExp (SK.Let (d, m), r) = "l" :: w_decl (d, w_modExp (m, r))
77                  fun w_item ({ name, def }, r) =            | w_modExp (SK.Con (m1, m2), r) =
78                      w_name (name, w_fctExp (def, r))              "c" :: w_modExp (m1, w_modExp (m2, r))
             in  
                 "f" :: w_list w_item (l, r)  
             end  
           | w_decl (SK.LocalDecl (x, y), r) = "l" :: w_decl (x, w_decl (y, r))  
           | w_decl (SK.SeqDecl l, r) = "q" :: w_list w_decl (l, r)  
           | w_decl (SK.OpenDecl l, r) = "o" :: w_list w_strExp (l, r)  
           | w_decl (SK.DeclRef s, r) = "r" :: w_list w_name (SS.listItems s, r)  
   
         and w_strExp (SK.VarStrExp p, r) = "v" :: w_path (p, r)  
           | w_strExp (SK.BaseStrExp d, r) = "s" :: w_decl (d, r)  
           | w_strExp (SK.AppStrExp (p, l), r) =  
             "a" :: w_path (p, w_list w_strExp (l, r))  
           | w_strExp (SK.LetStrExp (d, se), r) =  
             "l" :: w_decl (d, w_strExp (se, r))  
           | w_strExp (SK.ConStrExp (s1, s2), r) =  
             "c" :: w_strExp (s1, w_strExp(s2, r))  
   
         and w_fctExp (SK.VarFctExp (p, fe), r) =  
             "v" :: w_path (p, w_option w_fctExp (fe, r))  
           | w_fctExp (SK.BaseFctExp { params, body, constraint }, r) =  
             "f" :: w_decl (params,  
                            w_strExp (body, w_option w_strExp (constraint, r)))  
           | w_fctExp (SK.AppFctExp (p, sel, feo), r) =  
             "a" ::  
             w_path (p, w_list w_strExp (sel, w_option w_fctExp (feo, r)))  
           | w_fctExp (SK.LetFctExp (d, fe), r) =  
             "l" :: w_decl (d, w_fctExp (fe, r))  
   
79      in      in
80          BinIO.output (s, s2b (concat (version :: w_decl (d, ["\n"]))))          BinIO.output (s, s2b (concat (version :: w_decl (d, ["\n"]))))
81      end      end
# Line 139  Line 111 
111    
112          fun r_path first = SP.SPATH (r_list r_name first)          fun r_path first = SP.SPATH (r_list r_name first)
113    
114          fun r_option r (SOME #"-") = NONE          fun r_decl (SOME #"b") = SK.Bind (r_name (rd ()), r_modExp (rd ()))
115            | r_option r (SOME #"+") = SOME (r (rd ()))            | r_decl (SOME #"l") = SK.Local (r_decl (rd ()), r_decl (rd ()))
116            | r_option r _ = raise FormatError            | r_decl (SOME #"p") = SK.Par (r_list r_decl (rd ()))
117              | r_decl (SOME #"q") = SK.Seq (r_list r_decl (rd ()))
118          fun r_decl (SOME #"s") =            | r_decl (SOME #"o") = SK.Open (r_modExp (rd ()))
119              let            | r_decl (SOME #"r") = SK.Ref (makeset (r_list r_name (rd ())))
                 fun r_item first = {  
                                     name = r_name first,  
                                     def = r_strExp (rd ()),  
                                     constraint = r_option r_strExp (rd ())  
                                    }  
             in  
                 SK.StrDecl (r_list r_item (rd ()))  
             end  
           | r_decl (SOME #"f") =  
             let  
                 fun r_item first = {  
                                     name = r_name first,  
                                     def = r_fctExp (rd ())  
                                    }  
             in  
                 SK.FctDecl (r_list r_item (rd ()))  
             end  
           | r_decl (SOME #"l") = SK.LocalDecl (r_decl (rd ()), r_decl (rd ()))  
           | r_decl (SOME #"q") = SK.SeqDecl (r_list r_decl (rd ()))  
           | r_decl (SOME #"o") = SK.OpenDecl (r_list r_strExp (rd ()))  
           | r_decl (SOME #"r") = SK.DeclRef (makeset (r_list r_name(rd ())))  
120            | r_decl _ = raise FormatError            | r_decl _ = raise FormatError
121    
122          and r_strExp (SOME #"v") = SK.VarStrExp (r_path (rd ()))          and r_modExp (SOME #"v") = SK.Var (r_path (rd ()))
123            | r_strExp (SOME #"s") = SK.BaseStrExp (r_decl (rd ()))            | r_modExp (SOME #"d") = SK.Decl (r_decl (rd ()))
124            | r_strExp (SOME #"a") =            | r_modExp (SOME #"a") =
125              SK.AppStrExp (r_path (rd ()), r_list r_strExp (rd ()))              SK.App (r_path (rd ()), r_list r_modExp (rd ()))
126            | r_strExp (SOME #"l") =            | r_modExp (SOME #"l") = SK.Let (r_decl (rd ()), r_modExp (rd ()))
127              SK.LetStrExp (r_decl (rd ()), r_strExp (rd ()))            | r_modExp (SOME #"c") = SK.Con (r_modExp (rd ()), r_modExp (rd ()))
128            | r_strExp (SOME #"c") =            | r_modExp _ = raise FormatError
             SK.ConStrExp (r_strExp (rd ()), r_strExp (rd ()))  
           | r_strExp _ = raise FormatError  
   
         and r_fctExp (SOME #"v") =  
             SK.VarFctExp (r_path(rd()), r_option r_fctExp(rd()))  
           | r_fctExp (SOME #"f") =  
             SK.BaseFctExp { params = r_decl (rd ()),  
                             body = r_strExp (rd ()),  
                             constraint = r_option r_strExp (rd ()) }  
           | r_fctExp (SOME #"a") =  
             SK.AppFctExp (r_path (rd ()),  
                           r_list r_strExp (rd ()),  
                           r_option r_fctExp (rd ()))  
           | r_fctExp (SOME #"l") =  
             SK.LetFctExp (r_decl (rd ()), r_fctExp (rd ()))  
           | r_fctExp _ = raise FormatError  
129    
130          val firstline = inputLine s          val firstline = inputLine s
131          val r = if firstline = version then r_decl (rd ())          val r = if firstline = version then r_decl (rd ())

Legend:
Removed from v.279  
changed lines
  Added in v.286

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