CVS: sml/src/smlnj-lib/PP/src pp-debug-fn.sml,1.3,1.4 pp-desc-fn.sml,1.2,1.3 pp-desc-sig.sml,1.2,1.3 pp-stream-fn.sml,1.4,1.5 pp-stream-sig.sml,1.3,1.4 sources.cm,1.4,1.5 pp-desc.sml,1.2,NONE
John Reppy <[email protected]>
| Newsgroups | gmane.comp.lang.sml.smlnj.commits |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/smlnj/sml/src/smlnj-lib/PP/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11007/PP/src
Modified Files:
pp-debug-fn.sml pp-desc-fn.sml pp-desc-sig.sml
pp-stream-fn.sml pp-stream-sig.sml sources.cm
Removed Files:
pp-desc.sml
Log Message:
Refactored PP library.
Index: pp-debug-fn.sml
===================================================================
RCS file: /cvsroot/smlnj/sml/src/smlnj-lib/PP/src/pp-debug-fn.sml,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** pp-debug-fn.sml 11 Aug 2003 20:45:59 -0000 1.3
--- pp-debug-fn.sml 6 Jul 2005 14:35:47 -0000 1.4
***************
*** 1,5 ****
(* pp-debug-fn.sml
*
! * COPYRIGHT (c) 1997 Bell Labs, Lucent Technologies.
*
* A wrapper for the PPStreamFn, which dumps the current PP state prior
--- 1,6 ----
(* pp-debug-fn.sml
*
! * COPYRIGHT (c) 2005 John Reppy (http://www.cs.uchicago.edu/~jhr)
! * All rights reserved.
*
* A wrapper for the PPStreamFn, which dumps the current PP state prior
***************
*** 57,68 ****
val newline = debug' "newline" PP.newline
val nbSpace = debug "nbSpace" PP.nbSpace
- val onNewline = debug "onNewline" PP.onNewline
val control = debug "control" PP.control
- type pp_desc = PP.pp_desc
- val description = debug "description" PP.description
-
- structure Desc = PP.Desc
-
end;
--- 58,63 ----
Index: pp-desc-fn.sml
===================================================================
RCS file: /cvsroot/smlnj/sml/src/smlnj-lib/PP/src/pp-desc-fn.sml,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** pp-desc-fn.sml 1 Jun 2000 18:33:54 -0000 1.2
--- pp-desc-fn.sml 6 Jul 2005 14:35:47 -0000 1.3
***************
*** 1,37 ****
(* pp-desc-fn.sml
*
! * COPYRIGHT (c) 1997 Bell Labs, Lucent Technologies.
*
! * This interface provides a declarative way to specify pretty-printing.
*)
! functor PPDescFn (S : sig
! include PP_STREAM
! where type indent = PPDesc.indent
! where type pp_desc = (token, style, device) PPDesc.pp_desc
! end) :> PP_DESC =
struct
! structure PPS = S
! structure D = PPDesc
- type pp_desc = PPS.pp_desc
type token = PPS.token
type style = PPS.style
type indent = PPS.indent
! val hBox = D.HBox
! val vBox = D.VBox
! val hvBox = D.HVBox
! val hovBox = D.HOVBox
! val box = D.Box
! val token = D.Token
! val string = D.String
! val style = D.Style
! val break = D.Break
! fun space n = D.Break{nsp = n, offset = 0}
! val cut = D.Break{nsp = 0, offset = 0}
! val newline = D.NewLine
! val control = D.Control
end;
--- 1,70 ----
(* pp-desc-fn.sml
*
! * COPYRIGHT (c) 2005 John Reppy (http://www.cs.uchicago.edu/~jhr)
! * All rights reserved.
*
! * This functor implements a declarative way to specify pretty-printing
! * (see pp-desc-sig.sml).
*)
! functor PPDescFn (PPS : PP_STREAM) :> PP_DESC =
struct
! structure PPS = PPS
type token = PPS.token
type style = PPS.style
type indent = PPS.indent
! (* The pp_desc type is a concrete representation of a PP layout. *)
! datatype pp_desc
! = HBox of pp_desc list
! | VBox of (indent * pp_desc list)
! | HVBox of (indent * pp_desc list)
! | HOVBox of (indent * pp_desc list)
! | Box of (indent * pp_desc list)
! | Token of token
! | String of string
! | Style of (style * pp_desc list)
! | Break of {nsp : int, offset : int}
! | NewLine
! | NBSpace of int
! | Control of (PPS.device -> unit)
!
! (* pretty print a description *)
! fun description strm = let
! fun pp (HBox l) = (PPS.openHBox strm; ppList l; PPS.closeBox strm)
! | pp (VBox(i, l)) = (PPS.openVBox strm i; ppList l; PPS.closeBox strm)
! | pp (HVBox(i, l)) = (PPS.openHVBox strm i; ppList l; PPS.closeBox strm)
! | pp (HOVBox(i, l)) = (PPS.openHOVBox strm i; ppList l; PPS.closeBox strm)
! | pp (Box(i, l)) = (PPS.openBox strm i; ppList l; PPS.closeBox strm)
! | pp (Token tok) = PPS.token strm tok
! | pp (String s) = PPS.string strm s
! | pp (Style(sty, l)) = (
! PPS.pushStyle(strm, sty); ppList l; PPS.popStyle strm)
! | pp (Break brk) = PPS.break strm brk
! | pp NewLine = PPS.newline strm
! | pp (NBSpace n) = PPS.nbSpace strm n
! | pp (Control ctlFn) = PPS.control strm ctlFn
! and ppList [] = ()
! | ppList (item::r) = (pp item; ppList r)
! in
! pp
! end
!
! (* exported PP description constructors *)
! val hBox = HBox
! val vBox = VBox
! val hvBox = HVBox
! val hovBox = HOVBox
! val box = Box
! val token = Token
! val string = String
! val style = Style
! val break = Break
! fun space n = Break{nsp = n, offset = 0}
! val cut = Break{nsp = 0, offset = 0}
! val newline = NewLine
! val control = Control
end;
Index: pp-desc-sig.sml
===================================================================
RCS file: /cvsroot/smlnj/sml/src/smlnj-lib/PP/src/pp-desc-sig.sml,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** pp-desc-sig.sml 1 Jun 2000 18:33:54 -0000 1.2
--- pp-desc-sig.sml 6 Jul 2005 14:35:48 -0000 1.3
***************
*** 1,5 ****
(* pp-desc-sig.sml
*
! * COPYRIGHT (c) 1997 Bell Labs, Lucent Technologies.
*
* This interface provides a declarative way to specify pretty-printing.
--- 1,6 ----
(* pp-desc-sig.sml
*
! * COPYRIGHT (c) 2005 John Reppy (http://www.cs.uchicago.edu/~jhr)
! * All rights reserved.
*
* This interface provides a declarative way to specify pretty-printing.
***************
*** 10,34 ****
structure PPS : PP_STREAM
! type pp_desc = PPS.pp_desc
! type token = PPS.token
! type style = PPS.style
! type indent = PPS.indent
val hBox : pp_desc list -> pp_desc
! val vBox : (indent * pp_desc list) -> pp_desc
! val hvBox : (indent * pp_desc list) -> pp_desc
! val hovBox : (indent * pp_desc list) -> pp_desc
! val box : (indent * pp_desc list) -> pp_desc
! val token : token -> pp_desc
val string : string -> pp_desc
! val style : (style * pp_desc list) -> pp_desc
val break : {nsp : int, offset : int} -> pp_desc
val space : int -> pp_desc
- (* space n == break{nsp=n, offset=0} *)
val cut : pp_desc
- (* cut == break{nsp=0, offset=0} *)
val newline : pp_desc
--- 11,30 ----
structure PPS : PP_STREAM
! type pp_desc
val hBox : pp_desc list -> pp_desc
! val vBox : (PPS.indent * pp_desc list) -> pp_desc
! val hvBox : (PPS.indent * pp_desc list) -> pp_desc
! val hovBox : (PPS.indent * pp_desc list) -> pp_desc
! val box : (PPS.indent * pp_desc list) -> pp_desc
! val token : PPS.token -> pp_desc
val string : string -> pp_desc
! val style : (PPS.style * pp_desc list) -> pp_desc
val break : {nsp : int, offset : int} -> pp_desc
val space : int -> pp_desc
val cut : pp_desc
val newline : pp_desc
Index: pp-stream-fn.sml
===================================================================
RCS file: /cvsroot/smlnj/sml/src/smlnj-lib/PP/src/pp-stream-fn.sml,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** pp-stream-fn.sml 31 Jul 2003 22:16:26 -0000 1.4
--- pp-stream-fn.sml 6 Jul 2005 14:35:48 -0000 1.5
***************
*** 1,5 ****
(* pp-stream-fn.sml
*
! * COPYRIGHT (c) 1997 Bell Labs, Lucent Technologies.
*
* The implementation of PP streams, where all the action is.
--- 1,6 ----
(* pp-stream-fn.sml
*
! * COPYRIGHT (c) 2005 John Reppy (http://www.cs.uchicago.edu/~jhr)
! * All rights reserved.
*
* The implementation of PP streams, where all the action is.
***************
*** 19,23 ****
structure T = Token
structure Q = Queue
- structure PPD = PPDesc
type device = D.device
--- 20,23 ----
***************
*** 25,29 ****
type style = T.style
! datatype indent = datatype PPD.indent
(**** DATA STRUCTURES ****)
--- 25,31 ----
type style = T.style
! datatype indent
! = Abs of int (* indent relative to outer indentation *)
! | Rel of int (* indent relative to start of box *)
(**** DATA STRUCTURES ****)
***************
*** 469,517 ****
fun nbSpace strm n = enqueueTokenWithLen (strm, NBSP n, n)
- fun onNewline strm () = raise Fail "onNewline"
-
fun control strm ctlFn = enqueueToken (strm, CTL ctlFn)
- (* pretty print a description *)
- type pp_desc = (token, style, device) PPD.pp_desc
-
- fun description strm = let
- fun pp (PPD.HBox l) = (openHBox strm; ppList l; closeBox strm)
- | pp (PPD.VBox(i, l)) = (openVBox strm i; ppList l; closeBox strm)
- | pp (PPD.HVBox(i, l)) = (openHVBox strm i; ppList l; closeBox strm)
- | pp (PPD.HOVBox(i, l)) = (openHOVBox strm i; ppList l; closeBox strm)
- | pp (PPD.Box(i, l)) = (openBox strm i; ppList l; closeBox strm)
- | pp (PPD.Token tok) = token strm tok
- | pp (PPD.String s) = string strm s
- | pp (PPD.Style(sty, l)) = (
- pushStyle(strm, sty); ppList l; popStyle strm)
- | pp (PPD.Break brk) = break strm brk
- | pp PPD.NewLine = newline strm
- | pp (PPD.NBSpace n) = nbSpace strm n
- | pp (PPD.Control ctlFn) = control strm ctlFn
- and ppList [] = ()
- | ppList (item::r) = (pp item; ppList r)
- in
- pp
- end
-
- (* PP description constructors *)
- structure Desc =
- struct
- val hBox = PPD.HBox
- val vBox = PPD.VBox
- val hvBox = PPD.HVBox
- val hovBox = PPD.HOVBox
- val box = PPD.Box
- val token = PPD.Token
- val string = PPD.String
- val style = PPD.Style
- val break = PPD.Break
- fun space n = PPD.Break{nsp = n, offset = 0}
- val cut = PPD.Break{nsp = 0, offset = 0}
- val newline = PPD.NewLine
- val control = PPD.Control
- end
-
end
--- 471,476 ----
Index: pp-stream-sig.sml
===================================================================
RCS file: /cvsroot/smlnj/sml/src/smlnj-lib/PP/src/pp-stream-sig.sml,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** pp-stream-sig.sml 31 Jul 2003 22:16:26 -0000 1.3
--- pp-stream-sig.sml 6 Jul 2005 14:35:48 -0000 1.4
***************
*** 1,5 ****
(* pp-stream-sig.sml
*
! * COPYRIGHT (c) 1997 Bell Labs, Lucent Technologies.
*
* This interface provides a output stream interface to pretty printing.
--- 1,6 ----
(* pp-stream-sig.sml
*
! * COPYRIGHT (c) 2005 John Reppy (http://www.cs.uchicago.edu/~jhr)
! * All rights reserved.
*
* This interface provides a output stream interface to pretty printing.
***************
*** 48,77 ****
(* emits a nonbreakable space *)
- val onNewline : stream -> unit -> unit
- (* the command is executed iff it is preceeded by a newline *)
-
val control : stream -> (device -> unit) -> unit
- (* pretty-print a PP description *)
- type pp_desc
- val description : stream -> pp_desc -> unit
-
- (* PP description constructors *)
- structure Desc : sig
- val hBox : pp_desc list -> pp_desc
- val vBox : (indent * pp_desc list) -> pp_desc
- val hvBox : (indent * pp_desc list) -> pp_desc
- val hovBox : (indent * pp_desc list) -> pp_desc
- val box : (indent * pp_desc list) -> pp_desc
- val token : token -> pp_desc
- val string : string -> pp_desc
- val style : (style * pp_desc list) -> pp_desc
- val break : {nsp : int, offset : int} -> pp_desc
- val space : int -> pp_desc
- val cut : pp_desc
- val newline : pp_desc
- val control : (device -> unit) -> pp_desc
- end
-
end
--- 49,54 ----
Index: sources.cm
===================================================================
RCS file: /cvsroot/smlnj/sml/src/smlnj-lib/PP/src/sources.cm,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** sources.cm 18 Oct 2004 21:45:30 -0000 1.4
--- sources.cm 6 Jul 2005 14:35:48 -0000 1.5
***************
*** 7,10 ****
--- 7,11 ----
Group
+ signature PP_DESC
signature PP_DEVICE
signature PP_TOKEN
***************
*** 12,15 ****
--- 13,17 ----
functor PPStreamFn
+ functor PPDescFn
functor PPDebugFn
***************
*** 24,29 ****
pp-device-sig.sml
pp-token-sig.sml
! pp-desc.sml
pp-stream-sig.sml
pp-stream-fn.sml
pp-debug-fn.sml
--- 26,33 ----
pp-device-sig.sml
pp-token-sig.sml
! pp-desc-fn.sml
pp-stream-sig.sml
pp-stream-fn.sml
pp-debug-fn.sml
+ pp-desc-sig.sml
+
--- pp-desc.sml DELETED ---
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click