Reusable and replaceable compiler parts

leszekp at Safe-mail.net leszekp at Safe-mail.net
Mon Aug 20 05:18:52 PDT 2007


Hello

A "classic" compiler, javac more or less too, is composed of a few parts:
- lexer (scanner)
- parser
- semantic checker - in javac it is done by tree walkers
- optimizer, tree transformer, etc
- code generator

If an api to above parts/modules existed they might be reused separately.
Possible uses are in example:

- replace lexer and parser by other ones. This way various frontends may
be constructed, in example ruby, python, scripting languages etc
- bypass parser, directly construct abstract syntex tree, may be used
by a jsp compiler
- replace backend, output to another language instead of bytecodes

Of course an interface to compiler parts should be standarized somehow.
Abstract syntax trees probably should be modelled less around java syntax
and more around jvm operations. I think modularization it's the future of
compiler tools in general as there will be more and more demand for
domain specific languages.

Leszek Piotrowicz



More information about the compiler-dev mailing list