You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 25, 2019. It is now read-only.
// find the corresponding closing bracket, move the ip to it
74
+
loop{
75
+
ins_ptr += 1;
76
+
if instructions[ins_ptr] == '['{
77
+
balance += 1
78
+
}elseif instructions[ins_ptr] == ']'{
79
+
balance -= 1
80
+
}
81
+
if balance == 0{break}
75
82
}
76
83
}
77
-
continue
78
84
},
79
85
']' => {
80
86
if tape[mem_ptr] == 0x00{
81
-
// move back to just before the matching open bracket
82
-
while instructions[ins_ptr] != '['{
83
-
ins_ptr -= 1
87
+
letmut balance = 1;
88
+
// find the corresponding opening bracket, move the ip just before it
89
+
loop{
90
+
if instructions[ins_ptr] == '['{
91
+
balance += 1
92
+
}elseif instructions[ins_ptr] == ']'{
93
+
balance -= 1
94
+
}
95
+
ins_ptr -= 1;
96
+
if balance == 0{break}
84
97
}
85
-
ins_ptr -= 1
86
98
}
87
-
continue
88
99
}
100
+
_ => unreachable!(),
89
101
}
90
102
ins_ptr += 1
91
103
}
92
104
}
93
105
94
106
fnmain(){
95
-
// TODO
107
+
// Just a test, doesn't seem to be working just yet
108
+
let code = "\"?'\"........'\",;;....\";.;.;.;..;...\"-'\";,\";;;.;.;.'\"-'\"--\";;;;.;....;!;,,,!.......!!'\",;.;.--'\";...!---!--!;;;;....'\",-....;'\"-,!;;!...!;!,,,,,,,,!-----!".to_string();
0 commit comments