I'm currently diving into creating my own programming language called CheechLang (.chl) using Lua. My idea is to have a for loop running through every line of code. Each line will specify the library being used, and the interpreter will read these lines to translate the code into Lua or Bash, though Lua is my main focus.
Here's a simple example of what a 'Hello World' program would look like:
01 Program helloWorld
05 print *, "Hello World!"
04 endl
01 End Program helloWorld.
I'm looking for advice on how to approach this process effectively!
4 Answers
Starting out, it's crucial to define a clear grammar for your language and build a parser based on that. Having users input numbers like 01, 05, and 04 can be kinda verbose—why not just use Lua directly if it’s going to look that way?
Consider writing your language's grammar in Backus-Nauer form to make foundational decisions easier. Also, what happens if a line requires multiple libraries? It seems limiting to force users to include libraries on every line, and numbering instead of naming commands feels odd.
Check out 'COMPILER CONSTRUCTION: Principles and Practice'—it’s a fantastic resource for learning to create your own programming language. Plus, some universities offer courses on compiler construction that could really aid your journey!
Thanks! I'm just experimenting with this right now, so I’ll consider compilers later.
I'd recommend reading 'Crafting Interpreters' by Bob Nystrom, available online for free. It walks you through creating a language in Java first and then in C. That’ll give you a solid grounding before you launch into your own project.
Appreciate the suggestion!
I plan to have the parser handle library readings, which should help with command usage.