From 950e3c765e30648de34cfc4f65fffdce06f0727f Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Tue, 1 Apr 2014 21:50:24 -0500 Subject: PS: add stepA_more. Sync other steps. In particular, self reference in function definition and putting readline into _readline function. --- ps/step2_eval.ps | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'ps/step2_eval.ps') 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 -- cgit v1.2.3