Execute Brain****/C++: Difference between revisions

m
Fixed syntax highlighting.
m (RCBF moved to RCBF (C++): Language-specific page title)
m (Fixed syntax highlighting.)
 
(18 intermediate revisions by 9 users not shown)
Line 1:
{{implementation|Brainf***}}{{collection|RCBF}}
{{implementation|Brainf***}}RCBFThis is an implementation of [[Brainf***]] originally written in [[C++]] by [[User:Short Circuit|Mike Mol]] and [[User:Mwn3d|Mike Neurohr]], for Rosetta Code. It is licensed under the same license as Rosetta Code itself.
 
It may be fed BF instructions either through standard input (i.e. terminal keyboard input), or through a file named as the first command-line argument.
 
RCBF is intended for educational purposes only; There is no guarantee it won't lock up your computer. (Though Mike M thinks he's got that bug ironed out...) (We'll no it wasn't, but it should be now -- RdB)
 
{{works with|g++|4.1.3}}
It has been tested using the following compilers/library combinations:
* [[g++]] 4.1.3 withplus the GNU C++ Standard Library
<presyntaxhighlight lang="cpp">// RCBF -- A free Brainfuck interpreter written for Rosetta Code (http://rosettacode.org)
 
<pre>// RCBF -- A free Brainfuck interpreter written for Rosetta Code (http://rosettacode.org)
// Created by Mike Mol and Mike Neurohr, and under the same license as Rosetta Code.
// Repaired by Robert de Bath -- but Ghods is it slow!
 
// Test with this Hello World, it breaks BF interpreters
// >++++++++[<+++++++++>-]<.>>+>+>++>[-]+<[>[->+<<++++>]<<]>.+++++++..+++.>
// >+++++++.<<<[[-]<[-]>]<+++++++++++++++.>>.+++.------.--------.>>+.>++++.
 
#include <list>
Line 239 ⟶ 244:
int input(memptr_t &ptr)
{
cin >> *ptr = cin.get();
 
if ( cin.eof() )
// Someone closed our input stream. We should exit.
return CLOSE;
 
return SUCCESS;
}
Line 345:
codeptr_t tmppos = code.end();
rec.open = --tmppos;
rec.close = rec.open;
 
// Because we always encounter forward jumps before back jumps,
Line 394 ⟶ 395:
// We never found a close branch
return BRANCH_NOT_FOUND;
}</presyntaxhighlight>
9,476

edits