Click here to Skip to main content
15,910,603 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
where i have to start building a compiler for C++ programming language?
what language i should use for building a compiler?


thanks
Posted
Comments
CHill60 30-Jan-15 12:21pm    
Why on earth would you want to build a compiler? Unless this is a school or college assignment - in which case refer to your course notes
rudy-peto 30-Jan-15 12:36pm    
just for fun and practicing more than what i get on college.. :)
yeah, i just heard about compiler but just dunno where to start (dunno using what language build a C++ compiler)
Sergey Alexandrovich Kryukov 30-Jan-15 15:52pm    
I guess you already created few compilers for some simple languages. If not, don't start with C++.
Besides, "where to start" is a bad question. There are many different ways to start, this is not critical.
—SA
rudy-peto 31-Jan-15 2:21am    
i start with C++ just because i like C++ so much.
because i know there are many ways to start, i got a big big confusion. am starting reading a few and hope will be a way for me to understand
Sergey Alexandrovich Kryukov 31-Jan-15 3:05am    
Sure.
I'm telling you: first, get experience doing prototype work starting from extremely simple languages. Traditionally, some old "hard" programming courses, as far as I know from books, involved some virtual toy computer modeled on a real computer, and students developed assembly programs for its instruction set and then code generation, and so on...

Good luck.
—SA

As you asked where to start I can recommend this series of articles from Crenshaw[^]

As to language - anything you like really ... back in the day the 'C' compiler was written in 'C' !

This SO Post[^] was closed as "not constructive" but does have some suggestions that would be appropriate for your question

Edit - the above SO post has now been removed - here is a similar one[^]
 
Share this answer
 
v2
Comments
rudy-peto 30-Jan-15 13:05pm    
thanks a lot! its helpful!

so, u mean C++ compiler written in C++? cause i just think its a bit weird
CHill60 30-Jan-15 20:57pm    
Yep .. I found it a bit weird back in the day when I found out that the 'C' compiler on our midi computer at Uni was ...er...written in 'C'. It was about then that I decided I wasn't interested in writing compilers ;-p
Writing a compiler is a complex task, writing a C++ compiler is a daunting task.
I would suggest you to choose a much more simple target language for starting. You probably need some background on the argument (you might start with the already suggested Creenshaw series, or check out the oldie goldie Wirth's book: "Compiler Contruction"[^], or the famous 'Dragon Book'[^]).
You may also consider using one of the many available tools for writing a compiler, e.g. flex[^] and bison[^], ANTLR[^], etc...
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 30-Jan-15 15:55pm    
5ed. Also, my advice was: implement some compilers for some extremely simple languages first.
—SA
CPallini 30-Jan-15 15:57pm    
Yes, I fully agrre.
By the way, thank you.
Sergey Alexandrovich Kryukov 30-Jan-15 16:01pm    
Oh, I don't know how I failed to see your statement "I would suggest you to choose a much more simple target language for starting." :-)
—SA
There are different open source compilers in the internet, but I would favour the LLVM, because it is a fresh and modern start, which is now productive in the XCode IDE of the Apple- world. And it rocks ;-)

Consider working on some open source project instead of starting some.
 
Share this answer
 
Comments
rudy-peto 30-Jan-15 13:09pm    
thanks! anyway i would like to know how to build that compilers and even LLVM itself.

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