diff options
Diffstat (limited to 'ps')
| -rw-r--r-- | ps/step0_repl.ps | 3 | ||||
| -rw-r--r-- | ps/step1_read_print.ps | 3 | ||||
| -rw-r--r-- | ps/step2_eval.ps | 3 | ||||
| -rw-r--r-- | ps/step3_env.ps | 3 | ||||
| -rw-r--r-- | ps/step4_if_fn_do.ps | 7 | ||||
| -rw-r--r-- | ps/step5_tco.ps | 7 | ||||
| -rw-r--r-- | ps/step6_file.ps | 18 | ||||
| -rw-r--r-- | ps/step7_quote.ps | 18 | ||||
| -rw-r--r-- | ps/step8_macros.ps | 18 | ||||
| -rw-r--r-- | ps/step9_interop.ps | 18 | ||||
| -rw-r--r-- | ps/stepA_more.ps | 19 |
11 files changed, 72 insertions, 45 deletions
diff --git a/ps/step0_repl.ps b/ps/step0_repl.ps index 046e5a1..d26844c 100644 --- a/ps/step0_repl.ps +++ b/ps/step0_repl.ps @@ -28,7 +28,8 @@ % repl /REP { READ (stub env) EVAL PRINT } def -{ % loop +% repl loop +{ %loop (user> ) _readline not { exit } if % exit if EOF diff --git a/ps/step1_read_print.ps b/ps/step1_read_print.ps index b4c6275..476c917 100644 --- a/ps/step1_read_print.ps +++ b/ps/step1_read_print.ps @@ -29,7 +29,8 @@ end } def % repl /REP { READ (stub env) EVAL PRINT } def -{ % loop +% repl loop +{ %loop (user> ) _readline not { exit } if % exit if EOF diff --git a/ps/step2_eval.ps b/ps/step2_eval.ps index d5c956b..551c637 100644 --- a/ps/step2_eval.ps +++ b/ps/step2_eval.ps @@ -71,7 +71,8 @@ end } def /REP { READ repl_env EVAL PRINT } def -{ % loop +% repl loop +{ %loop (user> ) _readline not { exit } if % exit if EOF diff --git a/ps/step3_env.ps b/ps/step3_env.ps index 42eda2c..92dc26e 100644 --- a/ps/step3_env.ps +++ b/ps/step3_env.ps @@ -88,7 +88,8 @@ end } def (*) { dup 0 _nth exch 1 _nth mul } _ref (/) { dup 0 _nth exch 1 _nth idiv } _ref -{ % loop +% repl loop +{ %loop (user> ) _readline not { exit } if % exit if EOF diff --git a/ps/step4_if_fn_do.ps b/ps/step4_if_fn_do.ps index b01c594..9e628b6 100644 --- a/ps/step4_if_fn_do.ps +++ b/ps/step4_if_fn_do.ps @@ -113,13 +113,14 @@ end } def /REP { READ repl_env EVAL PRINT } def % core.ps: defined using postscript -/_ref { _function repl_env 3 1 roll env_set pop } def -core_ns { _ref } forall +/_ref { repl_env 3 1 roll env_set pop } def +core_ns { _function _ref } forall % core.mal: defined using the language itself (\(def! not \(fn* \(a\) \(if a false true\)\)\)) RE pop -{ % loop +% repl loop +{ %loop (user> ) _readline not { exit } if % exit if EOF diff --git a/ps/step5_tco.ps b/ps/step5_tco.ps index 50bcdbf..c1698d6 100644 --- a/ps/step5_tco.ps +++ b/ps/step5_tco.ps @@ -123,13 +123,14 @@ end } def /REP { READ repl_env EVAL PRINT } def % core.ps: defined using postscript -/_ref { _function repl_env 3 1 roll env_set pop } def -core_ns { _ref } forall +/_ref { repl_env 3 1 roll env_set pop } def +core_ns { _function _ref } forall % core.mal: defined using the language itself (\(def! not \(fn* \(a\) \(if a false true\)\)\)) RE pop -{ % loop +% repl loop +{ %loop (user> ) _readline not { exit } if % exit if EOF diff --git a/ps/step6_file.ps b/ps/step6_file.ps index faa7101..00598be 100644 --- a/ps/step6_file.ps +++ b/ps/step6_file.ps @@ -123,9 +123,10 @@ end } def /REP { READ repl_env EVAL PRINT } def % core.ps: defined using postscript -/_ref { _function repl_env 3 1 roll env_set pop } def -core_ns { _ref } forall -(eval) { 0 _nth repl_env EVAL } _ref +/_ref { repl_env 3 1 roll env_set pop } def +core_ns { _function _ref } forall +(eval) { 0 _nth repl_env EVAL } _function _ref +(*ARGV*) [ ] _list_from_array _ref % core.mal: defined using the language itself (\(def! not \(fn* \(a\) \(if a false true\)\)\)) RE pop @@ -133,13 +134,16 @@ core_ns { _ref } forall userdict /ARGUMENTS known { %if command line arguments ARGUMENTS length 0 gt { %if more than 0 arguments - ARGUMENTS { - (\(load-file ") exch ("\)) concatenate concatenate RE pop - } forall + (*ARGV*) ARGUMENTS 1 ARGUMENTS length 1 sub getinterval + _list_from_array _ref + ARGUMENTS 0 get + (\(load-file ") exch ("\)) concatenate concatenate RE pop quit } if } if -{ % loop + +% repl loop +{ %loop (user> ) _readline not { exit } if % exit if EOF diff --git a/ps/step7_quote.ps b/ps/step7_quote.ps index 93bf464..10c8089 100644 --- a/ps/step7_quote.ps +++ b/ps/step7_quote.ps @@ -155,9 +155,10 @@ end } def /REP { READ repl_env EVAL PRINT } def % core.ps: defined using postscript -/_ref { _function repl_env 3 1 roll env_set pop } def -core_ns { _ref } forall -(eval) { 0 _nth repl_env EVAL } _ref +/_ref { repl_env 3 1 roll env_set pop } def +core_ns { _function _ref } forall +(eval) { 0 _nth repl_env EVAL } _function _ref +(*ARGV*) [ ] _list_from_array _ref % core.mal: defined using the language itself (\(def! not \(fn* \(a\) \(if a false true\)\)\)) RE pop @@ -165,13 +166,16 @@ core_ns { _ref } forall userdict /ARGUMENTS known { %if command line arguments ARGUMENTS length 0 gt { %if more than 0 arguments - ARGUMENTS { - (\(load-file ") exch ("\)) concatenate concatenate RE pop - } forall + (*ARGV*) ARGUMENTS 1 ARGUMENTS length 1 sub getinterval + _list_from_array _ref + ARGUMENTS 0 get + (\(load-file ") exch ("\)) concatenate concatenate RE pop quit } if } if -{ % loop + +% repl loop +{ %loop (user> ) _readline not { exit } if % exit if EOF diff --git a/ps/step8_macros.ps b/ps/step8_macros.ps index 814b62b..74cf50f 100644 --- a/ps/step8_macros.ps +++ b/ps/step8_macros.ps @@ -197,9 +197,10 @@ end } def /REP { READ repl_env EVAL PRINT } def % core.ps: defined using postscript -/_ref { _function repl_env 3 1 roll env_set pop } def -core_ns { _ref } forall -(eval) { 0 _nth repl_env EVAL } _ref +/_ref { repl_env 3 1 roll env_set pop } def +core_ns { _function _ref } forall +(eval) { 0 _nth repl_env EVAL } _function _ref +(*ARGV*) [ ] _list_from_array _ref % core.mal: defined using the language itself (\(def! not \(fn* \(a\) \(if a false true\)\)\)) RE pop @@ -209,13 +210,16 @@ core_ns { _ref } forall userdict /ARGUMENTS known { %if command line arguments ARGUMENTS length 0 gt { %if more than 0 arguments - ARGUMENTS { - (\(load-file ") exch ("\)) concatenate concatenate RE pop - } forall + (*ARGV*) ARGUMENTS 1 ARGUMENTS length 1 sub getinterval + _list_from_array _ref + ARGUMENTS 0 get + (\(load-file ") exch ("\)) concatenate concatenate RE pop quit } if } if -{ % loop + +% repl loop +{ %loop (user> ) _readline not { exit } if % exit if EOF diff --git a/ps/step9_interop.ps b/ps/step9_interop.ps index e8d837f..4f324d5 100644 --- a/ps/step9_interop.ps +++ b/ps/step9_interop.ps @@ -211,9 +211,10 @@ end } def /REP { READ repl_env EVAL PRINT } def % core.ps: defined using postscript -/_ref { _function repl_env 3 1 roll env_set pop } def -core_ns { _ref } forall -(eval) { 0 _nth repl_env EVAL } _ref +/_ref { repl_env 3 1 roll env_set pop } def +core_ns { _function _ref } forall +(eval) { 0 _nth repl_env EVAL } _function _ref +(*ARGV*) [ ] _list_from_array _ref % core.mal: defined using the language itself (\(def! not \(fn* \(a\) \(if a false true\)\)\)) RE pop @@ -223,13 +224,16 @@ core_ns { _ref } forall userdict /ARGUMENTS known { %if command line arguments ARGUMENTS length 0 gt { %if more than 0 arguments - ARGUMENTS { - (\(load-file ") exch ("\)) concatenate concatenate RE pop - } forall + (*ARGV*) ARGUMENTS 1 ARGUMENTS length 1 sub getinterval + _list_from_array _ref + ARGUMENTS 0 get + (\(load-file ") exch ("\)) concatenate concatenate RE pop quit } if } if -{ % loop + +% repl loop +{ %loop (user> ) _readline not { exit } if % exit if EOF diff --git a/ps/stepA_more.ps b/ps/stepA_more.ps index 73403b0..744a092 100644 --- a/ps/stepA_more.ps +++ b/ps/stepA_more.ps @@ -247,9 +247,10 @@ end } def /REP { READ repl_env EVAL PRINT } def % core.ps: defined using postscript -/_ref { _function repl_env 3 1 roll env_set pop } def -core_ns { _ref } forall -(eval) { 0 _nth repl_env EVAL } _ref +/_ref { repl_env 3 1 roll env_set pop } def +core_ns { _function _ref } forall +(eval) { 0 _nth repl_env EVAL } _function _ref +(*ARGV*) [ ] _list_from_array _ref % core.mal: defined using the language itself (\(def! *host-language* "postscript"\)) RE pop @@ -260,13 +261,17 @@ core_ns { _ref } forall userdict /ARGUMENTS known { %if command line arguments ARGUMENTS length 0 gt { %if more than 0 arguments - ARGUMENTS { - (\(load-file ") exch ("\)) concatenate concatenate RE pop - } forall + (*ARGV*) ARGUMENTS 1 ARGUMENTS length 1 sub getinterval + _list_from_array _ref + ARGUMENTS 0 get + (\(load-file ") exch ("\)) concatenate concatenate RE pop quit } if } if -{ % loop + +% repl loop +(\(println \(str "Mal [" *host-language* "]"\)\)) RE pop +{ %loop (user> ) _readline not { exit } if % exit if EOF |
