diff options
| author | Drahflow <drahflow@gmx.de> | 2012-12-09 22:13:32 +0100 |
|---|---|---|
| committer | Drahflow <drahflow@gmx.de> | 2012-12-09 22:13:32 +0100 |
| commit | 9de23daca3f223643eb4d0f92636d72d0f5c9364 (patch) | |
| tree | befc76bcf7bb68b3d85fec3387187dee99208147 /examples | |
| parent | 651f0712cc1349ae152ee6a93302f22c25f89b43 (diff) | |
The dark magic unfolds
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/non-working/macro.ey | 55 | ||||
| -rw-r--r-- | examples/working/exec.ey | 2 | ||||
| -rw-r--r-- | examples/working/fold.ey | 2 | ||||
| -rw-r--r-- | examples/working/string.ey | 4 |
4 files changed, 55 insertions, 8 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 } * diff --git a/examples/working/exec.ey b/examples/working/exec.ey index 3d67793..a88ccae 100644 --- a/examples/working/exec.ey +++ b/examples/working/exec.ey @@ -1,4 +1,4 @@ #!/usr/bin/env elymas 1 1 |dump *0 add dump -4 { 1 add } 3 rep dump +4 3 { 1 add } rep dump diff --git a/examples/working/fold.ey b/examples/working/fold.ey index 4cae734..fd42f11 100644 --- a/examples/working/fold.ey +++ b/examples/working/fold.ey @@ -6,7 +6,7 @@ ? * } /fold deff -{ =f _ len =l l dearray f l 1 sub rep } /foldshort deff +{ =f _ len =l l dearray l 1 sub f rep } /foldshort deff { =f { f fold } } /enfold deff diff --git a/examples/working/string.ey b/examples/working/string.ey new file mode 100644 index 0000000..1174e14 --- /dev/null +++ b/examples/working/string.ey @@ -0,0 +1,4 @@ +"test" dump +"a\nb" dump +"a\\b" dump +"a\"b" dump |
