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 293, Tue May 25 03:04:50 1999 UTC revision 294, Tue May 25 09:06:06 1999 UTC
# Line 44  Line 44 
44          (* We are consing up the whole output as a list of strings          (* We are consing up the whole output as a list of strings
45           * before concatenating it to form the final result and           * before concatenating it to form the final result and
46           * wrinting it out using one single `output' call. *)           * wrinting it out using one single `output' call. *)
47          fun w_name (n, r) = let          fun w_name (n, r) =
48              val ns = S.nameSpace n              (case S.nameSpace n of
49              val prefix =                   S.SIGspace => "'"      (* only tyvars could start like that *)
50                  case ns of                 | S.FCTspace => "("      (* no sym can start like that *)
51                      S.SIGspace => ";"                 | S.FSIGspace => ")"     (* no sym can start like that *)
                   | S.FCTspace => "("  
                   | S.FSIGspace => ")"  
52                    | S.STRspace => ""    (* this should be safe now *)                    | S.STRspace => ""    (* this should be safe now *)
53                    | _ => raise InternalError                 | _ => raise InternalError)
54          in              :: S.name n :: "." :: r
             prefix :: S.name n :: "." :: r  
         end  
55    
56          fun w_list w ([], r) = "0" :: r          (* foldl means that last element appears first in output! *)
57            | w_list w ([a], r) = "1" :: w (a, r)          fun w_list w (l, r) = foldl w (";" :: r) l
           | w_list w ([a, b], r) = "2" :: w (a, w (b, r))  
           | w_list w ([a, b, c], r) = "3" :: w (a, w (b, w (c, r)))  
           | w_list w ([a, b, c, d], r) = "4" :: w (a, w (b, w (c, w (d, r))))  
           | w_list w (a :: b :: c :: d :: e :: x, r) =  
             "5" :: w (a, w (b, w (c, w (d, w (e, w_list w (x, r))))))  
58    
59          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)
60    
# Line 99  Line 90 
90                  loop ([], first)                  loop ([], first)
91              end              end
92          in          in
93              fun r_name (SOME #";") = get (S.sigSymbol, rd ())              fun r_name (SOME #"'") = get (S.sigSymbol, rd ())
94                | r_name (SOME #"(") = get (S.fctSymbol, rd ())                | r_name (SOME #"(") = get (S.fctSymbol, rd ())
95                | r_name (SOME #")") = get (S.fsigSymbol, rd ())                | r_name (SOME #")") = get (S.fsigSymbol, rd ())
96                | r_name first = get (S.strSymbol, first)                | r_name first = get (S.strSymbol, first)
97          end          end
98    
99          fun r_list r = let          (* lists are written in reverse order, so a tail-recursive
100              fun n () = r (rd ())           * reader is exactly right because it undoes the reversal *)
101              fun rl (SOME #"0") = []          fun r_list r first = let
102                | rl (SOME #"1") = [n ()]              (* argument order important: side effects in arguments! *)
103                | rl (SOME #"2") = [n (), n ()]              fun rl (l, SOME #";") = l
104                | rl (SOME #"3") = [n (), n (), n ()]                | rl (l, first) = rl (r first :: l, rd ())
               | rl (SOME #"4") = [n (), n (), n (), n ()]  
               | rl (SOME #"5") =  
                 n () :: n () :: n () :: n () :: n () :: rl (rd ())  
               | rl _ = raise FormatError  
105          in          in
106              rl              rl ([], first)
107          end          end
108    
109          fun r_path first = SP.SPATH (r_list r_name first)          fun r_path first = SP.SPATH (r_list r_name first)

Legend:
Removed from v.293  
changed lines
  Added in v.294

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