/Readme.md

https://github.com/ForNeVeR/BetterFuck · Markdown · 100 lines · 70 code · 30 blank · 0 comment · 0 complexity · af7c8fc7dbf1d93b11f8994e1ee568d5 MD5 · raw file

  1. BetterFuck [![Status Aquana][status-aquana]][andivionian-status-classifier] [![Build status][badge-appveyor]][build-appveyor] [![Build Status][badge-travis]][build-travis]
  2. ==========
  3. About
  4. -----
  5. BetterFuck is a Brainfuck language compiler into managed code (CLR). Compiled
  6. programs are ordinary CLR assemblies and therefore can be executed under MS .NET
  7. or Mono runtimes.
  8. Usage
  9. -----
  10. To use compiler, first save your Brainfuck code to plain text file (encoding
  11. does not matter, but it is recommended to use UTF-8 with or without BOM for any
  12. purposes). File extension does not matter either, but it is common practice to
  13. use `.b` extension for Brainfuck sources. If you're new to Brainfuck, see below
  14. for additional information about Brainfuck language.
  15. Then you can run `BFuck.Console` frontend to compile your source. Consider this:
  16. > ls
  17. BFuck.Compiler.dll
  18. BFuck.Console.exe
  19. BFuck.Runtime.dll
  20. source.b
  21. Here `BFuck.Compiler.dll`, `BFuck.Console.exe` and `BFuck.Runtime.dll` are
  22. necessary BetterFuck libraries and `source.b` is user-written Brainfuck source
  23. file. For this example, we'll use simple source:
  24. > cat source.b
  25. ,+.,+.,+.
  26. This program reads three characters from input stream and prints next character
  27. for each character read.
  28. Compile our program:
  29. > BFuck.Console source.b
  30. source.b... ok.
  31. (In non-Windows environments you may experience problems when running CLR
  32. executables from terminal; use `mono BFuck.Console.exe source.b` command then.)
  33. Now we got additional file in our directory: `source.exe`. Let's test it:
  34. > source.exe
  35. abcdef
  36. (Here I've entered letters `ace` with my keyboard, and program inserted one
  37. additional character after every my keypress.)
  38. (Same comments about running Mono-related stuff in non-Windows environments
  39. applies here.)
  40. Note that your compiled assembly (`source.exe` in our case) references
  41. `BFuck.Runtime.dll` assembly so it has to be in the same directory for your
  42. program to function properly.
  43. About the language
  44. ------------------
  45. BetterFuck runtime machine is a simple collection of memory cells. Every cell is
  46. of CLR type System.Int16 and therefore can store values from 0 to 65535. Every
  47. value can be interpreted as ordinary character and be printed to Unicode-aware
  48. output stream.
  49. Count of cells can be changed when configuring BetterFuck engine; current
  50. default is 256 cells.
  51. In Brainfuck, there are only 8 single-character commands:
  52. 1. `+` for incrementing current cell value.
  53. 2. `-` for decrementing current cell value.
  54. 3. `>` for moving one cell right (forward).
  55. 4. `<` for moving one cell left (back).
  56. 5. `.` for writing current cell value to output stream.
  57. 6. `,` for reading single character from input stream to current cell.
  58. 7. `[` for starting loop.
  59. 8. `]` for jumping to previous `[` if current cell value is not equal to 0;
  60. proceeds to next command otherwise.
  61. Source code can include any other characters; they will be dropped before
  62. compilation.
  63. BetterFuck compiler also introduces the concept of comments. Any piece of line
  64. starting with `#` character will be treated as comment till end of line.
  65. [andivionian-status-classifier]: https://github.com/ForNeVeR/andivionian-status-classifier#status-aquana-
  66. [build-appveyor]: https://ci.appveyor.com/project/ForNeVeR/betterfuck/branch/develop
  67. [build-travis]: https://travis-ci.org/ForNeVeR/BetterFuck
  68. [badge-appveyor]: https://ci.appveyor.com/api/projects/status/1cqgyhipyausce5g/branch/develop?svg=true
  69. [badge-travis]: https://travis-ci.org/ForNeVeR/BetterFuck.svg?branch=develop
  70. [status-aquana]: https://img.shields.io/badge/status-aquana-yellowgreen.svg