Anonymous user
Execute Brain****/Elena: Difference between revisions
no edit summary
No edit summary |
No edit summary |
||
Line 7:
#import extensions'scripting.
▲#class BFTape
{
[
theArray := Array new:aLength set &every: (&int:n) [ Integer new:0 ].
Line 24 ⟶ 22:
]
[
(theArray@thePointer) += 1.
]
[
(theArray@thePointer) -= 1.
]
[
thePointer += 1.
]
[
thePointer -= 1.
]
[
theBrackets push:bookmark.
]
=> theBrackets.
[
theArray@thePointer := console readChar toInt.
]
[
console write:((theArray@thePointer) toChar).
]
}
[
console
writeLine:"++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.".
load &path:"rules.es"
eval:"++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.".
Line 78 ⟶ 76:
The grammar:
<lang elena>[[
[[
#grammar transform
#grammar cf
#define start ::= <=
#define commands ::= command commands;
Line 86:
#define commands ::= $eof;
#define command ::= <= += " %""output[0]"" " => ".";
#define command ::= <= += " %""input[0]"" " => ",";
#define command ::= <= += " %""previous[0]"" " => "<";
#define command ::= <= += " %""next[0]"" " => ">";
#define command ::= <= += " %""append[0]"" " => "+";
#define command ::= <= += " %""reduce[0]"" " => "-";
#define command ::= <= += " -2" += " %""system'dynamic'tapeOp.ptr&args$[]"" " += " 1" += " %""system'dynamic'tapeOp.stack&args$[]"
+= "%""push[1]"" " => "[";
#define command ::= <= 0 %"system'dynamic'tapeOp.stack&args$[]" %"check[0]" 1 %"system'dynamic'tapeOp.stack&args$[]" %"pop[0]" %"system'dynamic'tapeOp.jumpif&args$[13]" => "]";▼
#define command ::= <= += " 0" += " %""system'dynamic'tapeOp.stack&args$[]"" " += " %""check[0]"" " += " 1" += "
▲
#define comment ::= " " comments;
Line 104 ⟶ 106:
#mode symbolic;
]]
]]</lang>
|