Hi, I attempted to write my own language a while ago but I really got lost in complexity.
I'd really appreciate it if you could share any resources (tutorials, websites, etc) that you used, or if there was any really useful resources on writing a compiler or interpreter?
Hi mike, I would love to be able to post a long list of resources that I used when making the compiler, but the truth is, there aren't any good ones out there.. Before starting the compiler, I set out to find as many tutorials, guides, and other resources on how to go about making my own compiler...but I found nothing of use. Most of the time spent programming the compiler, I was offline, on my laptop, so I didn't have resources to go to..
The most important thing I have found with the project, and with many others, is to draw a diagram of how it is all going to work. With pseudo-code dotted around it if you think it will help to develop the diagram.
This is how OXY works right now.
1) input a text file with code in it
E.g. If (1==2) say(hi);
2) read the text file word by word (stopping at "; (" (those three characters, not the smily))
3) interpret the read data and add a branch to an element tree with the type of command, and any extra data (parameters)
4) walk through the generated tree, branch by branch, and output as a byte stream.
5) save the byte stream to a file. (This is your executable byte stream. Encrypt/compress/pack however you like now)
6) runner loads the executable byte stream and walks through it, executing what it says.
In essence, this is how OXY works, there are of course special cases (functions/classes) but those get coded in later ;)