fabianishere / brainfuck Goto Github PK
View Code? Open in Web Editor NEWBrainfuck interpreter written in C
License: Apache License 2.0
Brainfuck interpreter written in C
License: Apache License 2.0
It would be nice if piped content was supported:
echo '.+[.+] prints out all ASCII characters' | brainfuck -c
# Other example: concatenate two brainfuck programs and execute them
cat file1 file2 | brainfuck -c
# Other example: minify brainfuck code using brnfckr and pass the result to `brainfuck` directly
brnfckr '.+[.+] prints out all ASCII characters' | brainfuck -c
Currently, this gives the following error:
error: no code specified!
there are extensions for brainfuck, would be glad to have it.
Hello. When I try to make the program, an error shows that editline/readline/h does not exist.
[ 40%] Built target libbrainfuck_static [ 60%] Building C object CMakeFiles/brainfuck.dir/src/main.c.o /media/sebastian/UUI/sml/Coding/BF/brainfuck/src/main.c:24:11: fatal error: editline/readline.h: No such file or directory #include <editline/readline.h> ^~~~~~~~~~~~~~~~~~~~~ compilation terminated. CMakeFiles/brainfuck.dir/build.make:62: recipe for target 'CMakeFiles/brainfuck.dir/src/main.c.o' failed make[2]: *** [CMakeFiles/brainfuck.dir/src/main.c.o] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/brainfuck.dir/all' failed make[1]: *** [CMakeFiles/brainfuck.dir/all] Error 2
I have libedit in a directory in my home directory, and I have the dependencies required for that as well. Am I doing something wrong?
Code is currently not compilable due to debris left behind by diff3(1)
For example:
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef BRAINFUCK_H
#define BRAINFUCK_H
<<<<<<< HEAD
#define BRAINFUCK_VERSION "2.3"
=======
#define BRAINFUCK_VERSION "2.4"
>>>>>>> f3fdf57cc86182aacc89de87f2d5f7827dbf6d0f
#define BRAINFUCK_CELL_TYPE int
#define BRAINFUCK_TAPE_SIZE 30000
#define BRAINFUCK_TOKEN_PLUS '+'
#define BRAINFUCK_TOKEN_MINUS '-'
#define BRAINFUCK_TOKEN_PREVIOUS '<'
#define BRAINFUCK_TOKEN_NEXT '>'
#define BRAINFUCK_TOKEN_OUTPUT '.'
brainfuck -h
says "run code directly" for the -v --version
entry
This is the error message I get:
~/Github/brainfuck/build$
cmake ..
CMake Error at /home/.../.local/lib/python3.10/site-packages/cmake/data/share/cmake-3.26/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find editline (missing: EDITLINE_INCLUDE_DIR EDITLINE_LIBRARY)
Call Stack (most recent call first):
/home/stefggl/.local/lib/python3.10/site-packages/cmake/data/share/cmake-3.26/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
cmake/Findeditline.cmake:31 (find_package_handle_standard_args)
CMakeLists.txt:52 (find_package)
-- Configuring incomplete, errors occurred!
cmake is version 3.26.4
Ubuntu 22.04 machine
Lines 565 to 570 in 71c0e0c
If we trust this repository, it's not like that in the original.
https://gist.github.com/rdebath/0ca09ec0fdcf3f82478f#file-bfi-c-L19
We should be able to support other Brainfuck dialects like Ook! and Blub.
Regardless of whether you are running a program from file or using direct input, the first character is always ignored. i.e. The ASCII value for '!' is 32, so theoretically the following program should output the character '!'
++++++++++++++++++++++++++++++++.
But instead outputs the character with the ASCII value of 31, even though '+' is written 32 times. Adding an extra '+' prints out an '!', but this is incorrect behaviour.
make all CC=cc CCFLAGS=
Building
mkdir -p bin
cc -o /private/tmp/brainfuck-9gd5/brainfuck-0.1.2/bin/brainfuck /private/tmp/brainfuck-9gd5/brainfuck-0.1.2/src/*
clang: error: cannot specify -o when generating multiple output files
make: *** [all] Error 1
The project now requires the libedit
library to be installed in order to build the command line interface.
We should have a build option to disable the interactive console, so people can build the command line interface without needing the libedit
library if they are not interested in the interactive console.
Faced this issue while installing brainfuck in ubuntu x86_64 at this step
cmake ..
Output :
Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
CMake Error at CMakeLists.txt:29 (message):
Doxygen is needed to build the documentation.
Provide an optional Just-in-time compilation that dynamically translates the instructions into x86-64 instructions.
Please consider tagging a stable release (e.g. 0.1.0
) so that this can be added on Homebrew. Thank you!
I'm on MAC with OSX Yosémite v10.10.3
$> ./brainfuck -m
Segmentation fault: 11
$>
Currently, there’s brainfuck [file]
for files, and brainfuck -i
for interactive mode.
How about adding -c
| --code
which take direct input as strings?
E.g.
$ brainfuck -c '.+[.+]'
…
I get the following error message:
[ 33%] Built target brainfuck
Scanning dependencies of target brainfuck-cli
make[2]: Warning: File 'CMakeFiles/brainfuck-cli.dir/depend.make' has modification time 0.77 s in the future
[ 50%] Building C object CMakeFiles/brainfuck-cli.dir/src/main.c.o
/mnt/c/GitRepos/brainfuck/src/main.c:23: warning: "BRAINFUCK_EDITLINE_LIB" redefined
23 | #define BRAINFUCK_EDITLINE_LIB
|
<command-line>: note: this is the location of the previous definition
/mnt/c/GitRepos/brainfuck/src/main.c:24:11: fatal error: editline/readline.h: No such file or directory
24 | #include <editline/readline.h>
| ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/brainfuck-cli.dir/build.make:63: CMakeFiles/brainfuck-cli.dir/src/main.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:126: CMakeFiles/brainfuck-cli.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
I am following the readme guide. And I get the error both in on MinGW on windows and in WSL.
If I'm the one doing something wrong, then please tell me what.
Thanks in advance.
brainfuck.c:23:10: fatal error: brainfuck.h: No suck file or directory
main.c::34:10: fatal error: brainfuck.h: No such file or directory
It seems that you need to include the full directory path
Edit: follow the steps in https://github.com/fabianishere/brainfuck#building
I've run into some issue when playing with bf using this interpreter. Below is the simplest test case I was able to make, that show the problem:
>
><<
$ echo ">\n><<" | brainfuck
error: tape memory out of bounds (overrun)
exceeded the tape size of 30000 cells
$ echo $?
1
If we add single space between >
and <
then problem disappears:
>
> <<
$ echo ">\n> <<" | brainfuck
$ echo $?
0
The API currently includes the function brainfuck_execute
, but there is no way to stop the execution. This means that code that includes infinite loops will execute forever. Worse, if this API is used in code (i.e in a tool that interprets BF) this provides a plethora of opportunities for your application to crash.
This issue is concerned with adding support for automated testing. Test automation provides the benefit of automatically checking for breaking changes when adding features or refactoring parts of the code. In addition, we can also add automated tests for parts of the code that are often forgotten when running manual tests.
I propose we use the builtin testing functionality of CMake - CTest - to drive our tests.
Hey, wanting to use this for a project, could you throw a license in the repo? :)
Thanks
The readme for this project shows the usage guidelines ...
Usage
brainfuck [-ch] <filenames> -e run code directly -h show a help message.
... but is unclear as to whether -c
or -e
is actually the option for running code directly. This could be figured out really quickly by running the program, but I think it'd be beneficial from making the command-line options more unambiguous.
brainfuck_insert_before()
will create a circular list and memory leak in the instruction list it operates on. The cause is initializing next
(line #176) after setting after->next
to instruction
(line #173), so that next
refers to the list to be inserted, rather than the original tail (which is leaked).
This issue is concerned with adding support for automatic packaging of the interpreter for various operating systems/distributions.
We should be able to build on some Travis machines to check whether the master still builds before merging a pull request.
So , I got the interpreter working but just letting you know about this bug.
my software specs:
OS: Arch Linux
KDE Plasma Version: 5.10.5
KDE Frameworks Version: 5.37.0
Qt Version: 5.9.1
Kernel Version: 4.12.8-2-ARCH
OS Type: 64-bit
------------------------------------------------------------
COMPILER
------------------------------------------------------------
gcc (GCC) 7.1.1 20170630
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--------------
LIBEDIT
--------------
libedit 20170329_3.1-1 [installed]
When I compiled it shot with a include error ,
fatal error: editline/history.h: No such file or directory
#include <editline/history.h>
^~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/brainfuck.dir/build.make:63: CMakeFiles/brainfuck.dir/src/main.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:68: CMakeFiles/brainfuck.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
So what I did was comment this line in src/main.c
#ifdef BRAINFUCK_EDITLINE_LIB
#include <editline/readline.h>
/*
* This line caused the compile error , even if it is not mac
* I think , We don't need to include editline/history.h when
* We already included editline/readline.h
#ifndef __APPLE__
#include <editline/history.h>
#endif
*/
#endif
After editing this , I compiled successfully!
is this intensional?......
just reporting!
It would be nice to have a make install
option available from cmake (an make install
option also appears to be a prerequisite for getting merged into the homebrew repos Homebrew/homebrew-core#17230 (comment)).
Is Windows supported ? Can you create a compiler fonctionality with this command scheme : brainfuck <INPUT_FILE_PATH> -o <OUTPUT_FILE_PATH>
? And can you create a distribuable installer in .exe
for Windows (if Windows is supported), .deb
/.rpm
for Linux and .dmg
for macOS ?
[ 33%] Built target brainfuck
[ 50%] Building C object CMakeFiles/brainfuck-cli.dir/src/main.c.o
/home/romario/super-ia-project/bfinterpreter2/src/main.c:23:11: fatal error: editline/readline.h: No such file or directory
#include <editline/readline.h>
^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/brainfuck-cli.dir/build.make:62: recipe for target 'CMakeFiles/brainfuck-cli.dir/src/main.c.o' failed
make[2]: *** [CMakeFiles/brainfuck-cli.dir/src/main.c.o] Error 1
CMakeFiles/Makefile2:904: recipe for target 'CMakeFiles/brainfuck-cli.dir/all' failed
make[1]: *** [CMakeFiles/brainfuck-cli.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
We should add a CMake option to build a shared library for the project.
I'm not sure if this intentional but the interpreter disallows basically any sort of cursor movement, like that with the arrow keys or emacs-like Ctrl-e/Ctrl-a type of stuff. When I try to to for example move my cursor to the right some escape sequence appears on the prompt instead. Any fix on my side or a rationale behind the choice to disable cursor movement ? (macOS 10.12 + iTerm)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.