more prettyprinter fixes

cvs
Slava Pestov 2005-08-21 18:40:12 +00:00
parent 17b0f15425
commit 119cb1ba6b
6 changed files with 23 additions and 20 deletions

View File

@ -12,7 +12,7 @@ io kernel lists math namespaces prettyprint words ;
] unless ;
: compiling ( word -- word parameter )
check-architecture "Compiling " write dup pp dup word-def ;
check-architecture "Compiling " write dup . dup word-def ;
GENERIC: (compile) ( word -- )
@ -41,7 +41,7 @@ M: compound (compile) ( word -- )
"compile" get [ word compile ] when ; parsing
: cannot-compile ( word error -- )
"Cannot compile " write swap pp print-error ;
"Cannot compile " write swap . print-error ;
: try-compile ( word -- )
[ compile ] [ [ cannot-compile ] when* ] catch ;
@ -50,7 +50,7 @@ M: compound (compile) ( word -- )
: decompile ( word -- )
dup compiled? [
"Decompiling " write dup pp
"Decompiling " write dup .
[ word-primitive ] keep set-word-primitive
] [
drop

View File

@ -82,4 +82,4 @@ M: #entry node>quot ( ? node -- ) "#entry" comment, ;
: dataflow. ( quot ? -- )
#! Print dataflow IR for a quotation. Flag indicates if
#! annotations should be printed or not.
>r dataflow optimize r> dataflow>quot pp ;
>r dataflow optimize r> dataflow>quot . ;

View File

@ -244,17 +244,22 @@ M: wrapper pprint* ( wrapper -- )
: pprint>string ( object -- string )
[ pprint ] string-out ;
: pp ( obj -- ) pprint terpri ;
: . ( obj -- ) pprint terpri ;
: . ( obj -- )
[ 2 nesting-limit set 100 length-limit set pp ] with-scope ;
: pprint-short ( object -- string )
[
1 line-limit set
5 length-limit set
2 nesting-limit set
pprint
] with-scope ;
: pprint>short-string ( object -- string )
[ pprint-short ] string-out ;
: [.] ( sequence -- )
#! Unparse each element on its own line.
[
1 line-limit set 10 length-limit set
[ pp ] each
] with-scope ;
[ [ pprint>short-string print ] each ] with-scope ;
: stack. reverse-slice [.] ;

View File

@ -17,8 +17,8 @@ vectors words ;
: type-check-error. ( list -- )
"Type check error" print
uncons car dup "Object: " write .
"Object type: " write class pp
"Expected type: " write type>class pp ;
"Object type: " write class .
"Expected type: " write type>class . ;
: float-format-error. ( list -- )
"Invalid floating point literal format: " write . ;

View File

@ -15,9 +15,7 @@ M: object sheet ( obj -- sheet )
tuck [ execute ] map-with
2list ;
PREDICATE: list nonvoid cons? ;
M: nonvoid sheet unit ;
M: list sheet unit ;
M: vector sheet unit ;
@ -26,7 +24,7 @@ M: array sheet unit ;
M: hashtable sheet dup hash-keys swap hash-values 2list ;
: format-column ( list -- list )
[ unparse ] map
[ pprint>short-string ] map
[ max-length ] keep
[ swap CHAR: \s pad-right ] map-with ;
@ -45,7 +43,7 @@ M: hashtable sheet dup hash-keys swap hash-values 2list ;
"This is an orphan not part of the dictionary." print
"It claims to belong to the " write
] ifte
word-vocabulary unparse write " vocabulary." print
word-vocabulary pprint " vocabulary." print
] [
drop
"The word is a uniquely generated symbol." print
@ -65,7 +63,7 @@ M: object extra-banner ( obj -- ) drop ;
: inspect-banner ( obj -- )
"You are looking at an instance of the " write dup class pprint
" class:" print
" " write dup pp
" " write dup pprint-short terpri
"It takes up " write dup size pprint " bytes of memory." print
extra-banner ;

View File

@ -47,7 +47,7 @@ global [ 100 <vector> commands set ] bind
"This stream does not support live gadgets"
swap format terpri ;
[ drop t ] "Prettyprint" [ pp ] define-command
[ drop t ] "Prettyprint" [ . ] define-command
[ drop t ] "Inspect" [ inspect ] define-command
[ drop t ] "References" [ references inspect ] define-command