Search code examples
c++compiler-theory

What knowledge is required/recommended before approaching compiler development?


There is a question on stackoverflow about Learning to write a compiler. I have looked at it and I think it's an undertaking I want to tackle. I think (like many others) the knowledge will be invaluable to a programmer. However, my skills are primarily in C++ and I would say I am very comfortable with the syntax of the language and some basic algorithms and design concepts, but I am by no means a seasoned programmer. My only programming experience comes from academic textbooks at the college level and the completion of introductory/intermediate courses (300 level classes). Hence, the rise of my question.

With only a general knowledge of the C++ language and no Assembly knowledge, would a book aimed at the theories and workings of a compiler and the implementation of those theories, such as the book Compilers: Principles, Techniques, and Tools (2nd Edition), be difficult for me to understand?


Solution

  • I would recommend you start with an interpreter first as you don't need proprietary hardware knowledge to implement it. The key concepts are usually how is the language defined, what makes a statement, building parse trees, etc... The hardware knowledge to me is secondary than actually understanding how to read and evaluate the statements.

    What I did when learning was write a small interpreter for a Pascal like language and started small with simple statements and variable storage and slowly added different things to it as I got better.