aboutsummaryrefslogtreecommitdiff
path: root/examples/non-working
diff options
context:
space:
mode:
authorDrahflow <drahflow@gmx.de>2012-12-09 22:13:32 +0100
committerDrahflow <drahflow@gmx.de>2012-12-09 22:13:32 +0100
commit9de23daca3f223643eb4d0f92636d72d0f5c9364 (patch)
treebefc76bcf7bb68b3d85fec3387187dee99208147 /examples/non-working
parent651f0712cc1349ae152ee6a93302f22c25f89b43 (diff)
The dark magic unfolds
Diffstat (limited to 'examples/non-working')
-rw-r--r--examples/non-working/macro.ey55
1 files changed, 49 insertions, 6 deletions
diff --git a/examples/non-working/macro.ey b/examples/non-working/macro.ey
index 9ead477..fdaf0cf 100644
--- a/examples/non-working/macro.ey
+++ b/examples/non-working/macro.ey
@@ -1,8 +1,51 @@
-{ * } /now defq
+# an alternative to }, moving the top stack element
+# into closure storage and pushing it back before
+# executing the block
-{ { 1 2 3 add add } now } /f deff
-f dump
+{ "}" | *
+ { /f deff /x defv
+ { x f }
+ } quoted { } { * } ? *
+} "}0" defq
-{ blk 0 -01 * sym die } /qdie defq
-{ code die } /qcode defq
-{ f qcode }
+5 { { dump }0 } * /dumpfive deff
+5 { dump }0 /dumpfivetwo deff
+
+7 dumpfive -
+7 dumpfivetwo -
+
+
+# import members of other objects into local scope
+
+{
+ "_" | "-021" | ".|" | "-01" | |deff
+} /usef defq
+
+
+# codewalker
+
+{ "lol" dump } /lol deff
+
+{
+ 1 /cont defv
+
+ { cont } { 0 {
+ exe /walkelem deff
+ { sys .out .writestr } /out deff
+
+ _ { { " " out } rep }0 /indent deff
+ { 2 add walkelem }0 /walk deff
+
+ _ code [ {
+ indent [ "\"" -102 "\"\n" ] |out each
+ } {
+ indent _ sym _ out
+ "{" streq { 0 =cont |lol } { - } ? *
+ "\n" out
+ } {
+ blk |walk each
+ } ] * *
+ } * } loop
+} /codewalk defq
+
+{ f "t" g h { a b { c d } e } codewalk } *