• C

Compiler Building

Where can I find the best ONLINE resources for building compilers?
I am not interested in Lex, Yacc company. I need to build a small C compiler by hand from the beginning to the end.
God bless you,
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gregclauAuthor Commented:
Main emphasis on building the Lexical Analizer and the Parser
Why online only?  Are you too cheap or lazy to read/buy a book?

The best resource I've ever read is a book by James Hendrix about his SmallC compiler for the X86 processor.  I followed a series of articles in DDJ in the early '90s.  It included a great description of how the thing works and had full source code to the compiler that could compile itself.

I'm not going to bother digging up any more information on it since you want ONLINE only but I thought I'd mention it...
jhance, not all people are as rich as you are... im sorry i had to say that, but that's just the way it is!
MSSPs - Are you paying too much?

WEBINAR: Managed security service providers often deploy & manage products from a variety of solution vendors. But is this really the best approach when it comes to saving time AND money? Join us on Aug. 15th to learn how you can improve your total cost of ownership today!

not even rich with points, it seems :-)  20 points for how to build a compiler !
not even rich with points, it seems :-)  20 points for how to build a compiler !  (BTW, the answer *is* to use Lex/Yacc).

Did you try a search engine? "Compiler Writing" brought a bunch of hits, even on a search of page titles only. As did "compiler building".  O.K, a bunch of them are book reviews, so you can throw them out. It seems that you want us to wade through the search engine hots for you, for a measly 20 points.

Btw, that came over as a nasty dig at viktomet (isn't it always the way in print, rather than in person)?). I'd say that if you are capable of writing a compiler, then you're capable of getting a programming job & then shelling out 20 or 30 bucks for a book (or skip a few smokes or drinks; life's about compromises).

>jhance, not all people are as rich as
>you are... im sorry i had to say that,
>but that's just the way it is!

While it may be true that not all people are as rich as I am, I'm not proposing a major expenditure either.  Even the most expensive programming books are US$50-$60 and if even that is prohibitive, virtually all such book are available absolutely FREE at many public libraries!!
60 bucks is quiet a bit for me... yes, library is a good idea but they dont have all the books and are not up to date.. new books are brought an year or more after the release of the book so you're never up to date (usually)...

graham, stop being greedy and try to help out the individual...

gregclau, why dont you try out http://www.programmersheaven.com/

i think they have a tutorial on how to build a simple compiler (but the tutorial is for pascal programmers.. so if you know pascal you'll be on your way to building your own compiler)...

who's being greedy? I don't want/need any more points. It's just that when some college kid asks us to do his homework, we ask to see what code he's already written. I'd just like you to say "I've tried all search engines & trawled UseNet and I found nothing" (which I doubt would be true).  *Have* you tried UseNet - http://www.deja.com  ?

Just to show that I'm a nice guy, I''ll see what I can find, but will refuse any points.
No need to buy a book, all the info is on line. The easiest way to accomplish this task is to use Lex/Yacc as graham_h pointed out, unless you are just hard core and want to write your own state machine.

> library is a good idea but they
> dont have all the books and are
> not up to date..

Up to date really doesn't matter in this space - compiler theory that is not proprietary hasn't changed much, if at all, in the past 20 years or so.

In my mind, the very best book I've seen is "A Compiler Generator" by McKeeman, Horning and Wortman - Prentice Hall. (Pretty darned old, too).  I know this isn't a net resource, but it is something you are likely to find in the library.

Now they are hawking an old mainframe compiler generating program, *BUT* before they get to that, they go through, step by step, what you need to do to write a compiler.  Reading the first few chapters and doing the exercises will allow you to attack your small C compiler with confidence.
  On what platform do you want to develop?

Whatever be it Hope this helps

Tools for Compiler Writing:

1. Compiler Writing Made Easy by Charles G. Petersen


1. http://www.softpanorama.org/Bookshelf/compilers.shtml   
2. http://www.first.gmd.de/cogent/catalog/kits.html   
5. http://www2.netdoor.com/~petersen/pmpub/preface.cwme.html   
6.  http://dkiong.comp.nus.edu.sg/compilers/prelude.html  
7. http://cs.ru.ac.za/homes/cspt/compbook.htm  -  10/29/1999  
All the best,
If any thing else comes along i will pass it to you.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.