diff options
Diffstat (limited to 'runtime/start.apl')
-rw-r--r-- | runtime/start.apl | 54 |
1 files changed, 40 insertions, 14 deletions
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 |