Simon Kwong said:
Hi,
I am learning c++ and would like to write a simple C++ compiler. How should
I start?
Please help.
Simon
Compilers in general, and C++ compilers in particular, are among the most
complex pieces of software out there. If what you implement is truly C++ in
its entirety, you will have created a *very* non-trivial piece of software.
A small subset of C++ would be much more manageable. Specifically, I would
leave out inheritance, templates, namespaces and exceptions for sure and
would pick-and-choose other stuff to leave out. I suggest starting by
taking a university course in compiler construction. Make sure it's a
course that involves a project (any decent course will). After such a
course, you will realize that you are still a long way from being able to
write a C++ compiler.
As a point of interest and curiosity, can anybody think of problem domains
more complex than full-fledged optimizing compilers for extremely robust
languages such as C++? Of course, "complex" is subjective, but I suppose a
reasonable interpretation would be that in addition to being large (i.e. a
large number of lines of code are necessary) an in-depth knowledge of
several areas of Computer Science is required (formal languages, parsing,
classic algorithms / data structures, architecture, etc...).