4

I want to write my own compiler for my own language. Yes, it's going to be hard, and it will take long, but I think it will be worth it.

I have looked into OSDev.org, and read about executable formats there, but they aren't much help. I am looking for information beyond what they have there.

So, anything will help. Books, websites, PDFs, anything.

I am looking into 32-bit, not 64- or 16-bit.

gnat
  • 21,442
  • 29
  • 112
  • 288
Marcus
  • 65
  • 1
  • 1
  • 2
  • http://meta.stackexchange.com/questions/25840/can-we-stop-recommending-the-dragon-book-please. He gives a list of stackoverflow posts that will answer this question. He's not downvoted because of the list (the list of posts are useful). – jmq Mar 02 '12 at 23:27
  • Hello Marcus Szanto and welcome to Programmers! This is an extremely broad question, and can not be reasonably answered. Please do some research of your own, and when you start building your compiler feel free to ask specific questions. – yannis Mar 02 '12 at 23:54

1 Answers1

2

I would think the best place to start in practical terms would be a solid foundation in using lex and yacc (or flex and bison), since these are likely the tools you'll use to actually build the compiler. There's a tutorial here, and O'Reilly has a great book about them.

From a theoretical standpoint, you'll want to study compiler design. Google turns up plenty of quality resources, but the the classic book on the subject is Compilers: principles, techniques, and tools by Alfred V. Aho. I can't recommend it highly enough.

Jason Lewis
  • 2,113
  • 13
  • 18
  • Also look into http://lambda-the-ultimate.org and read books like http://www.cs.rochester.edu/~scott/pragmatics/ & http://pagesperso-systeme.lip6.fr/Christian.Queinnec/WWW/LiSP.html – Basile Starynkevitch Mar 03 '12 at 21:49
  • 1
    Personally, I think you learn more from a hand-crafted lexer and recursive descent parser. Symbols, types and fragments are where the fun is. I dislike Aho, but it is unavoidable. Lambda is a better home than here for inhaling the essence. – david.pfx Mar 26 '14 at 13:50