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/ml-lex/lexgen.sml
ViewVC logotype

Diff of /sml/trunk/src/ml-lex/lexgen.sml

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

revision 419, Fri Sep 3 23:51:27 1999 UTC revision 656, Fri Jun 9 03:39:04 2000 UTC
# Line 45  Line 45 
45                  and characters.                  and characters.
46          02/08/95 (jhr) Modified to use new List module interface.          02/08/95 (jhr) Modified to use new List module interface.
47          05/18/95 (jhr) changed Vector.vector to Vector.fromList          05/18/95 (jhr) changed Vector.vector to Vector.fromList
48  *  
  * $Log: lexgen.sml,v $  
  * Revision 1.1.1.1  1998/04/08 18:40:10  george  
  * Version 110.5  
  *  
49   * Revision 1.9  1998/01/06 19:23:53  appel   * Revision 1.9  1998/01/06 19:23:53  appel
50   *   added %posarg feature to permit position-within-file to be passed   *   added %posarg feature to permit position-within-file to be passed
51   *   as a parameter to makeLexer   *   as a parameter to makeLexer
# Line 72  Line 68 
68  # Revision 1.3  1997/10/04  03:52:13  dbm  # Revision 1.3  1997/10/04  03:52:13  dbm
69  #   Fix to remove output file if ml-lex fails.  #   Fix to remove output file if ml-lex fails.
70  #  #
 # Revision 1.2  1997/05/06  01:12:38  george  
 # *** empty log message ***  
 #  
  * Revision 1.2  1996/02/26  15:02:27  george  
  *    print no longer overloaded.  
  *    use of makestring has been removed and replaced with Int.toString ..  
  *    use of IO replaced with TextIO  
  *  
  * Revision 1.1.1.1  1996/01/31  16:01:15  george  
  * Version 109  
  *  
71   *)   *)
72    
73  (* Subject: lookahead in sml-lex  (* Subject: lookahead in sml-lex
# Line 912  Line 897 
897    
898           fun GetEndLeaf t =           fun GetEndLeaf t =
899             let fun f ((tl,el)::r) = if (tl=t) then el else f r             let fun f ((tl,el)::r) = if (tl=t) then el else f r
900                     | f _ = raise Match
901             in f tcpairs             in f tcpairs
902             end             end
903           fun GetTrConLeaves s =           fun GetTrConLeaves s =
# Line 987  Line 973 
973    
974              val _ = say "val s = map f (rev (tl (rev s))) \n"              val _ = say "val s = map f (rev (tl (rev s))) \n"
975              val _ = say "exception LexHackingError \n"              val _ = say "exception LexHackingError \n"
976              val _ = say "fun look ((j,x)::r, i) = if i = j then x else look(r, i) \n"              val _ = say "fun look ((j,x)::r, i: int) = if i = j then x else look(r, i) \n"
977              val _ = say "  | look ([], i) = raise LexHackingError\n"              val _ = say "  | look ([], i) = raise LexHackingError\n"
978    
979          val _ = say "fun g {fin=x, trans=i} = {fin=x, trans=look(s,i)} \n"          val _ = say "fun g {fin=x, trans=i} = {fin=x, trans=look(s,i)} \n"
980           in res           in res
981          end          end
982    
983            fun makeTable args = let
984                fun makeOne (a, b) = let
985                    fun item (N i) = ("N", i)
986                      | item (T i) = ("T", i)
987                      | item (D i) = ("D", i)
988                    fun makeItem x = let
989                        val (t, n) = item x
990                    in
991                        app say ["(", t, " ", Int.toString n, ")"]
992                    end
993                    fun makeItems [] = ()
994                      | makeItems [x] = makeItem x
995                      | makeItems (hd :: tl) =
996                        (makeItem hd; say ","; makeItems tl)
997                in
998                    say "{fin = [";
999                    makeItems b;
1000                    app say ["], trans = ", a, "}"]
1001                end
1002                fun mt ([], []) = ()
1003                  | mt ([a], [b]) = makeOne (a, b)
1004                  | mt (a :: a', b :: b') =
1005                    (makeOne (a, b); say ",\n"; mt (a', b'))
1006                  | mt _ = raise Match
1007            in
1008                mt args
1009            end
1010    
1011    (*
1012          fun makeTable(nil,nil) = ()          fun makeTable(nil,nil) = ()
1013            | makeTable(a::a',b::b') =            | makeTable(a::a',b::b') =
1014               let fun makeItems nil = ()               let fun makeItems nil = ()
# Line 1014  Line 1029 
1029                    then ()                    then ()
1030                    else (say ",\n"; makeTable(a',b')))                    else (say ",\n"; makeTable(a',b')))
1031                end                end
1032    *)
1033    
1034          fun msg x = TextIO.output(TextIO.stdOut, x)          fun msg x = TextIO.output(TextIO.stdOut, x)
1035    

Legend:
Removed from v.419  
changed lines
  Added in v.656

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