Execute Brain****/Lua: Difference between revisions

m
Fixed syntax highlighting.
(Fixed bracket matching and made them a bit more robust.)
m (Fixed syntax highlighting.)
 
(2 intermediate revisions by 2 users not shown)
Line 2:
 
An implementation of a Brainf*** interpreter in [[Lua]].
<langsyntaxhighlight lang="lua">memory = {0} --memory is bounded on one side, at 1
 
program = io.read("*all") --loads an entire program at once, must not contain newlines
 
pointer = 1
Line 36:
if program:sub(instruction, instruction) == "[" then
b = b + 1
elseif program:sub(instruction, instruction) == "]" then
b = b - 1
end
Line 66:
if instr then instr() end
instruction = instruction + 1
end</langsyntaxhighlight>
9,476

edits