PageRenderTime 42ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/README.md

http://github.com/FabianM/Brainfuck
Markdown | 80 lines | 69 code | 11 blank | 0 comment | 0 complexity | 894eb96c5ab2fe491efda2fcbe310b96 MD5 | raw file
Possible License(s): Apache-2.0
  1. brainfuck
  2. [![Build Status](https://github.com/fabianishere/brainfuck/workflows/Build/badge.svg)](https://github.com/fabianishere/brainfuck/actions?query=workflow%3ABuild)
  3. ===========
  4. Brainfuck interpreter written in C.
  5. ## Usage
  6. brainfuck [-veh] file...
  7. -e --eval run code directly
  8. -v --version show version information
  9. -h --help show a help message.
  10. The interactive console can be accessed by passing no arguments.
  11. We also provide a C api:
  12. ``` c
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <brainfuck.h>
  16. int main() {
  17. BrainfuckState *state = brainfuck_state();
  18. BrainfuckExecutionContext *context = brainfuck_context(BRAINFUCK_TAPE_SIZE);
  19. BrainfuckInstruction *instruction = brainfuck_parse_string(",+++++.");
  20. brainfuck_add(state, instruction);
  21. brainfuck_execute(state->root, context);
  22. brainfuck_destroy_context(context);
  23. brainfuck_destroy_state(state);
  24. return EXIT_SUCCESS;
  25. }
  26. ```
  27. ## Examples
  28. The [examples/](/examples) directory contains a large amount of
  29. brainfuck example programs. We have tried to attribute the original
  30. authors of these programs where possible.
  31. ## Getting the source
  32. Download the source code by running the following code in your command prompt:
  33. ```sh
  34. $ git clone https://github.com/fabianishere/brainfuck.git
  35. ```
  36. or simply [grab](https://github.com/fabianishere/brainfuck/archive/master.zip) a copy of the source code as a Zip file.
  37. ## Building
  38. Create the build directory.
  39. ```sh
  40. $ mkdir build
  41. $ cd build
  42. ```
  43. Brainfuck requires CMake and a C compiler (e.g. Clang or GCC) in order to run. It also depends on [libedit](http://thrysoee.dk/editline/), which is available in the main repositories of most Linux distributions (e.g. as [libedit-dev](https://packages.debian.org/stretch/libedit-dev) on Debian/Ubuntu) and comes with the macOS XCode command line tools.
  44. Then, simply create the Makefiles:
  45. ```sh
  46. $ cmake ..
  47. ```
  48. and finally, build it using the building system you chose (e.g. Make):
  49. ```sh
  50. $ make
  51. ```
  52. After the build has been finished, you may install the binaries to your local system (see [CMAKE\_INSTALL\_PREFIX](https://cmake.org/cmake/help/v3.0/variable/CMAKE_INSTALL_PREFIX.html) for information about the install prefix):
  53. ```sh
  54. $ make install
  55. ```
  56. Alternatively, you may run the interpreter directly without installation, for instance:
  57. ```sh
  58. $ ./brainfuck ../examples/hello.bf
  59. ```
  60. ## License
  61. The code is released under the Apache License version 2.0. See [LICENSE.txt](/LICENSE.txt).
  62. ## Contributors
  63. Fabian Mastenbroek https://github.com/fabianishere
  64. aliclubb https://github.com/aliclubb
  65. diekmann https://github.com/diekmann
  66. SevenBits https://github.com/SevenBits
  67. Alex Burka https://github.com/durka
  68. outis https://github.com/outis
  69. rien333 https://github.com/rien333