Heh, yeah have to agree with you but for me most books on compilers suck because I can't understand them (probably more likely that I suck)
Right, I don't understand them either.
Surely you could recommend some books on the subject that you have referenced from because you didn't just wake up one day and found out that you knew how to make a compiler. Surely you must have read some good books on compilers.
I read Jack Crenshaw's let's write a compiler. I have the dragon book but it's pure nonsense to normal people like us.
I'm actually more interested in making an interpreter, I reason that if I follow your tutorial and emulate the stack as well as other fasm opcodes in any language (not just PureBasic), that this would be possible. Is my reasoning wrong?
There's two ways to make an interpreter. On way is to compile the program like I show, but instead generate a different set of instructions (like I do, only you could make the instruction set simpler). Then you make another program to interpret these instructions.
The other way is to interpret the program directly. In this case you will have to return the return the the actual value from functions such as AddOp(). You will learn a lot from following this tutorial in either case.
I'm not going to debate with you on the pros and cons of using tree structures because this subject is way out of my depth, so I'll take your word for it that a tree structure is less intuitive.
This is my point precisely. If we a have a complicated structure that we don't intuitively understand how to process, and have a simple structure that we do now how to process, because it's a simple list, why should we do it the hard way? In our case we don't even use the list, we just output asm instructions directly. For more optimization, they can be stored to a linked list and optimizations be performed on that list.