aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/standardClient.ey53
-rw-r--r--examples/working-compiler/auto_loop.test3
-rw-r--r--examples/working-compiler/curry-std.test4
-rw-r--r--examples/working-compiler/curry.test25
-rw-r--r--examples/working-compiler/mapping.test27
5 files changed, 111 insertions, 1 deletions
diff --git a/compiler/standardClient.ey b/compiler/standardClient.ey
index 1d55824..cdf2f6f 100644
--- a/compiler/standardClient.ey
+++ b/compiler/standardClient.ey
@@ -525,7 +525,19 @@
invalid # function code
{ [ 1 0 object len 1 sub ] 0 object * typeStackInternal } # array
invalid # function type
- literal # scope
+ {
+ [
+ { object "#*" .? } {
+ object "#in" . ==in
+ in len 1 neq { "multi-input scope in typeStack" die } rep
+ [ 0 in * 0 1 neg ]
+ object "#out" . ==out
+ out len 1 neq { "multi-output scope in typeStack" die } rep
+ 0 out * typeStackInternal
+ }
+ { 1 } literal
+ ] conds
+ } # scope
invalid # name table
unknown
unknown
@@ -784,6 +796,45 @@
> --
> --
+{ _ ==f _ sys .typed .inputs ==inputs
+ sys .typed .outputs ==outputs
+ inputs len 2 lt { f } {
+ { "t from curry should never execute" die }
+ [ inputs len 1 sub inputs * ] outputs '' ==t
+ 0 inputs len 2 sub range reverse { ==i t [ i inputs * ] [ t ] '' =t } each
+ 1 inputs len range reverse { ==i
+ f < =*g { { g }_ } > -- [ i inputs * ] [ t ] '' =f
+ 0 t sys .typed .outputs * =t
+ } each
+ f
+ } ? *
+} /curry deffd
+
+{ | curry } "||" deffd
+{ ==o
+ { "unknown type in **" die } ==:unknown
+ { "invalid type in **" die } ==:invalid
+
+ o sys .typed .type [
+ { o } # integer
+ { o } # string
+ { o } # float
+ unknown
+ invalid # extension area
+ { o * ** } # function
+ invalid # function code
+ { o * ** } # array
+ invalid # function type
+ { o "#*" .? { o * ** } { o } ? * } # scope
+ invalid # name table
+ unknown
+ unknown
+ unknown
+ unknown
+ unknown
+ ] * *
+} "**" deffd
+
# global extensions
<
"0123456789" ==:base10digits
diff --git a/examples/working-compiler/auto_loop.test b/examples/working-compiler/auto_loop.test
new file mode 100644
index 0000000..cdb24a6
--- /dev/null
+++ b/examples/working-compiler/auto_loop.test
@@ -0,0 +1,3 @@
+|not |not add =*f
+0 f dump
+1 f dump
diff --git a/examples/working-compiler/curry-std.test b/examples/working-compiler/curry-std.test
new file mode 100644
index 0000000..28dab30
--- /dev/null
+++ b/examples/working-compiler/curry-std.test
@@ -0,0 +1,4 @@
+3 3 ||add ||add mul * * dump
+||add ||add mul { ** }_ =*m
+
+3 3 m dump
diff --git a/examples/working-compiler/curry.test b/examples/working-compiler/curry.test
new file mode 100644
index 0000000..f641fb0
--- /dev/null
+++ b/examples/working-compiler/curry.test
@@ -0,0 +1,25 @@
+{ _ ==f _ sys .typed .inputs ==inputs
+ sys .typed .outputs ==outputs
+ inputs len 2 lt { f } {
+ { "t from curry should never execute" die }
+ [ inputs len 1 sub inputs * ] outputs '' ==t
+ 0 inputs len 2 sub range reverse { ==i t [ i inputs * ] [ t ] '' =t } each
+ 1 inputs len range reverse { ==i
+ f < =*g { { g }_ } > -- [ i inputs * ] [ t ] '' =f
+ 0 t sys .typed .outputs * =t
+ } each
+ f
+ } ? *
+} /curry deffd
+
+|add curry ==a
+5 5 a * * dump
+
+a sys .typed .inputs dump
+a sys .typed .outputs _ dump 0 -01 * ==b
+b sys .typed .inputs dump
+b sys .typed .outputs _ dump 0 -01 * ==c
+
+3 3 |a |a mul * * dump
+
+# vim: syn=elymas
diff --git a/examples/working-compiler/mapping.test b/examples/working-compiler/mapping.test
new file mode 100644
index 0000000..cf25036
--- /dev/null
+++ b/examples/working-compiler/mapping.test
@@ -0,0 +1,27 @@
+<
+ { .v -01 . } "#*" defmd
+ { -- [ 0 ] } "#in" defmd
+ { -- [ 0 ] } "#out" defmd
+ { .v keys } "#dom" defmd
+ { .v ==v =*f v keys { v -01 . f } each } "#each" defmd
+ { < < { defv }' > ==v "#=[]" =* > }
+> -- /map deffd
+
+map ==m
+
+0 "foo" m =[]
+1 "bar" m =[]
+2 "quux" m =[]
+
+"foo" m * dump
+"bar" m * dump
+"quux" m * dump
+
+m dom dump
+m { dump } each
+
+5 m mul ==mm
+
+"foo" mm * dump
+"bar" mm * dump
+"quux" mm * dump