├── LICENSE ├── README.md ├── bracket.lua ├── brainfuck.lua ├── morse.lua └── test ├── 99-bottles-bracket.lua ├── 99-bottles-morse.lua ├── 99-bottles.lua ├── hello-world-bracket.lua ├── hello-world-morse-str.lua ├── hello-world-morse.lua └── hello-world.lua /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Patrick Rapin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | LuaBrainFuck 2 | ============ 3 | 4 | _LuaBrainFuck_ is a simple module to execute Brainfuck programs under Lua 5.2. 5 | 6 | In addition to the traditional syntax, it supports Morse style and bracket style. 7 | 8 | As an interesting by-product, both the Morse and bracket styles enable to turn any Brainfuck 9 | program into a quine, that is into a program that outputs itself! 10 | 11 | Traditional syntax 12 | ------------------ 13 | 14 | The module in `brainfuck.lua` contains a simple yet complete Brainfuck interpreter. 15 | 16 | Unlike most Lua modules, `brainfuck.lua` returns a single **function** that you just call 17 | with the Brainfuck source string in argument in order to run a program. 18 | 19 | Example: 20 | 21 | require 'brainfuck' '++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.' 22 | 23 | This obviously outputs the usual `Hello World!` message. 24 | 25 | Conforming to the Brainfuck language specifications, any character except `+ - < > [ ] . ,` is treated as a comment. 26 | 27 | Morse syntax 28 | ------------ 29 | 30 | As an innovation, _LuaBrainFuck_ supports a form of Morse code syntax for the Brainfuck program. 31 | 32 | This enables a more unified syntax where only three characters (well, nearly) are needed to program. 33 | These characters are without surprise the dash (`-`) (or the underscore `_`), the dot `.` and the oblique bar `/`. 34 | 35 | To support Morse code syntax, you need to first call `require "morse"` or to run Lua with `-l morse` 36 | on the command line. 37 | 38 | That modules returns a table with currently only one helper function: `export`. 39 | 40 | Most importantly, the module sets during loading 4 global variables: `_`, `__`, `___`, and `____`. 41 | 42 | The `___` (3 underscores) function is the main one: it runs the Morse encoded Brainfuck program. 43 | The argument can be a plain Morse string as showed in this _Hello World_ example: 44 | 45 | ___[[-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/-..-/-.-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-.-/-.-/-.-/ 46 | -.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-.-/-.-/-.-/-.-/-.-.-/-.-/--.-/--.-/--.-/--.-/-.--/-..-.-/-.-.-/ 47 | -.-/-.-/--.--/-.-.-/-.-/--.--/-.-/-.-/-.-/-.-/-.-/-.-/-.-/--.--/--.--/-.-/-.-/-.-/--.--/-.-.-/-.-/ 48 | -.-/--.--/--.-/--.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/--.--/-.-.-/--.--/ 49 | -.-/-.-/-.-/--.--/-.--/-.--/-.--/-.--/-.--/-.--/--.--/-.--/-.--/-.--/-.--/-.--/-.--/-.--/-.--/--.--/ 50 | -.-.-/-.-/--.--/-.-.-/--.--]] 51 | 52 | Since the program does not include a `require "morse"` instruction (which would look quite weird in a Morse 53 | program), you must load the module from the command line: 54 | 55 | lua -l morse hello-world-morse-str.lua 56 | 57 | Passing a string to `___` could be considered as cheating. That is why a pure Lua version is also 58 | supported. For that, you need to use the character `_` (underscore) instead of `-` (dash) for the _dah_ sign. 59 | The same _Hello World_ example becomes: 60 | 61 | ___(_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_.._/_._._/_._/_._/_._/_._/_._/_._/_._/_._._/_._/_._/ 62 | _._/_._/_._/_._/_._/_._/_._/_._/_._._/_._/_._/_._/_._._/_._/__._/__._/__._/__._/_.__/_.._._/_._._/ 63 | _._/_._/__.__/_._._/_._/__.__/_._/_._/_._/_._/_._/_._/_._/__.__/__.__/_._/_._/_._/__.__/_._._/_._/ 64 | _._/__.__/__._/__._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/__.__/_._._/__.__/ 65 | _._/_._/_._/__.__/_.__/_.__/_.__/_.__/_.__/_.__/__.__/_.__/_.__/_.__/_.__/_.__/_.__/_.__/_.__/__.__/ 66 | _._._/_._/__.__/_._._/__.__) 67 | 68 | Yes, it actually works! The code uses `_` and `__` global variables, along with a bunch of Lua indexation, 69 | division and concatenation operations. The general form for a program is: 70 | 71 | ___( CODE ) 72 | 73 | You can add spaces and newlines anywhere except between two underscores `__` or two dots `..`. 74 | 75 | Note: due to a limitation in Lua compiler, the number of `..` (concatenation) operations is limited to 200 per program. 76 | 77 | ### Look up table 78 | 79 | Here is the equivalence table between Brainfuck instructions and Morse encoding. 80 | For readability, it uses dash signs and not underscores. A division sign `/` is required to separate 81 | instructions. 82 | 83 | + -.- 84 | - -.-- 85 | > -.-.- 86 | < --.- 87 | [ -..- 88 | ] -..-.- 89 | . --.-- 90 | , --..- 91 | 92 | ### Quine 93 | 94 | A quine, according to Wikipedia definition, is a computer program which takes no input and produces a copy of its own source code as its only output. 95 | 96 | Because of the nature of the implementation in `morse.lua`, it is straightforward to turn any valid program 97 | in the full Lua Morse form into a quine! For that, you just need to change the call to `___` into a call 98 | to `____` (4 underscores), that is to add an underscore at the beginning of the program. 99 | 100 | The output may differ from the source code by a few white spaces. It is however guarantied that the output of the quine 101 | is itself a perfect quine. Illustration: 102 | 103 | $ lua -l morse hello-world-morse.lua > out1.lua 104 | $ lua -l morse out1.lua > out2.lua 105 | $ diff out1.lua out2.lua 106 | 107 | A good way to test quines is with the interactive interpreter: 108 | 109 | $ lua -l morse 110 | Lua 5.2.0 Copyright (C) 1994-2011 Lua.org, PUC-Rio 111 | > ____(_._) 112 | ____(_._) 113 | > ____(__.._/_.__/_.._._) 114 | ____(__.._/_.__/_.._._) 115 | 116 | ### Brainfuck to Morse conversion 117 | 118 | The module function `morse.export` can be used to transform a valid Brainfuck into Morse syntax, 119 | either in string or code versions. Here is its prototype: 120 | 121 | function morse.export(brainfuck_source, want_code_syntax) 122 | 123 | The first argument is a string containing the Brainfuck program. The second is a Boolean value: if `true` 124 | it outputs full Lua code, if `false` the string form. Example of usage: 125 | 126 | lua -l morse -e "print(morse.export([[ +-<> ]], true))" > out.lua 127 | 128 | Bracket mode 129 | ------------ 130 | 131 | _LuaBrainFuck_ also supports another syntax mode called _bracket_. This only uses parenthesis `()`, 132 | square brackets `[]`, braces `{}` and underscore `_` characters. 133 | 134 | To support bracket code syntax, you need to first call `require "bracket"` or to run Lua with `-l bracket` 135 | on the command line. 136 | 137 | Like `morse.lua` that modules returns a table with currently only one helper function: `export`. 138 | 139 | Most importantly, the module sets during loading 2 global variables: `_`, `__`. 140 | You cannot use simultaneously Morse and bracket styles because both define the same global variables 141 | `_` and `__` in an incompatible manner. 142 | 143 | The _Hello World_ example now becomes: 144 | 145 | _()()()()()()()()()(){_}(_)()()()()()()()(_)()()()()()()()()()()(_)()()()(_)()[_][_][_][_]{ 146 | }[__](_)()()(__)(_)()(__)()()()()()()()(__)(__)()()()(__)(_)()()(__)[_][_]()()()()()()()()( 147 | )()()()()()()(__)(_)(__)()()()(__){}{}{}{}{}{}(__){}{}{}{}{}{}{}{}(__)(_)()(__)(_)(__)(_,_) 148 | 149 | It works perfectly if run this way: 150 | 151 | lua -l bracket hello-world.lua 152 | 153 | As you have understood, this is a succession of function calls, sometimes with a literal table argument, 154 | and indexations. The general form of a program is like this: 155 | 156 | _ CODE (_,_) 157 | 158 | Because of Lua 5.2 function disambiguation, you can add spaces and newlines anywhere in the code except between two underscores `__`. 159 | 160 | ### Look up table 161 | 162 | Here is the equivalence table between Brainfuck instructions and bracket encoding. 163 | 164 | + () 165 | - {} 166 | > (_) 167 | < [_] 168 | [ {_} 169 | ] [__] 170 | . (__) 171 | , {__} 172 | 173 | ### Quine 174 | 175 | Like Morse, the bracket syntax also supports to be turned into a quine. All you have to do for that is to 176 | replace the final function call `(_,_)` by the function call `(_,__)`, that is to add an underscore 177 | before the last parenthesis character. 178 | 179 | The output may differ from the source code by a few white spaces. It is however guarantied that the output of the quine 180 | is itself a perfect quine. Illustration: 181 | 182 | $ lua -l bracket hello-world-bracket.lua > out1.lua 183 | $ lua -l bracket out1.lua > out2.lua 184 | $ diff out1.lua out2.lua 185 | 186 | It is also easy to test quines in the interactive interpreter: 187 | 188 | $ lua -l bracket 189 | Lua 5.2.0 Copyright (C) 1994-2011 Lua.org, PUC-Rio 190 | > _()(_,__) 191 | _()(_,__) 192 | > _{}()[_]{_}(_,__) 193 | _{}()[_]{_}(_,__) 194 | > 195 | 196 | ### Brainfuck to bracket conversion 197 | 198 | The module function `bracket.export` can be used to transform a valid Brainfuck into bracket syntax. 199 | Here is its prototype: 200 | 201 | function bracket.export(brainfuck_source) 202 | 203 | The argument is a string containing the program. Example of usage: 204 | 205 | lua -l bracket -e "print(bracket.export[[ +-<> ]])" > out.lua 206 | 207 | Copyright 208 | --------- 209 | 210 | _LuaBrainFuck_ source files are copyrighted by Patrick Rapin and placed under MIT license. 211 | 212 | The _99 bottles of beer_ source code and derived forms are copyrighted by Raphael Bois and placed under GPL v2. 213 | -------------------------------------------------------------------------------- /bracket.lua: -------------------------------------------------------------------------------- 1 | local accumul = {} 2 | local function add(...) 3 | for _,v in ipairs{...} do 4 | accumul[#accumul+1] = tostring(v) 5 | end 6 | end 7 | 8 | local subst = {['()']='+', ['{}']='-', ['[_]']='<', ['(_)']='>', 9 | ['{_}']='[', ['[__]']=']', ['(__)']='.', ['{__}']=','} 10 | local function run(a) 11 | local s = table.concat(accumul) 12 | accumul={} 13 | if a == __ then return print("_"..s.."(_,__)") end -- Quine! 14 | require'brainfuck'(s:gsub("[%[%(%{]_*[%]%)%}]", subst)) 15 | end 16 | 17 | local meta = { 18 | __call = function(f, a, b) 19 | if b then return run(b) end 20 | if a == nil then add'()' 21 | elseif a.s then add('(',a,')') 22 | elseif a[1] then add('{',a[1],'}') 23 | else add('{}') 24 | end 25 | return _ 26 | end, 27 | __index = function(t,k) add('[',k,']') return _ end, 28 | __tostring = function(t) return t.s end, 29 | } 30 | _ = setmetatable({s='_'}, meta) 31 | __ = setmetatable({s='__'}, meta) 32 | 33 | return { 34 | export = function(bf) 35 | local t = {} 36 | for k,v in pairs(subst) do t[v]=k end 37 | return "_"..bf:gsub("[^%+%-<>%.,%[%]]+",""):gsub('.', t).."(_,_)" 38 | end } 39 | -------------------------------------------------------------------------------- /brainfuck.lua: -------------------------------------------------------------------------------- 1 | -- Main Brainfuck interpreter. If you can program in Brainfuck (and in Lua), 2 | -- you certainly don't need any explanation on the code below! 3 | return function(s) 4 | local subst = {["+"]="v=v+1 ", ["-"]="v=v-1 ", [">"]="i=i+1 ", ["<"]="i=i-1 ", 5 | ["."] = "w(v)", [","]="v=r()", ["["]="while v~=0 do ", ["]"]="end "} 6 | local env = setmetatable({ i=0, t=setmetatable({},{__index=function() return 0 end}), 7 | r=function() return io.read(1):byte() end, w=function(c) io.write(string.char(c)) end }, 8 | {__index=function(t,k) return t.t[t.i] end, __newindex=function(t,k,v) t.t[t.i]=v end }) 9 | load(s:gsub("[^%+%-<>%.,%[%]]+",""):gsub(".", subst), "brainfuck", "t", env)() 10 | end 11 | -------------------------------------------------------------------------------- /morse.lua: -------------------------------------------------------------------------------- 1 | local meta 2 | meta = { 3 | __index = function(t,k) return setmetatable({t[1]..'.'..k}, meta) end, 4 | __concat = function(t1, t2) return setmetatable({t1[1]..'..'..t2[1]}, meta) end, 5 | __div = function(t1, t2) return setmetatable({t1[1]..'/'..t2[1]}, meta) end, 6 | __tostring = function(t) return t[1] end, 7 | } 8 | _ = setmetatable({'_'}, meta) 9 | __ = setmetatable({'__'}, meta) 10 | 11 | local subst = {['-.-']='+', ['-.--']='-', ['-..-']='[', ['--.-']='<', 12 | ['--.--']='.', ['--..-']=',', ['-.-.-']='>', ['-..-.-']=']', } 13 | function ___(p) 14 | require'brainfuck'(tostring(p):gsub("_","-"):gsub("[%.%-]+", subst):gsub("/","")) 15 | end 16 | function ____(p) 17 | return print("____("..tostring(p)..")") -- Quine! 18 | end 19 | 20 | return { 21 | export = function(bf, code) 22 | local t = {} 23 | for k,v in pairs(subst) do t[v]=k.."/" end 24 | local morse = bf:gsub("[^%+%-<>%.,%[%]]+",""):gsub('.', t):sub(1,-2) 25 | if code then 26 | morse = '___('..morse:gsub('-','_')..')' 27 | end 28 | return morse 29 | end } 30 | -------------------------------------------------------------------------------- /test/99-bottles-bracket.lua: -------------------------------------------------------------------------------- 1 | _()()(_)()(_)()()(_)(_)()(_)(_)(_)()()()()()()()()()(){_}{}(_)()(_)()(_)()()()()()()()()()()[_][_][ 2 | _][__](_)(_)(_)(_)()()()()()()()()()(){_}{}(_)()()()()()(_)()()()()()()()()()()(_)()()()()()()()()( 3 | )()()(_)()()()()()()()()(_)()()()()()()()()(_)()()()(_)()()()()(_)()[_][_][_][_][_][_][_][_][__]()( 4 | _){}{}()(_)()()()(_)()()()()()()(_){}{}()(_)()()()()()(_)()()()(_)()()()()()(_)()(_)()(_)()(_)()(_) 5 | ()()(_)()(_)()(_)()(){_}{}[_][__][_][_][_][_][_][_][_]{_}{}(_)(_){_}(_)(_)(_)(_)(_)(_)(_)(_){_}[_][ 6 | _][_][_][_][_][_]{_}{}(_){_}{}[__](_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(__)[_]{}{}{}{}(__)(_)(_)(_)(__) 7 | [_][_][_]{}{}(__)()()(__)()()()(__)()[_]{}(__)()[_][_]()[_][_][_][_][_][_][_][_][__]()(_){_}{}[_]{_ 8 | }{}[__](_)(_)(_)(_)(_){_}(_)(_)(_)()[_][_][_][_]()[_]()[_]()(_)(_)(_){}[__][_][_][_]{_}{}(_)(_)(_)( 9 | )[_][_][_][__](_){_}(_)(_)(_)(_)(_)(_)()[_][_][_][_][_][_]{}[__](_)(_)(_)(_)(_){_}{_}{}[__](_)(__)[ 10 | _][__][_][_][_][_]{_}(_)(_)(_)(_)(_){}[_][_][_][_][_]{}[__](_)(_){_}[_][_]()[_]()[_]()(_)(_)(_)(_){ 11 | }[__][_][_][_][_]{_}{}(_)(_)(_)(_)()[_][_][_][_][__](_){_}(_)(_)(_)(_)(_)(_)()[_][_][_][_][_][_]{}[ 12 | __](_)(_)(_)(_)(_)(_)(__)[_][_][_][_][_]{_}(_)(_)(_)(_)(_){}[_][_][_][_][_]{}[__](_)(_)(_){_}{}[_][ 13 | _][_]()[_]()(_)(_)(_)(_)[__][_][_][_][_]{_}{}(_)(_)(_)(_)()[_][_][_][_][__](_){}{_}{_}{}[__](_)(_)( 14 | _)(_)()[_][_][_][_][__][_][_][_][__]()(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(__)[_][_][_][_]{}{}{} 15 | {}(__)(_){}{}{}{}(__)()()()()()(__)(__){}[_]()()()()()()()()()()(__){}{}{}{}{}{}{}(__)[_][_]{_}{_}{ 16 | }[__](_)(_)(_)(__)[_][_][_][__](_)(_)(_)(_)(_)(_)(__)[_][_][_]{}{}{}{}(__)[_]()(__)(_)(_)(_)(_)(__) 17 | [_][_][_][_]{}{}{}{}(__)()()()(__)(__)()(_)()()()(__)(){_}(_)[__]()(_)()(_){_}{}(_)()[_][_]{}[_]{}[ 18 | _][_][_](__)[_][_][_]{}{}{}{}(__){}(__)(_)(_)(_)(__)[_][_][_]()()()()()()(__)[_]()()(__){}{}{}(__)( 19 | _)(_)(_)(_)(__)[_][_][_]()()()(__)[_]{}{}{}{}(__)()()()()()()()()()()()(__)(__){}{}{}{}{}{}(_){}{}{ 20 | }{}(_){}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}(_)(_)(_)()()(__){}{}(_)(__)( 21 | __)(_)(_)(_)[__](_)(_)(_){_}{}(_){_}{}[__][_][_][_][_][_][_][_]{_}[_][__][_]{_}{}[__](_)(_){_}(_)[ 22 | __](_)(_)(_)(_)(_)[__]()(_){_}{}[_]{_}{}[__][_][_][_][_]{_}{}(_)(_){_}{}(_)()[_][_][_][_]{}[_][_][_ 23 | ](__)[_][_][_]{}{}{}{}(__){}(__)(_)(_)(_)(__)[_][_][_]()()()()()()(__)[_]()()(__){}{}{}(__)(_)(_)(_ 24 | )(_)(__)[_][_][_]()()()(__)[_]{}{}{}{}(__)()()()()()()()()()()()(__)(__){}{}{}{}{}{}(_){}{}{}{}(_)( 25 | )()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()(_)(_)(_)(__)[_](__)(_)(_)(_)(_)(_)( 26 | _)[__][_][_][__][_]{_}{}(_)(_)(_)(_){_}{}[_][_]()[_][_][_][_]()()(__){}{}(_)(__){_}[_][__][_][_][_] 27 | [_][_][_][_][_]{_}{}(_){_}{}[__][_][__]()(_){_}{}[_]{_}{}[__](_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_)(_ 28 | )(__)[_][_][_]{}{}{}{}{}(__)()()()()()()()()()()(__){}{}{}{}{}{}(__)(_)(_)(_)(_)(__)[_][_][_]{}{}{} 29 | {}(__){}(__)[_](__)(_)(_)(_)(_)(__)[_][_][_][_]{}(__)(_)()(__)()()()()()()()()(__){}{}{}{}{}{}{}{}{ 30 | }(__)(_)(_)(_)(__)[_][_][_][_]{}{}{}(__)(_)(__)[_]()()()(__)(_)(_)(_)(_)(__)[_][_][_]()()(__)[_]{}{ 31 | }{}(__)(_)()()()(__)(__)(_)(_)(_)(__)[_][_][_][_]()()()()()()()()(__)(_)()(__)(_)(_)(_)(__)[_][_][_ 32 | ][_]{}{}{}{}{}{}{}{}(__)(_){}{}(__){}{}{}(__)()()()()()()(__){}{}{}{}{}{}{}(__)[_]()()()(__)()()(_) 33 | ()()()()()(_)(_)(_)(_)(__)[_](__){_}[_][__][_][_][_][_][_][_][_][__]()(_)(_)(_)(_)(_)(_){}[_][_][_] 34 | ()(_)(_){_}[_][_]{_}{}[__][_]()[_]()(_)(_)(_)(_){}[__][_][_][_][_]{_}(_){}[_]{_}{}[__][__](_){_}{}( 35 | _)(_)(_)()[_][_][_][__](_){_}{}(_){}(_)()()()()()()()()()[_][_][__](_)(_)(_)(_)(_){_}(_)[__](_)(_)( 36 | _)(_)[__][_][_][_][_][__](_)(_)(_)(_)(_)(_)[__]()[_][_][_][_][_][_][_]{_}[_][__][_][__]()[_]()[_][_ 37 | ][_][_][_][_]()[_]{}[__](_)(_)(_)(_)(_)(_)(_)(_)(_)(_){_}(_)[__](_)(_)(_)(_)(_){_}{}(_){_}{}[__][_] 38 | [__]()(_){_}{}[_]{_}{}[__][_][_][_][_][_][_][_][_][_]{}{}{}{}{}{}{}{}{}{}{}{}{}(__)[_][_]{}{}{}{}( 39 | __)(_)(_)(_)(__)[_][_][_]()()()()()(__){}{}{}{}{}(__)(_)(_)(_)(__)[_][_][_]()()()()()(__)[_]()()(__ 40 | ){}{}{}(__)(_)(_)(_)(_)(__)[_][_][_]{}(__)()(__){}{}{}{}{}(__)()()()(__)[_](__)(_)(_)(_)(_)(__)[_][ 41 | _][_][_]{}{}{}{}(__)(_){}{}{}{}(__)[_]()()()(__)(_)(_)(_)(_)(__)[_][_][_][_]{}{}(__)(_)()()()()()() 42 | ()(__)()()()()(__)(_)(_)(_)(__)[_][_][_]{}{}{}{}{}{}(__){}{}{}{}(__){}{}(__)[_]()()()(__)(_)(_)(_)( 43 | _)(__)[_][_][_](__)()()(__)()()()(__)()[_](__)()(_)(_)(_)(_)(_)(__)[_](__)(_)(_)(_)(_)(_)(_)(_)(_)( 44 | _)[__]()[_]{_}{}[__]()[_]{_}{}[__][_]{_}{}[__][_]{_}{}[__]()[_][_][_]{_}[_][__][_]{_}{}[__][_]{_}{} 45 | [__][_]{_}{}[__][_]{_}{}[__]()()()()()()()()()(){_}{}(_)()(_)()(_)()()()()()()()()()()[_][_][_][__] 46 | (_){}(_){}(_){}[_][_][_][_][_][_]{_}{}[__]()[_]{_}{}[__][_]()[_][_][__](_,_) -------------------------------------------------------------------------------- /test/99-bottles-morse.lua: -------------------------------------------------------------------------------- 1 | ___(_._/_._/_._._/_._/_._._/_._/_._/_._._/_._._/_._/_._._/_._._/_._._/_._/_._/_._/_._/_._/ 2 | _._/_._/_._/_._/_._/_.._/_.__/_._._/_._/_._._/_._/_._._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/ 3 | __._/__._/__._/_.._._/_._._/_._._/_._._/_._._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_.._/_.__/ 4 | _._._/_._/_._/_._/_._/_._/_._._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._._/_._/_._/_._/_._/_._/ 5 | _._/_._/_._/_._/_._/_._/_._._/_._/_._/_._/_._/_._/_._/_._/_._/_._._/_._/_._/_._/_._/_._/_._/_._/ 6 | _._/_._._/_._/_._/_._/_._._/_._/_._/_._/_._/_._._/_._/__._/__._/__._/__._/__._/__._/__._/__._/ 7 | _.._._/_._/_._._/_.__/_.__/_._/_._._/_._/_._/_._/_._._/_._/_._/_._/_._/_._/_._/_._._/_.__/_.__/_._/ 8 | _._._/_._/_._/_._/_._/_._/_._._/_._/_._/_._/_._._/_._/_._/_._/_._/_._/_._._/_._/_._._/_._/_._._/_._/ 9 | _._._/_._/_._._/_._/_._/_._._/_._/_._._/_._/_._._/_._/_._/_.._/_.__/__._/_.._._/__._/__._/__._/__._/ 10 | __._/__._/__._/_.._/_.__/_._._/_._._/_.._/_._._/_._._/_._._/_._._/_._._/_._._/_._._/_._._/_.._/__._/ 11 | __._/__._/__._/__._/__._/__._/_.._/_.__/_._._/_.._/_.__/_.._._/_._._/_._._/_._._/_._._/_._._/_._._/ 12 | _._._/_._._/_._._/_._._/_._._/__.__/__._/_.__/_.__/_.__/_.__/__.__/_._._/_._._/_._._/__.__/__._/ 13 | __._/__._/_.__/_.__/__.__/_._/_._/__.__/_._/_._/_._/__.__/_._/__._/_.__/__.__/_._/__._/__._/_._/ 14 | __._/__._/__._/__._/__._/__._/__._/__._/_.._._/_._/_._._/_.._/_.__/__._/_.._/_.__/_.._._/_._._/ 15 | _._._/_._._/_._._/_._._/_.._/_._._/_._._/_._._/_._/__._/__._/__._/__._/_._/__._/_._/__._/_._/_._._/ 16 | _._._/_._._/_.__/_.._._/__._/__._/__._/_.._/_.__/_._._/_._._/_._._/_._/__._/__._/__._/_.._._/_._._/ 17 | _.._/_._._/_._._/_._._/_._._/_._._/_._._/_._/__._/__._/__._/__._/__._/__._/_.__/_.._._/_._._/_._._/ 18 | _._._/_._._/_._._/_.._/_.._/_.__/_.._._/_._._/__.__/__._/_.._._/__._/__._/__._/__._/_.._/_._._/_._._/ 19 | _._._/_._._/_._._/_.__/__._/__._/__._/__._/__._/_.__/_.._._/_._._/_._._/_.._/__._/__._/_._/__._/_._/ 20 | __._/_._/_._._/_._._/_._._/_._._/_.__/_.._._/__._/__._/__._/__._/_.._/_.__/_._._/_._._/_._._/_._._/ 21 | _._/__._/__._/__._/__._/_.._._/_._._/_.._/_._._/_._._/_._._/_._._/_._._/_._._/_._/__._/__._/__._/ 22 | __._/__._/__._/_.__/_.._._/_._._/_._._/_._._/_._._/_._._/_._._/__.__/__._/__._/__._/__._/__._/_.._/ 23 | _._._/_._._/_._._/_._._/_._._/_.__/__._/__._/__._/__._/__._/_.__/_.._._/_._._/_._._/_._._/_.._/_.__/ 24 | __._/__._/__._/_._/__._/_._/_._._/_._._/_._._/_._._/_.._._/__._/__._/__._/__._/_.._/_.__/_._._/_._._/ 25 | _._._/_._._/_._/__._/__._/__._/__._/_.._._/_._._/_.__/_.._/_.._/_.__/_.._._/_._._/_._._/_._._/_._._/ 26 | _._/__._/__._/__._/__._/_.._._/__._/__._/__._/_.._._/_._/_._._/_._._/_._._/_._._/_._._/_._._/_._._/ 27 | _._._/_._._/_._._/_._._/_._._/_._._/__.__/__._/__._/__._/__._/_.__/_.__/_.__/_.__/__.__/_._._/_.__/ 28 | _.__/_.__/_.__/__.__/_._/_._/_._/_._/_._/__.__/__.__/_.__/__._/_._/_._/_._/_._/_._/_._/_._/_._/_._/ 29 | _._/__.__/_.__/_.__/_.__/_.__/_.__/_.__/_.__/__.__/__._/__._/_.._/_.._/_.__/_.._._/_._._/_._._/ 30 | _._._/__.__/__._/__._/__._/_.._._/_._._/_._._/_._._/_._._/_._._/_._._/__.__/__._/__._/__._/_.__/ 31 | _.__/_.__/_.__/__.__/__._/_._/__.__/_._._/_._._/_._._/_._._/__.__/__._/__._/__._/__._/_.__/_.__/ 32 | _.__/_.__/__.__/_._/_._/_._/__.__/__.__/_._/_._._/_._/_._/_._/__.__/_._/_.._/_._._/_.._._/_._/ 33 | _._._/_._/_._._/_.._/_.__/_._._/_._/__._/__._/_.__/__._/_.__/__._/__._/__._/__.__/__._/__._/__._/ 34 | _.__/_.__/_.__/_.__/__.__/_.__/__.__/_._._/_._._/_._._/__.__/__._/__._/__._/_._/_._/_._/_._/_._/_._/ 35 | __.__/__._/_._/_._/__.__/_.__/_.__/_.__/__.__/_._._/_._._/_._._/_._._/__.__/__._/__._/__._/_._/_._/ 36 | _._/__.__/__._/_.__/_.__/_.__/_.__/__.__/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/__.__/__.__/ 37 | _.__/_.__/_.__/_.__/_.__/_.__/_._._/_.__/_.__/_.__/_.__/_._._/_.__/_.__/_.__/_.__/_.__/_.__/_.__/ 38 | _.__/_.__/_.__/_.__/_.__/_.__/_.__/_.__/_.__/_.__/_.__/_.__/_.__/_.__/_.__/_.__/_.__/_.__/_.__/_.__/ 39 | _.__/_.__/_.__/_.__/_.__/_._._/_._._/_._._/_._/_._/__.__/_.__/_.__/_._._/__.__/__.__/_._._/_._._/ 40 | _._._/_.._._/_._._/_._._/_._._/_.._/_.__/_._._/_.._/_.__/_.._._/__._/__._/__._/__._/__._/__._/__._/ 41 | _.._/__._/_.._._/__._/_.._/_.__/_.._._/_._._/_._._/_.._/_._._/_.._._/_._._/_._._/_._._/_._._/_._._/ 42 | _.._._/_._/_._._/_.._/_.__/__._/_.._/_.__/_.._._/__._/__._/__._/__._/_.._/_.__/_._._/_._._/_.._/ 43 | _.__/_._._/_._/__._/__._/__._/__._/_.__/__._/__._/__._/__.__/__._/__._/__._/_.__/_.__/_.__/_.__/ 44 | __.__/_.__/__.__/_._._/_._._/_._._/__.__/__._/__._/__._/_._/_._/_._/_._/_._/_._/__.__/__._/_._/_._/ 45 | __.__/_.__/_.__/_.__/__.__/_._._/_._._/_._._/_._._/__.__/__._/__._/__._/_._/_._/_._/__.__/__._/ 46 | _.__/_.__/_.__/_.__/__.__/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/__.__/__.__/_.__/_.__/_.__/ 47 | _.__/_.__/_.__/_._._/_.__/_.__/_.__/_.__/_._._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/ 48 | _._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._._/_._._/_._._/ 49 | __.__/__._/__.__/_._._/_._._/_._._/_._._/_._._/_._._/_.._._/__._/__._/_.._._/__._/_.._/_.__/_._._/ 50 | _._._/_._._/_._._/_.._/_.__/__._/__._/_._/__._/__._/__._/__._/_._/_._/__.__/_.__/_.__/_._._/__.__/ 51 | _.._/__._/_.._._/__._/__._/__._/__._/__._/__._/__._/__._/_.._/_.__/_._._/_.._/_.__/_.._._/__._/ 52 | _.._._/_._/_._._/_.._/_.__/__._/_.._/_.__/_.._._/_._._/_._._/_._._/_._._/_._._/_._._/_._._/_._._/ 53 | _._._/_._._/_._._/_._._/_._._/__.__/__._/__._/__._/_.__/_.__/_.__/_.__/_.__/__.__/_._/_._/_._/_._/ 54 | _._/_._/_._/_._/_._/_._/__.__/_.__/_.__/_.__/_.__/_.__/_.__/__.__/_._._/_._._/_._._/_._._/__.__/ 55 | __._/__._/__._/_.__/_.__/_.__/_.__/__.__/_.__/__.__/__._/__.__/_._._/_._._/_._._/_._._/__.__/__._/ 56 | __._/__._/__._/_.__/__.__/_._._/_._/__.__/_._/_._/_._/_._/_._/_._/_._/_._/__.__/_.__/_.__/_.__/ 57 | _.__/_.__/_.__/_.__/_.__/_.__/__.__/_._._/_._._/_._._/__.__/__._/__._/__._/__._/_.__/_.__/_.__/ 58 | __.__/_._._/__.__/__._/_._/_._/_._/__.__/_._._/_._._/_._._/_._._/__.__/__._/__._/__._/_._/_._/ 59 | __.__/__._/_.__/_.__/_.__/__.__/_._._/_._/_._/_._/__.__/__.__/_._._/_._._/_._._/__.__/__._/__._/ 60 | __._/__._/_._/_._/_._/_._/_._/_._/_._/_._/__.__/_._._/_._/__.__/_._._/_._._/_._._/__.__/__._/__._/ 61 | __._/__._/_.__/_.__/_.__/_.__/_.__/_.__/_.__/_.__/__.__/_._._/_.__/_.__/__.__/_.__/_.__/_.__/__.__/ 62 | _._/_._/_._/_._/_._/_._/__.__/_.__/_.__/_.__/_.__/_.__/_.__/_.__/__.__/__._/_._/_._/_._/__.__/_._/ 63 | _._/_._._/_._/_._/_._/_._/_._/_._._/_._._/_._._/_._._/__.__/__._/__.__/_.._/__._/_.._._/__._/__._/ 64 | __._/__._/__._/__._/__._/_.._._/_._/_._._/_._._/_._._/_._._/_._._/_._._/_.__/__._/__._/__._/_._/ 65 | _._._/_._._/_.._/__._/__._/_.._/_.__/_.._._/__._/_._/__._/_._/_._._/_._._/_._._/_._._/_.__/_.._._/ 66 | __._/__._/__._/__._/_.._/_._._/_.__/__._/_.._/_.__/_.._._/_.._._/_._._/_.._/_.__/_._._/_._._/_._._/ 67 | _._/__._/__._/__._/_.._._/_._._/_.._/_.__/_._._/_.__/_._._/_._/_._/_._/_._/_._/_._/_._/_._/_._/ 68 | __._/__._/_.._._/_._._/_._._/_._._/_._._/_._._/_.._/_._._/_.._._/_._._/_._._/_._._/_._._/_.._._/ 69 | __._/__._/__._/__._/_.._._/_._._/_._._/_._._/_._._/_._._/_._._/_.._._/_._/__._/__._/__._/__._/__._/ 70 | __._/__._/_.._/__._/_.._._/__._/_.._._/_._/__._/_._/__._/__._/__._/__._/__._/__._/_._/__._/_.__/ 71 | _.._._/_._._/_._._/_._._/_._._/_._._/_._._/_._._/_._._/_._._/_._._/_.._/_._._/_.._._/_._._/_._._/ 72 | _._._/_._._/_._._/_.._/_.__/_._._/_.._/_.__/_.._._/__._/_.._._/_._/_._._/_.._/_.__/__._/_.._/_.__/ 73 | _.._._/__._/__._/__._/__._/__._/__._/__._/__._/__._/_.__/_.__/_.__/_.__/_.__/_.__/_.__/_.__/_.__/ 74 | _.__/_.__/_.__/_.__/__.__/__._/__._/_.__/_.__/_.__/_.__/__.__/_._._/_._._/_._._/__.__/__._/__._/ 75 | __._/_._/_._/_._/_._/_._/__.__/_.__/_.__/_.__/_.__/_.__/__.__/_._._/_._._/_._._/__.__/__._/__._/ 76 | __._/_._/_._/_._/_._/_._/__.__/__._/_._/_._/__.__/_.__/_.__/_.__/__.__/_._._/_._._/_._._/_._._/ 77 | __.__/__._/__._/__._/_.__/__.__/_._/__.__/_.__/_.__/_.__/_.__/_.__/__.__/_._/_._/_._/__.__/__._/ 78 | __.__/_._._/_._._/_._._/_._._/__.__/__._/__._/__._/__._/_.__/_.__/_.__/_.__/__.__/_._._/_.__/_.__/ 79 | _.__/_.__/__.__/__._/_._/_._/_._/__.__/_._._/_._._/_._._/_._._/__.__/__._/__._/__._/__._/_.__/_.__/ 80 | __.__/_._._/_._/_._/_._/_._/_._/_._/_._/__.__/_._/_._/_._/_._/__.__/_._._/_._._/_._._/__.__/__._/ 81 | __._/__._/_.__/_.__/_.__/_.__/_.__/_.__/__.__/_.__/_.__/_.__/_.__/__.__/_.__/_.__/__.__/__._/_._/ 82 | _._/_._/__.__/_._._/_._._/_._._/_._._/__.__/__._/__._/__._/__.__/_._/_._/__.__/_._/_._/_._/__.__/ 83 | _._/__._/__.__/_._/_._._/_._._/_._._/_._._/_._._/__.__/__._/__.__/_._._/_._._/_._._/_._._/_._._/ 84 | _._._/_._._/_._._/_._._/_.._._/_._/__._/_.._/_.__/_.._._/_._/__._/_.._/_.__/_.._._/__._/_.._/_.__/ 85 | _.._._/__._/_.._/_.__/_.._._/_._/__._/__._/__._/_.._/__._/_.._._/__._/_.._/_.__/_.._._/__._/_.._/ 86 | _.__/_.._._/__._/_.._/_.__/_.._._/__._/_.._/_.__/_.._._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/ 87 | _.._/_.__/_._._/_._/_._._/_._/_._._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/__._/__._/__._/_.._._/ 88 | _._._/_.__/_._._/_.__/_._._/_.__/__._/__._/__._/__._/__._/__._/_.._/_.__/_.._._/_._/__._/_.._/_.__/ 89 | _.._._/__._/_._/__._/__._/_.._._) -------------------------------------------------------------------------------- /test/99-bottles.lua: -------------------------------------------------------------------------------- 1 | require 'brainfuck' [=[ 2 | # 99 bottles of beer in Brainf*ck 3 | # Copyright (C) 2008 Raphael Bois 4 | # 1671 brainf*ck instructions 5 | # Published under GPL v2 6 | 7 | Initialization 8 | ++ Counter for loop (a) 9 | >+ unused 10 | >++ Counter for loop (b) 11 | > Flag for 'no more' 12 | >+ Flag for not 'no more' 13 | >>> (5) to (7) : temporary values 14 | ++++++++++[->+>+>++++++++++<<<]>>> 10 10 100 in (8) (9) (10) 15 | >++++++++++ 10 in (11) 16 | [- 17 | >+++++ 50 in (12) 18 | >++++++++++ 100 in (13) 19 | >+++++++++++ 110 in (14) 20 | >++++++++ 80 in (15) 21 | >++++++++ 80 in (16) 22 | >+++ 30 in (17) 23 | >++++ 40 in (18) 24 | >+ 10 in (19) 25 | <<<<<<<<] 26 | + 27 | >-- + 48 '0' plus 1 in (12) 28 | >++ + 102 'f' plus 1 in (13) 29 | >+++++ + 115 's' plus 1 in (14) 30 | >-- + 78 'N' plus 1 in (15) 31 | >++++ + 84 'T' plus 1 in (16) 32 | >++ + 32 ' ' plus 1 in (17) 33 | >++++ + 44 comma plus 1 in (18) 34 | > + 10 LF plus 1 in (19) 35 | 36 | stuff for writing parts of the song 37 | >+ select stuff 38 | >+ select stuff 39 | >+ write song part 3 40 | >++ write song part 1 41 | >+ write song part 2 42 | >+ Flag for 'end of song' 43 | >++ Flag for not 'end of song' 44 | 45 | All bytes are at val plus 1 46 | Go back to (7) with final initialization step (remove 1 to all bytes) 47 | [-<] 48 | 49 | <<<<<<< at (0) 50 | [ loop (a) 51 | - 52 | 53 | >> at (2) 54 | [ loop (b) 55 | 56 | >>>>>>>> at (10) 57 | [ start loop 58 | 59 | <<<<<<< at (3) 60 | [->[-] 61 | print '(N|n)o more' 62 | >>>>>>>>>>>. '(N|n)' 63 | <----. 'o' 64 | >>>. ' ' 65 | <<<--. 'm' 66 | ++. 'o' 67 | +++.+ 'r' 68 | <-.+ 'e' 69 | <<+<<<<<<<< 70 | ]+> at (4) 71 | [-<[-]>>>>> at (9) 72 | prints number (using (9) and (10)) 73 | [>>>+<<<<+<+<+>>>-]<<<[->>>+<<<]> at (6) 74 | [>>>>>>+<<<<<<-]>>>>>[[-]>.<]<<<<[>>>>>-<<<<<-]>> at (9) 75 | [<<+<+<+>>>>-]<<<<[->>>>+<<<<]> at (6) 76 | [>>>>>>+<<<<<<-]>>>>>>.<<<<<[>>>>>-<<<<<-] at (7) 77 | 78 | memorize in (11) if (10) not 1 79 | >>>[-<<<+<+>>>>]<<<<[->>>>+<<<<]>-[[-]>>>>+<<<<]<<< at (4) 80 | ]+ 81 | 82 | >>>>>>>> at (12) 83 | print ' bottle(s) of beer' 84 | >>>>>. ' ' 85 | <<<<----. 'b' 86 | >----. 'o' 87 | +++++..- 'tt' 88 | <++++++++++. 'l' 89 | -------. 'e' 90 | <<[[-]>>>.<<<]>> 's' if (11)==1 ie if (10)!=1 91 | >>>>. ' ' 92 | <<<----. 'o' 93 | <+. 'f' 94 | >>>>. ' ' 95 | <<<<----. 'b' 96 | +++..+ 'ee' 97 | >+++.+ 'r' 98 | 99 | [>] at (20) 100 | 101 | +>+>[->+<<-<- 102 | print ' on the wall' DOT LF LF 103 | <<<. ' ' 104 | <<<----. 'o' 105 | -. 'n' 106 | >>>. ' ' 107 | <<<++++++. 't' 108 | <++. 'h' 109 | ---. 'e' 110 | >>>>. ' ' 111 | <<<+++. 'w' 112 | <----. 'a' 113 | +++++++++++.. 'll' 114 | ------>---- reset to 'f' and 's' 115 | >---------- ---------- ---------- -- sets (15) to 'N' 116 | 117 | >>>++.-- DOT 118 | >.. LF LF 119 | >>>] at (22) 120 | 121 | >>>[->[-]<<<<<<<[<]<[-]>>[>]>>>>>]+ if end of song reset bottles counter 122 | >[-<[-] at (25) 123 | <<<< at (21) 124 | [->>[->+<<<<- 125 | print ' on the wall' COMMA ' ' 126 | <<<. ' ' 127 | <<<----. 'o' 128 | -. 'n' 129 | >>>. ' ' 130 | <<<++++++. 't' 131 | <++. 'h' 132 | ---. 'e' 133 | >>>>. ' ' 134 | <<<+++. 'w' 135 | <----. 'a' 136 | +++++++++++.. 'll' 137 | 138 | ------>---- reset (13) and (14) to 'f' and 's' 139 | >++++++++++ ++++++++++ ++++++++++ ++ sets (15) to 'n' 140 | 141 | >>>. comma 142 | <. ' ' 143 | >>>>>>]<<]< at (20) 144 | 145 | [->>>>[-<<+< at (21) 146 | <<<++.-- DOT 147 | >. LF 148 | 149 | [<]<<<<<<<< at (3) 150 | [->[-]<]+> at (4) 151 | [-<[-]> 152 | >>>>>>>>>>>>. 'T' 153 | <<<-----. 'a' 154 | ++++++++++. 'k' 155 | ------. 'e' 156 | >>>>. ' ' 157 | <<<----. 'o' 158 | -. 'n' 159 | <. 'e' 160 | >>>>. ' ' 161 | <<<<-. 'd' 162 | >+. 'o' 163 | ++++++++. 'w' 164 | ---------. 'n' 165 | >>>. ' ' 166 | <<<<---. 'a' 167 | >. 'n' 168 | <+++. 'd' 169 | >>>>. ' ' 170 | <<<++. 'p' 171 | <---. 'a' 172 | >+++.. 'ss' 173 | >>>. ' ' 174 | <<<<++++++++. 'i' 175 | >+. 't' 176 | >>>. ' ' 177 | <<<<--------. 'a' 178 | >--. 'r' 179 | ---. 'o' 180 | ++++++. 'u' 181 | -------. 'n' 182 | <+++. 'd' 183 | ++>+++++ reset (13) and (14) to 'f' and 's' 184 | >>>>. comma 185 | <. ' ' 186 | 187 | [<]<<<<<<< at (4) 188 | ]+ 189 | 190 | >>>>>> at (10) 191 | decrements values 192 | -<<<+>>[<<[-]<+<+>>>>-]<<<<[>-<[-]]>[->>>+<<<]>[->->+++++++++<<]>>> at (10) 193 | 194 | >>[>]>>>>] at (24) 195 | <<<<] at (20) 196 | 197 | >>>>>>]+ at (26) 198 | 199 | <<<<<<<[<]< at (10) 200 | ] 201 | +<+ 202 | <<<<<<+< at (2) 203 | - 204 | ] 205 | 206 | print 'Go to the store and buy some more' comma ' ' 207 | 208 | >>>>>>>>>>[>]>>>>> at (25) 209 | [->[-]<]+> at (26) 210 | [-<[-] 211 | <<<<<<<<< at (16) 212 | -------------. 'G' 213 | <<----. 'o' 214 | >>>. ' ' 215 | <<<+++++. 't' 216 | -----. 'o' 217 | >>>. ' ' 218 | <<<+++++. 't' 219 | <++. 'h' 220 | ---. 'e' 221 | >>>>. ' ' 222 | <<<-. 's' 223 | +. 't' 224 | -----. 'o' 225 | +++. 'r' 226 | <. 'e' 227 | >>>>. ' ' 228 | <<<<----. 'a' 229 | >----. 'n' 230 | <+++. 'd' 231 | >>>>. ' ' 232 | <<<<--. 'b' 233 | >+++++++. 'u' 234 | ++++. 'y' 235 | >>>. ' ' 236 | <<<------. 's' 237 | ----. 'o' 238 | --. 'm' 239 | <+++. 'e' 240 | >>>>. ' ' 241 | <<<. 'm' 242 | ++. 'o' 243 | +++.+ 'r' 244 | <.+ 'e' 245 | >>>>>. coma 246 | <. ' ' 247 | >>>>>>>>> 248 | ]+ 249 | 250 | Initialize last loop to print final '99 bottles of beer on the wall' DOT 251 | <[-]+<[-]<[-]<[-]+<<< at (19) 252 | [<]<[-]<[-]<[-]<[-] at (7) 253 | ++++++++++[->+>+>++++++++++<<<]>->->- 254 | <<<<<<[-]+<[-]<+<< at (0) 255 | ] 256 | ]=] 257 | -------------------------------------------------------------------------------- /test/hello-world-bracket.lua: -------------------------------------------------------------------------------- 1 | _()()()()()()()()()(){_}(_)()()()()()()()(_)()()()()()()()()()()(_)()()()(_)()[_][_][_][_]{ 2 | }[__](_)()()(__)(_)()(__)()()()()()()()(__)(__)()()()(__)(_)()()(__)[_][_]()()()()()()()()( 3 | )()()()()()()(__)(_)(__)()()()(__){}{}{}{}{}{}(__){}{}{}{}{}{}{}{}(__)(_)()(__)(_)(__)(_,_) -------------------------------------------------------------------------------- /test/hello-world-morse-str.lua: -------------------------------------------------------------------------------- 1 | ___[[-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/-..-/-.-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-.-/-.-/-.-/ 2 | -.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-.-/-.-/-.-/-.-/-.-.-/-.-/--.-/--.-/--.-/--.-/-.--/-..-.-/-.-.-/ 3 | -.-/-.-/--.--/-.-.-/-.-/--.--/-.-/-.-/-.-/-.-/-.-/-.-/-.-/--.--/--.--/-.-/-.-/-.-/--.--/-.-.-/-.-/ 4 | -.-/--.--/--.-/--.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/-.-/--.--/-.-.-/--.--/ 5 | -.-/-.-/-.-/--.--/-.--/-.--/-.--/-.--/-.--/-.--/--.--/-.--/-.--/-.--/-.--/-.--/-.--/-.--/-.--/--.--/ 6 | -.-.-/-.-/--.--/-.-.-/--.--]] -------------------------------------------------------------------------------- /test/hello-world-morse.lua: -------------------------------------------------------------------------------- 1 | ___(_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_.._/_._._/_._/_._/_._/_._/_._/_._/_._/_._._/_._/_._/ 2 | _._/_._/_._/_._/_._/_._/_._/_._/_._._/_._/_._/_._/_._._/_._/__._/__._/__._/__._/_.__/_.._._/_._._/ 3 | _._/_._/__.__/_._._/_._/__.__/_._/_._/_._/_._/_._/_._/_._/__.__/__.__/_._/_._/_._/__.__/_._._/_._/ 4 | _._/__.__/__._/__._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/__.__/_._._/__.__/ 5 | _._/_._/_._/__.__/_.__/_.__/_.__/_.__/_.__/_.__/__.__/_.__/_.__/_.__/_.__/_.__/_.__/_.__/_.__/__.__/ 6 | _._._/_._/__.__/_._._/__.__) -------------------------------------------------------------------------------- /test/hello-world.lua: -------------------------------------------------------------------------------- 1 | require 'brainfuck' '++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.' 2 | --------------------------------------------------------------------------------