From e2ebfbb7d19ff3b990eb51dc9843200053cbbf98 Mon Sep 17 00:00:00 2001 From: glenda Date: Sat, 10 Sep 2022 16:25:05 +0000 Subject: Improve the session a lot --- runtime/start.apl | 54 ++++++++++++++++++++++++++++++++++++++++-------------- runtime/stdlib.apl | 8 ++++++++ 2 files changed, 48 insertions(+), 14 deletions(-) create mode 100644 runtime/stdlib.apl (limited to 'runtime') diff --git a/runtime/start.apl b/runtime/start.apl index 46a0703..c98462e 100644 --- a/runtime/start.apl +++ b/runtime/start.apl @@ -1,15 +1,41 @@ -send←⍈ ⍝ I can't type those easily so give them names -recv←⍇ -prompt←6⍴' ' -session←{ - (task data)←{1 ⍵} recv ⍬ - ⎕rawio←{¯1≡⍵:'???:' ⋄ ⍵,':'} task ⎕tasks 1 - ⎕rawio←data - ⍞rawio←prompt - ∇⍵ -} - +⎕session←{ + (indented main prompt)←⍵ + unindent←{ + ⎕rawio←⎕ucs ⍺⍴8 + } + handleError←{ + 0::⍺ + (task (error msg taskname))←⍵ + ⎕rawio←error,' in [',(⍕task),':',taskname,']' + _←{⎕rawio←': ', msg} IF msg≢'' + ⎕rawio←⎕ucs 10 + ⎕rawio←prompt + ≢prompt + } + handleQuad←{ + 0::⍺ + data←⍵ + ⎕rawio←data + ⎕rawio←⎕ucs 10 + ⎕rawio←prompt + ≢prompt + } + handleQuoteQuad←{ + 0::⍺ + data←⍵ + ⎕rawio←data + ⍺ + } + handle←{ + 0::⍺ + (task (type data))←⍵ + indented←⍺ + _←indented∘unindent IF (indented>0)∧task≢main + type≡'!': 0 handleError task data + type≡'⎕': 0 handleQuad data + type≡'⍞': 0 handleQuoteQuad data + ⍵ + } + {∇ ⍵ handle {1 ⍵}⍇⍬} indented +}&'session'⊢0 ⎕self (6⍴' ') ⎕←'Welcome to APL9' -⍞rawio←prompt - -⎕session←session&'session'⊢⍬ \ No newline at end of file diff --git a/runtime/stdlib.apl b/runtime/stdlib.apl new file mode 100644 index 0000000..24b7e5e --- /dev/null +++ b/runtime/stdlib.apl @@ -0,0 +1,8 @@ +⍝ All things in here have global scope and can be changed at any time +SEND←⍈ +RECV←⍇ + +IF←{ + ⍵:⍶ ⍬ + ⍬ +} \ No newline at end of file -- cgit v1.2.3