Luai - Lua Interpreter

Update

[+] Updated parser
[+] Added interpreter

Decided to do a quick test, Luai vs vLua. Here’s the results:
Luai: 0.0007014274597168
vLua: 0.0044927597045898

the e-05 in the loadstring time actually means 0.00001 so loadstring is actually over 100x faster than LuaI

1 Like

I removed that, but loadstring is exploitable so this is a better alternative, even with its limited functions.

Well, could you possibly write some grammar and standards for it?

Hard to know what’s there and what to use without a set standard or definition of namespaces, keywords, and functions in the language.

For example:

It explains how you would build a function, string, number, negative (unary), etc, etc
An example:

printStatement -> "out" expression ";"

--translates to

out(1); -- prints "1"

Luau has this in their source code (look in Parser.cpp):

  • If statement
    image

  • While and Repeat loops
    image
    image

And a little bit of information:

  • If you’re looking to BUILD a programming language/interpreter later on in the future, don’t use Luau/Lua. They lack a lot of useful features used to make one.

Anyways, nice job on this, continue doing what you’re doing :grin:

1 Like

Thanks, but it’s like loadstring. Refer to the Luau syntax.

Could you change this then if it’s related to Luau’s grammar and syntax?
Looks kind of like a mix of JavaScript and Java, so I mentioned setting a standard and giving more context on the grammar.

1 Like

My bad, I recently changed the keywords of it.

Sorry for bumping. But this seems like a great alternative to vLua! I’m gonna use this.

This is an underrated module.

1 Like

Thanks for the feedback! I’ve paused this project as I work on writing a programming language in C so I can fully understand the concept of language design (500 unfinished projects is the developer life lmao). Once I finish that, I’ll continue developing this.

1 Like

Is there a way to stop the code from accessing the game itself?

i was looking over the code you wrote and noticed a striking similarity in the code for the lexer to code I wrote a year later by myself for a toy language i was going to make, without knowing your project even existed LOL

image

I just think its pretty funny we both had almost the exact same approach :sob: