Skip to content

ArmoredPony/lunge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

What

Lunge is a Befunge-93 programming language interpreter written in Lua.

Why

  1. I am bored at midnight
  2. I hadn't written anything in Lua for a while
  3. I couldn't find Befunge interpreter written in Lua

How

Import Befunge module with require 'befunge', create a new interpreter instance with Befunge.new('some code') and run it with run method. Notice how [[multiline strings]] are used - Lua my beloved got us covered here too. When run stops, it returns interpreter's status. You also may advance algorithm execution step by step with advance method.

See examples folder for more algorithms. You can find them (and more) on esoteric programming languages wiki - Esolang.

local Befunge = require 'befunge'

-- "Hello world"
local hw = Befunge.new [[
>              v
v"Hello World!"<
>:v
^,_@
]]
local hwstatus = hw:run()
print()

-- DNA-code
local dna = Befunge.new [[
7^DN>vA
v_#v? v
7^<""""
3  ACGT
90!""""
4*:>>>v
+8^-1,<
> ,+,@)
]]
local dnastatus = dna:run()

-- Quine
local quine = Befunge.new [[
01->1# +# :# 0# g# ,# :# 5# 8# *# 4# +# -# _@
]]
local quinestatus = quine:run()
print()

for _, s in ipairs{hwstatus, dnastatus, quinestatus} do
  assert(s == 'finished')
end

About

Befunge-93 interpreter written in Lua.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages