Click here to Skip to main content
15,891,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,how has book for build c++ compiler?
please help me and i want lexical syntax & generation codt to build compiler.
it is important,because i search about it in the net but i don't find the code so please help me
Posted

There are several good books on writing compilers (see, for instance the classic 'teoric' Dragon Book[^] or 'more pragmatic' Fraser and Hanson's one[^]).
It is worth noting that building a C++ compiler is a daunting task (C++ is a damned complex language).
 
Share this answer
 
v2
Comments
Sandeep Mewara 31-May-12 15:58pm    
5!
There's only been one person in the history of mankind to have built a C++ compiler single handed, Walter Bright [1]. So I wouldn't even try yourself. He wrote a C compiler, saw a copy of the C++ Annotated Reference Manual, said "how hard can this be?". A couple of years later he'd found out how hard but had a working compiler [2].

If you want the brain bending theory, have a look at the references CPallini gave you. If you want to see how a real compiler works in all it's ugly glory have a look at g++[^]. The code is really nasty but will show you the sort of things you have to do to parse C++ - the code generation is actually the easy bit!

And if you're feeling really flush Walter Bright is selling the source for his C++ compiler for $59[^] - worth a punt if you're serious.

Anyway, the point here is if you want to modify a C++ compiler to do something it doesn't already do grab g++ and hack on that. If you're trying to research how compilers work and implement a simple one then start with something VERY easy to parse like this.[^]

[1] To head this one off at the pass Bjarne Stroustrup wrote Cfront way before Bright wrote Zortech C++. However Stroustrup was implementing a lot simpler language then. By the time the team at AT&T got to the same level as Bright's compiler there were four of them working on it.

[2] This information was from a personal conversation in April 2010 at the ACCU conference during a seminar he gave on compiler design.
 
Share this answer
 
Comments
Sandeep Mewara 31-May-12 15:59pm    
5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900