Compiler Creation

Started by
12 comments, last by CpMan 19 years, 7 months ago
Thanks everyone, I'm currently checking out the pdf and I'll look at the online article later. Combined with the book (if it ever gets here) I should be able to fiddle around. Thanks again!
--------------------------------------------------------Life would be so much easier if we could just get the source code.
Advertisement
Game Scripting Mastery teaches you how to build a lexer, a syntax parser and generate output, basically the main stuff a compiler will do. It doesn't use Yacc or Lex and IMHO is a good introduction to the murky subject of compiler writing.
I liked the pxdscript tutorial, but nothing beats a good book. I also suggest that you should learn flex and bison since they will make thing a lot easier.
// Javelin// Assumption is the mother of all fuckups...
Quote:Original post by Extrarius
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.


I believe GCC recently changed to a recusive descent parser, and VC++ uses a version Yacc. It's heavily optimized, so it's not slow, but over the years it's become a bit hard to read. The advantage of an automated parser is that it ensures that we have a hard time breaking someone's other grammar changes (shift reduce conflicts appear). This is nice as people move from project to project every once in a while. A recursive descent parser is faster and cleaner, however it requires more control in the development process (when you have a lot of people around), to keep it working properly
VSEDebug Visual Studio.NET Add-In. Enhances debugging in ways never thought possible.

This topic is closed to new replies.

Advertisement