summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/start.apl54
-rw-r--r--runtime/stdlib.apl8
2 files changed, 48 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
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