Skip to content

Commit

Permalink
Update interpreter.osl
Browse files Browse the repository at this point in the history
  • Loading branch information
Mistium authored Jul 23, 2024
1 parent 29f2a28 commit aa67b94
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions 3rd Party/3rdPartyLanguages/BrainFuck/interpreter.osl
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
code = "Code".ask
memory = "Array".new(3000)
code = "Code".ask()
memory = 3000.newArray()
pointer = 1
input_buffer = ""
output_buffer = ""

count = 0

loop code.len (
count += 1
run_c = code.[count]
count ++
run_c = code[count]

if run_c == ">" "pointer += 1"
if run_c == "<" "pointer -= 1"
if run_c == "+" "memory.[pointer] += 1"
if run_c == "-" "memory.[pointer] -= 1"
if run_c == "." (
output_buffer = output_buffer ++ memory.[pointer].from("unicode")
output_buffer = output_buffer ++ memory[pointer].from("unicode")
)
if run_c == "," (
memory.[pointer] = "Input a Character".ask.to("unicode")
memory[pointer] = "Input a Character".ask.to("unicode")
)
if run_c == "[" and ( pointer == 0 ) (
if run_c == "[" and (pointer == 0) (
count += code.trim(count, 99999999).index("]")
)
if run_c == "]" and ( memory.[pointer] != 0 ) (
if run_c == "]" and (memory.[pointer] != 0) (
data = code.len - count
count -= code.reverse.trim(data, 99999999).index("[") + 1
)
Expand Down

0 comments on commit aa67b94

Please sign in to comment.