Luai - Lua Interpreter

I’ve written an interpreter with a fully functioning lexer and parser. I see no actual use for it, but I thought it was a cool concept. I might make a game for this, with a script editor and output, and io.

You can get the module here and view the source here. Feel free to contribute by creating pull requests.

To run, create a script, and put this in it. At the moment, it only supports variables and printing.

local luai = require(path.to.module)

luai([[
    local my_var = true
    print(my_var)
]])

This would print “true”.

25 Likes

This is great! I think I have seen some custom load string scripts and such, but the ease of use that this provides is excellent.

1 Like

Can you upload the source to GitHub?

2 Likes

I made the repository and posted the link.

1 Like

Quick update: added support for strings and decimals.

What language is this? From the title, I thought it was a Lua code interpreter made in Roblox Luau, but it seems like it interprets JavaScript instead?

It’s not a specific language, I just chose my own syntax. I guess you could say I made my own “language”.

After reading the source, you should change your terminology here. A lexer separates groups of characters into language-specific tokens. A parser reads the tokens and returns an AST (Abstract Syntax Tree). An interpreter reads the AST top-down and execute what’s on the tree.

Yeah I was gonna make a script editor off another Lua module but this might be more efficient as the module I’m using is slower than Lua.

May I ask, what’s the speed compared to Lua and this module?

Why don’t you run a test using tick()?

I’m lazy and don’t know any slow functions

Its as simple as this:

local currentTime = tick()
wait(1)
local endTime = tick() - currentTime
print("Took "..endTime.." seconds.")

ik but idk any slow functions to see the actual result of speed

They seem to have a similar time of 0.0003 seconds.

1 Like

goodbye vlua, hello luai

1 Like

It’s not done yet. I’m reworking the parser, so there’ll be limited functions.

Could you list the following functions available or is it too much?

At the moment, you can only create variables and print to the output.

well ig I’ll stick to vlua for now until all of the functions are added

Thanks for the info

1 Like

Pretty nice! I could see some useful in-game debugging applications for this.

1 Like