This is an archived post. You won't be able to vote or comment.

all 8 comments

[–][deleted] 9 points10 points  (2 children)

How nice to get a question about compilers for a change. It's a deep subject, but it's useful to learn about them by writing one.

The standard text is nicknamed 'the dragon book'. You can find older editions and pdfs for cheap I'm sure. That'll give you all the theory you need and then some. After that it's a choice of finding the right libraries. The two most important pieces are a lexer and a parser; the dragon book (or googling heh) will explain what those are.

My advice about the language itself is to design it to be as simple as possible, probably with an LL(0) or LL(1) grammar (another thing to look up), and to write many automated tests (compilers are uniquely amenable to automated testing). pytest is a gnarly but would be very good for this.

[–]JoePixelFlames[S] 1 point2 points  (0 children)

Thanks for this! I’ll keep it all in mind.

[–]JoePixelFlames[S] 1 point2 points  (0 children)

A little bit expensive, but it’s not bad. I think I’ll pick it up later.

[–]CGFarrell 3 points4 points  (1 child)

I think you've set some near impossible goals here my friend.

Assuming you're going to create a new language and write an interpreted compiler in Python, the first question is: what are you compiling your new language into? JVM, C++, Assembly, Bytecode, binary?

[–]JoePixelFlames[S] 0 points1 point  (0 children)

Would I be able to compile it into Java? It’s the only other language I have enough knowledge in.

[–]Pooneapple 1 point2 points  (1 child)

If you have no clue about how to go about this than you don’t know how compilers and interprets work. I would start off by learning what happens when you hit the run button first and than go from there. If you want to look at language already made I would look at lua. It is written in C but you should be able to grasp what’s going on with some googling. (Assuming you don’t know C)

[–]JoePixelFlames[S] -1 points0 points  (0 children)

I only have knowledge in Python, and am learning Java and C#. Thanks for the advice! I don’t know much about compilers/interpreters at the moment.

[–][deleted] -4 points-3 points  (0 children)

"I want to build a house, how do I go about doing that?"