What’s the best way to start creating my own programming language?

0
8
Asked By CuriousExplorer42 On

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

Answered By TeachMeLangs On

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?

Answered By SyntaxNinja On

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.

CuriousExplorer42 -

I plan to have the parser handle library readings, which should help with command usage.

Answered By BookWormCompiler On

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!

CuriousExplorer42 -

Thanks! I'm just experimenting with this right now, so I’ll consider compilers later.

Answered By NerdyInterpreter On

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.

CuriousExplorer42 -

Appreciate the suggestion!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.