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/step2_eval.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/step2_eval.ps')
| -rw-r--r-- | ps/step2_eval.ps | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/ps/step2_eval.ps b/ps/step2_eval.ps index aa34bf5..b353f8e 100644 --- a/ps/step2_eval.ps +++ b/ps/step2_eval.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 @@ -39,7 +41,8 @@ end } def ast env eval_ast }{ %else apply the list /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 end } def @@ -60,23 +63,19 @@ end } def /REP { READ repl_env EVAL PRINT } def -/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 |
