1

Guys what are the best Online resources for learning Compiler Design ?

Would Perl be a viable language to write a Compiler ?

vitaut
  • 43,200
  • 23
  • 168
  • 291
Geek
  • 22,484
  • 20
  • 70
  • 85

5 Answers5

4

Software optimization resources is a must read before design a compiler. It has important documents about code optimization.

Maniero
  • 9,241
  • 6
  • 39
  • 78
4

Rather than online, as mentioned in the above answer, grab yourself a copy of the Dragon book Compilers: Principles, Techniques, and Tools. A copy of the first edition shouldn't set you back too much.

Not sure about Perl as a language of choice for implementing a compiler though.

GEOCHET
  • 20,745
  • 15
  • 72
  • 98
Rob Wells
  • 35,340
  • 13
  • 80
  • 146
  • 5
    A contrary view: the Dragon Book is a very hard read and does not cover the simplest method of compiler construction, recursive descent, in any detail. Avoid. –  Jun 12 '09 at 09:46
  • @Neil, I'd agree that it's not an easy read but then it's not a book for reading cover to cover. It does cover lots of topics salient to compiler design though. There must be a reason this book has been the compiler bible for the number of years that it has. (-: – Rob Wells Jun 12 '09 at 10:23
  • 3
    People keep recommending it, for reasons I frankly cannot fathom. I suspect most have not read it. –  Jun 12 '09 at 10:25
  • @Neil, true. like those people whose bookshelves are laden with programming books and when you pull one down to have a look it's in perfect unopened condition. Jees, my copy has those little post-it bookmark things coming out its arse! (-: – Rob Wells Jun 12 '09 at 12:16
2

Some things are not best learned on-line, and something of the complexity of compiler design is one of them. For a list of books on the subject, take a look at this question. I selected it more or less at random from a lot of similar questions - to get a list of them all, Google for

site:stackoverflow.com compiler design books

As for perl as a suitable language - yes, you can write a compiler in Perl, but I personally wouldn't like to try it. If I were you I'd take a look at something a bit cleaner, like Python.

Community
  • 1
  • 1
1

Jack Crenshaw wrote a great series on compiler construction - find it at http://compilers.iecc.com/crenshaw/ (examples are in Pascal, but still very useful).

There is also a c version floating around somewhere, but I can't find the link to it atm (someone else ported all the code in the articles into ANSI-C).

Community
  • 1
  • 1
a_m0d
  • 11,794
  • 15
  • 54
  • 77
0

I originally learned perl because I thought it might have a yacc in it.

It doesn't.

While I'm sure there are modules to add this sort of behaviour, and Perl 6 looks like it might be better in this regard, you would do well to study lex and yacc (or bison) instead.

I'm still glad I learned perl, though.

Alex Brown
  • 40,336
  • 10
  • 90
  • 107