Anonymous user
Execute Brain****/Elena: Difference between revisions
no edit summary
No edit summary |
No edit summary |
||
Line 1:
<lang elena>
class BFTape
{
Line 11:
object thePointer.
object theBrackets.
constructor new:aLength
[
theArray := Array new:aLength;
thePointer := Integer new:0.
theBrackets := Stack new.
]
append
[
]
reduce
[
]
next
[
thePointer
]
previous
[
thePointer
]
push : bookmark
[
theBrackets push:bookmark.
]
pop
=> theBrackets.
input
[
theArray
]
output
[
console write
]
check = theArray
}
const bf_program =
program =
[
console
writeLine:bf_program.
writeLine:"++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.".▼
var program := scriptEngine
load
eval:bf_program.
▲ eval:"++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.".
program eval:(BFTape new:1024).
].</lang>
The grammar:
<lang elena>[[
#grammar transform
#grammar cf
#define start ::= <= ( > += " 2" += " %""system'dynamic'tapeOp.
#define commands ::= command commands;
Line 91 ⟶ 92:
#define command ::= <= += " %""append[0]"" " => "+";
#define command ::= <= += " %""reduce[0]"" " => "-";
#define command ::= <= += " -2" += " %""system'dynamic'tapeOp.
#define command ::= <= += " 0" += " %""system'dynamic'tapeOp.tape_stack[]"" " += " %""check[0]"" " += " 1" += " %""system'dynamic'tapeOp.
▲ %""system'dynamic'tapeOp.stack&args$[]"" " += " %""pop[0]"" " += " %""system'dynamic'tapeOp.jumpif&args$[13]"" " => "]";
#define comment ::= " " comments;
Line 105 ⟶ 104:
#mode symbolic;
]]</lang>
{{out}}
<pre>
ELENA VM 3.2.15 (C)2005-2017 by Alex Rakov
Initializing...
Debug mode...
Done...
▲
Hello World!
</pre>
|