[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Performance of SableCC v ANTLR
I'm no expert on compiler design. I do have several books on the subject,
including the Dragon book, which I refer to with varying degrees if
understanding. I have written several "toy" compilers over the years.
For the last two months I've been writing a compiler for a language which is
similar to Pascal but with lots of initializers for data and types.
I started from the EBNF specification for the language using javaCC. I used
this because it gave the greatest number of hits on Google - so I figured it
must be good!
I found I just couldn't get on with the javaCC syntax. It makes yacc look
readable. I went looking for something else and discovered SableCC.
Compared to javaCC Sable is a like a breath of fresh air. Easy source syntax,
visitor pattern design, strong typing on the AST, good error reporting.
Within a few weeks I had my front-end running and was starting coding a
It was only when I started to compile larger programs (>250 lines) that I
noticed that the compilation was taking several seconds on a 2.1 Ghz PC. This
worried me greatly.
For comparison I've re-coded the front-end with ANTLR. The ANTLR syntax is not
as nice as SableCC but bearable. It's taken me probably three times longer to
understand ANTLR and code up the front-end. I use a strongly typed AST and
visitor pattern just like SableCC produces except with ANTLR I needed to hand
My observations so far are that the ANTLR front-end runs more than five times
faster than the SableCC equivalent. SableCC produces 445 AST node types
for the grammar, the ANTRL solution just 77.
At the moment I'm sticking with ANTLR.
Can I ask is SableCC intrinsicly slower than ANTLR?
Has anyone else had similar experiences?
Does anyone know of any SableCC based "full" compiler solutions, not a
language sub-set, that I can look at for camparison? Preferably for one of
the standard languages.