Jump to content
  • Advertisement
Sign in to follow this  
Venerable Vampire

Compiler Creation

This topic is 5470 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
There are tons of tutorials online on the subject, but IMO not a single one of them is good. If you look over some of the threads I've started using my profile, you'll get some suggestions on books and the like if that is what you're after.

Share this post


Link to post
Share on other sites
Quote:
Original post by Venerable Vampire
Life would be so much easier if we could just get the source code.
this->omnipotent = true;
ROFL - Nice line!

Learn Flex and Bison. They make compiler creation far quicker and the end result is faster too.

Share this post


Link to post
Share on other sites
Quote:
Original post by iMalc
Quote:
Original post by Venerable Vampire
Life would be so much easier if we could just get the source code.
this->omnipotent = true;
ROFL - Nice line!

Learn Flex and Bison. They make compiler creation far quicker and the end result is faster too.


While flex and bison are easy, they aren't the best things to actually learn how a compiler works with. Plus, they can be very very difficult to maintain. After working on the VC++ compiler for a summer (great time at it), and comparing it to the C# parser, I hate shift/reduce conflicts even more. I would learn a recursive descent parser. It's more intuitive and shows the concepts better, in my opinion.

Share this post


Link to post
Share on other sites
Quote:
Original post by iMalc
[...]Learn Flex and Bison. They make compiler creation far quicker and the end result is faster too.
CpMan is correct, but he left out the fact that you still have to know how a compiler works pretty much to use them properly and efficiently.

I opted not to use compiler compilers because they all spit out really ugly code with a very poor style that doesn't mesh with anything I've been working on. It seems to me that they are meant for standalone compilers that perform simple translations more than scripting libraries or things like that.

Share this post


Link to post
Share on other sites
Quote:
Original post by CpMan
I would learn a recursive descent parser. It's more intuitive and shows the concepts better, in my opinion.


Agreed. I used "Compilers - Principles, Techniques, and Tools" (commonly called the Dragon Book) as a reference at uni when we studied compiler construction and found it to be a great book. Simple compiler construction is not that difficult especailly when broken into steps. First we defined our grammar, then made a tokeniser/scanner and once that was working a recursive descent parser.

Mike

Share this post


Link to post
Share on other sites
Let's Build a Compiler, by Jack Crenshaw

I can't say its the best resource I've found, but its pretty good.

I've heard great things about the dragon book mentioned above, and the book "Game Scripting Mastery" by Alex Varanese has proven itself quite good in my own experience. Check them out if you're able.

Share this post


Link to post
Share on other sites
Quote:
Original post by Extrarius
I opted not to use compiler compilers because they all spit out really ugly code with a very poor style that doesn't mesh with anything I've been working on. It seems to me that they are meant for standalone compilers that perform simple translations more than scripting libraries or things like that.
Why would you want to read the generated code in the first place?
You can't touch it anyway since it'll be regenerated any time you make a change to the syntax script.

Oh, and many complex compilers use them (GCC is a good example).

Share this post


Link to post
Share on other sites
Quote:
Original post by doynax
[...]Why would you want to read the generated code in the first place?
You can't touch it anyway since it'll be regenerated any time you make a change to the syntax script.

Oh, and many complex compilers use them (GCC is a good example).
Because if it the compiler is going to be part of one of my projects, I'd have to integrate it cleanly into the rest. Just putting stuff in the code they spit out wouldn't work, because for ex I'd want the Compile() and Execute() functions to be part of a class that maintains state information that would be used when compiling/executing/etc. I'd also want them to be thread-safe (not sure if the code they generate is or not), and stuff like that.
The generated code would have to fit into and work with the rest of my code. In other words, they were not suitable to my needs, which is why I didn't use them.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!