new var declaration syntax
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
func main[] : i64
|
||||
// https://brainfuck.org/sierpinski.b
|
||||
let src = "++++++++[>+>++++<<-]>++>>+<[-[>>+<<-]+>>]>+[-<<<[->[+[-]+>++>>>-<<]<[<]>>++++++[<<+++++>>-]+<<++.[-]<<]>.>+[>>]>+]"
|
||||
let src_len = str.len(src)
|
||||
let i = 0
|
||||
src := "++++++++[>+>++++<<-]>++>>+<[-[>>+<<-]+>>]>+[-<<<[->[+[-]+>++>>>-<<]<[<]>>++++++[<<+++++>>-]+<<++.[-]<<]>.>+[>>]>+]"
|
||||
src_len := str.len(src)
|
||||
i := 0
|
||||
|
||||
let memory = mem.alloc(30000)
|
||||
memory := mem.alloc(30000)
|
||||
mem.zero(memory, 30000)
|
||||
let p = 0
|
||||
p := 0
|
||||
|
||||
while i < src_len
|
||||
let op = src[i]
|
||||
op := src[i]
|
||||
|
||||
if op == '>'
|
||||
p = p + 1
|
||||
@@ -26,7 +26,7 @@ func main[] : i64
|
||||
else if op == '['
|
||||
if !memory[p]
|
||||
i = i + 1
|
||||
let opened = 0
|
||||
opened := 0
|
||||
while i < src_len && !(src[i] == ']' && !opened)
|
||||
if src[i] == '['
|
||||
opened = opened + 1
|
||||
@@ -36,7 +36,7 @@ func main[] : i64
|
||||
else if op == ']'
|
||||
if memory[p]
|
||||
i = i - 1
|
||||
let closed = 0
|
||||
closed := 0
|
||||
while i >= 0 && !(src[i] == '[' && !closed)
|
||||
if src[i] == ']'
|
||||
closed = closed + 1
|
||||
|
||||
Reference in New Issue
Block a user