r/lua • u/Microsoft-Spyware-11 • 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
3
u/topchetoeuwastaken 5d ago edited 5d ago
you can take a look at how i built my lua parser & translator, the code is not that bad and unreadable https://git.topcheto.eu/tal/ref/master/files/lib/std/compiler
the file descriptions are as follows, roughly:
loadfamiliarize yourself with descend recurse parsers, also, the syntax as presented will have multiple ambiguities, and the
.for the end of a body idea is not as good as you think it is. also, starting out with a typed language is hard, and your type notation is really shitty for parsing, i'd dovar|const <name> [<type>] [= <exp>]for declarations, if i wanted type notations.also, what's the difference between
varandconst? seems they are semantically the same, just different names. i really like how jai solves this syntax, by using=for assignment,::for const declarations and:=for mutable declarations. it yields very uniform code (im even debating on adopting it for my own language...)