1 ! Copyright (C) 2007, 2008 Slava Pestov, Eduardo Cavazos.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors combinators kernel locals locals.types math
4 prettyprint.backend prettyprint.custom prettyprint.sections
8 : pprint-var ( var -- )
9 ! Prettyprint a read/write local as its writer, just like
10 ! in the input syntax: [| x! | ... x 3 + x! ]
12 "local-writer" word-prop
15 : pprint-vars ( vars -- ) [ pprint-var ] each ;
20 dup vars>> pprint-vars
22 f <inset body>> pprint-elements block>
26 : pprint-let ( let word -- )
28 <block body>> pprint-elements block>
31 M: let pprint* \ [let pprint-let ;
34 dup locals>> [ word? ] all? [
35 <block \ :> pprint-word locals>> {
36 [ length 1 > [ "(" text ] when ]
37 [ [ pprint-var ] each ]
38 [ length 1 > [ ")" text ] when ]
40 ] [ pprint-tuple ] if ;