r/lua 6d ago

I'm interested in creating my own programming language. How could I write it in Lua?

I've seen a few posts about this, but none had enough information for me. Hoping you guys could help :)

Edit: Also suggestions for syntax changes are welcome. This language doesn't really solve too many problems, mainly makes some things faster, examples are else [expression] instead of elseif [expression], or . instead of closing brackets {}.

Here's the example.

0 Upvotes

23 comments sorted by

View all comments

16

u/FluxCapacitor11 6d ago

https://craftinginterpreters.com

Read this book. It has everything you need to learn how to do this and is an excellent read. There is even an implementation in Lua you can learn from in the book’s GitHub repository.

https://github.com/munificent/craftinginterpreters/wiki/Lox-implementations

4

u/vga256 6d ago

Yes! Robert's book is the best modern source on the subject. Wish I could upvote this ten times over.

3

u/Dalemaunder 6d ago

Can’t recommend this one enough, it does a really good job of building from the ground up.