From 5ce65382cf4bdece30e9dee3f7765b698bd375e9 Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Sun, 6 Apr 2014 15:23:40 -0500 Subject: PS: add vector, hash-map, atoms and metadata. As part of this lists switch from being a postscript array to being a mal boxed type (dictionary with type in the /_maltype_ key). --- ps/printer.ps | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'ps/printer.ps') diff --git a/ps/printer.ps b/ps/printer.ps index c2e42a5..956bb18 100644 --- a/ps/printer.ps +++ b/ps/printer.ps @@ -1,19 +1,36 @@ -(in types.ps\n) print +(in printer.ps\n) print % requires types.ps to be included first +% ast print_readably -> _pr_str -> string /_pr_str { 4 dict begin /print_readably exch def dup /func? exch xcheck def % executable function /obj exch cvlit def - obj _mal_function? { % if user defined function + obj _sequential? { + obj _list? { (\() (\)) }{ ([) (]) } ifelse + obj /data get ( ) print_readably _pr_str_args + exch concatenate concatenate + }{ obj _hash_map? { + ({) + % get array of contents with keys stringified + [ obj /data get { exch dup length string cvs exch } forall ] + ( ) print_readably _pr_str_args + concatenate + (}) concatenate + }{ obj _mal_function? { % if user defined function (<\(fn* ) obj /params get print_readably _pr_str ( ) obj /ast get print_readably _pr_str (\)>) concatenate concatenate concatenate concatenate + }{ obj _atom? { % if atom + (\(atom ) + obj /data get print_readably _pr_str + (\)) + concatenate concatenate }{ /arraytype obj type eq { % if list or code block % accumulate an array of strings func? { () - } ifelse } ifelse } ifelse } ifelse } ifelse } ifelse } ifelse } ifelse + () + } ifelse } ifelse } ifelse } ifelse } ifelse } ifelse } ifelse } ifelse } ifelse } ifelse } ifelse end } def % array delim print_readably -> _pr_str_args -> new_string -- cgit v1.2.3