Maintainable compiler design?

=?ISO-8859-1?Q?Christoffer_Lern=F6?= <>
Mon, 27 Jul 2009 14:16:08 -0700 (PDT)

          From comp.compilers

Related articles
Maintainable compiler design? (=?ISO-8859-1?Q?Christoffer_Lern=F6?=) (2009-07-27)
Re: Maintainable compiler design? (Michiel) (2009-07-29)
Re: Maintainable compiler design? (BGB / cr88192) (2009-07-29)
Re: Maintainable compiler design? (Martin Ward) (2009-08-06)
Re: Maintainable compiler design? (James Harris) (2009-08-06)
| List of all articles for this month |

From: =?ISO-8859-1?Q?Christoffer_Lern=F6?= <>
Newsgroups: comp.compilers
Date: Mon, 27 Jul 2009 14:16:08 -0700 (PDT)
Organization: Compilers Central
Keywords: design, question
Posted-Date: 29 Jul 2009 08:37:47 EDT

I am working with my pet language, defining grammar, building runtime
etc - the usual things.

However, as this is my first complier, I am worried that I'm not
organising the code well. Aside from the frontend/backend division, I
feel the compiler books I red are sort of hazy in regards to how to
solidly organize the compiler to ensure that it is easy to maintain.

Currently I am working with ANTLR on the grammar, while I'm writing
the runtime in C. My idea was to make the first version of the
compiler with ANTLR in Java (striking a compromise between ease of
implementation and performance).
I have also played around a bit with Flex and Bison as well as Racc
and Rex on the ruby side, but ANTLR felt pretty easy to work with, esp
with ANTLRWorks for debugging grammar.

Most compiler books by necessity run rather limited examples where
code generation is done directly by emitting strings by walking the

That sounds reasonable for small language examples, but would seem
like it would be quite a nightmare to walk through for a larger
language. Looking through the ANTLR docs, there are examples where
they run their generated AST through multiple rule definitions to do
optimizations and finally generation, which seems like a good idea.

Are there any best practices to keep the compiler easy to understand
and well organized?


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.