blob: c98462e15e9f436c0b150a7c6301fb72eafc6093 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
⎕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'
|