diff options
| author | Joel Martin <github@martintribe.org> | 2014-04-01 21:50:24 -0500 |
|---|---|---|
| committer | Joel Martin <github@martintribe.org> | 2014-04-01 21:50:24 -0500 |
| commit | 950e3c765e30648de34cfc4f65fffdce06f0727f (patch) | |
| tree | 3e66b70a71a5cfa01671830d80d7ea7926509b2d /ps/step3_env.ps | |
| parent | 704194e12c5080f5c6842416a78fe7efa09da068 (diff) | |
| download | mal-950e3c765e30648de34cfc4f65fffdce06f0727f.tar.gz mal-950e3c765e30648de34cfc4f65fffdce06f0727f.zip | |
PS: add stepA_more.
Sync other steps. In particular, self reference in function definition
and putting readline into _readline function.
Diffstat (limited to 'ps/step3_env.ps')
| -rw-r--r-- | ps/step3_env.ps | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/ps/step3_env.ps b/ps/step3_env.ps index e906386..a86e036 100644 --- a/ps/step3_env.ps +++ b/ps/step3_env.ps @@ -2,6 +2,8 @@ (reader.ps) run % read +/_readline { print flush (%stdin) (r) file 99 string readline } def + /READ { /str exch def str read_str @@ -29,7 +31,8 @@ end } def /EVAL { 8 dict begin /env exch def /ast exch def - %(EVAL: ) print ast == + + %(EVAL: ) print ast true _pr_str print (\n) print ast _list? not { %if not a list ast env eval_ast }{ %else apply the list @@ -53,7 +56,8 @@ end } def a2 let_env EVAL }{ /el ast env eval_ast def - el _rest el _first exec % apply function to args + el _rest el _first % stack: ast function + exec % apply function to args } ifelse } ifelse } ifelse end } def @@ -76,23 +80,19 @@ end } def (*) { dup 0 get exch 1 get mul } _ref (/) { dup 0 get exch 1 get idiv } _ref -/stdin (%stdin) (r) file def - { % loop - (user> ) print flush - - stdin 99 string readline - + (user> ) _readline not { exit } if % exit if EOF - %(\ngot line: ) print dup print (\n) print flush - { %try REP print (\n) print } stopped { (Error: ) print get_error_data false _pr_str print (\n) print + $error /newerror false put + $error /errorinfo null put clear + cleardictstack } if } bind loop |
