blob: d65d0bc80497526a9fb7cd06376d1f91ad27721a (
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
42
43
44
45
46
47
48
49
50
51
52
53
|
⎕session←{
(indented main prompt)←⍵
⎕rawio←'Welcome to APL9',(⎕ucs 10),prompt
indented←≢prompt
unindent←{
⎕rawio←⎕ucs ⍺⍴8
}
handleMain←{
0::⍺
data←⍵
⎕rawio←data
⎕rawio←⎕ucs 10
⎕rawio←prompt
≢prompt
}
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
indented←indented×task≡main
type≡'→': indented handleMain data
type≡'!': indented handleError task data
type≡'⎕': indented handleQuad data
type≡'⍞': indented handleQuoteQuad data
⍵
}
{∇ ⍵ handle {1 ⍵}⍇⍬} indented
}&'session'⊢0 ⎕self (6⍴' ')
|