Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -4,21 +4,21 @@
|
|||
;
|
||||
|
||||
Tape: [0]
|
||||
DataPointer: new 0
|
||||
InstructionPointer: new 0
|
||||
DataPointer: 0
|
||||
InstructionPointer: 0
|
||||
|
||||
; Look for jumps in Code an register them
|
||||
; in the Jumps table
|
||||
|
||||
precomputeJumps: function [][
|
||||
vstack: new []
|
||||
jumphash: new #[]
|
||||
vstack: []
|
||||
jumphash: #[]
|
||||
instrPointer: 0
|
||||
|
||||
while [instrPointer<CodeLength] [
|
||||
command: get split Code instrPointer
|
||||
if? command="[" -> 'vstack ++ instrPointer
|
||||
else [
|
||||
switch command="[" -> 'vstack ++ instrPointer
|
||||
[
|
||||
if command="]" [
|
||||
target: last vstack
|
||||
chop 'vstack
|
||||
|
|
@ -47,36 +47,37 @@ StateIsValid: function [][
|
|||
interpret: function [].export:[DataPointer,InstructionPointer,Tape][
|
||||
while [StateIsValid][
|
||||
command: get split Code InstructionPointer
|
||||
case [command=]
|
||||
when? ["+"] -> Tape\[DataPointer]: Tape\[DataPointer]+1
|
||||
when? ["-"] -> Tape\[DataPointer]: Tape\[DataPointer]-1
|
||||
when? [">"] [
|
||||
case command [
|
||||
"+" -> Tape\[DataPointer]: Tape\[DataPointer]+1
|
||||
"-" -> Tape\[DataPointer]: Tape\[DataPointer]-1
|
||||
">" [
|
||||
inc 'DataPointer
|
||||
if DataPointer = size Tape -> Tape: Tape ++ 0
|
||||
]
|
||||
when? ["<"] -> dec 'DataPointer
|
||||
when? ["."] -> prints to :string to :char Tape\[DataPointer]
|
||||
when? [","][
|
||||
"<" -> dec 'DataPointer
|
||||
"." -> prints to :string to :char Tape\[DataPointer]
|
||||
"," [
|
||||
inp: to :integer input ""
|
||||
if inp=13 -> inp: 10
|
||||
if inp=3 -> panic "something went wrong!"
|
||||
set Tape DataPointer inp
|
||||
]
|
||||
when? ["["] ->
|
||||
if 0 = get Tape DataPointer [ InstructionPointer: new get Jumps InstructionPointer ]
|
||||
"[" ->
|
||||
if 0 = get Tape DataPointer [ InstructionPointer: new Jumps\[InstructionPointer] ]
|
||||
|
||||
when? ["]"] ->
|
||||
"]" ->
|
||||
if 0 <> get Tape DataPointer [
|
||||
InstructionPointer: new get Jumps InstructionPointer
|
||||
InstructionPointer: new Jumps\[InstructionPointer]
|
||||
]
|
||||
]
|
||||
|
||||
inc 'InstructionPointer
|
||||
]
|
||||
]
|
||||
|
||||
Code: ""
|
||||
if? 1>size arg -> Code: "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>."
|
||||
else -> Code: read arg\0
|
||||
switch 1>size arg -> Code: "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>."
|
||||
-> Code: read arg\0
|
||||
|
||||
CodeLength: size Code
|
||||
Jumps: precomputeJumps
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue