diff options
| author | Joel Martin <github@martintribe.org> | 2014-04-06 15:23:40 -0500 |
|---|---|---|
| committer | Joel Martin <github@martintribe.org> | 2014-04-06 15:23:40 -0500 |
| commit | 5ce65382cf4bdece30e9dee3f7765b698bd375e9 (patch) | |
| tree | 454089f5d1ea4ff1a2d78cf00e5c23397cac3065 /ps/printer.ps | |
| parent | ea81a8087bcd7953b083a2be9db447f75e7ebf56 (diff) | |
| download | mal-5ce65382cf4bdece30e9dee3f7765b698bd375e9.tar.gz mal-5ce65382cf4bdece30e9dee3f7765b698bd375e9.zip | |
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).
Diffstat (limited to 'ps/printer.ps')
| -rw-r--r-- | ps/printer.ps | 25 |
1 files changed, 21 insertions, 4 deletions
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? { (<builtin_fn* { ) }{ (\() } ifelse @@ -39,8 +56,8 @@ }{ /nametype obj type eq { % if symbol obj dup length string cvs }{ - (<unknown>) - } ifelse } ifelse } ifelse } ifelse } ifelse } ifelse } ifelse } ifelse + (<unknown>) + } ifelse } ifelse } ifelse } ifelse } ifelse } ifelse } ifelse } ifelse } ifelse } ifelse } ifelse end } def % array delim print_readably -> _pr_str_args -> new_string |
