https://github.com/guidanoli/lua-bf
Brainfuck language interpreter in Lua
https://github.com/guidanoli/lua-bf
brainfuck lua
Last synced: 7 months ago
JSON representation
Brainfuck language interpreter in Lua
- Host: GitHub
- URL: https://github.com/guidanoli/lua-bf
- Owner: guidanoli
- License: mit
- Created: 2019-11-16T01:40:46.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-24T18:02:28.000Z (about 5 years ago)
- Last Synced: 2025-01-17T13:29:28.164Z (9 months ago)
- Topics: brainfuck, lua
- Language: Lua
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Brainfuck Language Interpreter in Lua
Brainfuck is an esoteric language. A strangely simple esoteric language. That means it's not really useful for day-to-day challenges, but for having fun with building a very simple compiler/interpreter.
Brainfuck works much like a Turing Machine: a (nearly infinite) tape, a head, and a state register. Plus input and output operators and loops. To read more about brainfuck, check out its article on Esolang [here](https://esolangs.org/wiki/Brainfuck)!
I chose Lua mainly because it handles hash tables natively, which really helps the compiler scalability. Plus Lua is really lightweight, unlike Python.
## Running
Simply run the lua script on your terminal...
```bash
lua bf.lua
```...and type/paste the brainfuck code and then escape input (Ctrl+D on Unix, Ctrl+Z on Windows).
...if requested input, type and escape ever after each character. Cease input by escaping twice.Here is a demo of the interpreter running [this script](http://www.hevanet.com/cristofd/brainfuck/wc.b) by [daniel b cristofani](http://www.hevanet.com/cristofd/brainfuck/), which counts lines, words and bytes of input:
```
>>>+>>>>>+>>+>>+[<<],[
-[-[-[-[-[-[-[-[<+>-[>+<-[>-<-[-[-[<++[<++++++>-]<
[>>[-<]<[>]<-]>>[<+>-[<->[-]]]]]]]]]]]]]]]]
<[-<<[-]+>]<<[>>>>>>+<<<<<<-]>[>]>>>>>>>+>[
<+[
>+++++++++<-[>-<-]++>[<+++++++>-[<->-]+[+>>>>>>]]
<[>+<-]>[>>>>>++>[-]]+<
]>[-<<<<<<]>>>>
],
]+<++>>>[[+++++>>>>>>]<+>+[[<++++++++>-]<.<<<<<]>>>>>>>>]
i would like a cup of tea 0 7 25
```