[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Lookahead -- javacc vs sablecc



Artur Rataj wrote:
Hello. I am evaluating whether to use javacc or sablecc, and I was
browsing the java grammars written in both. In javacc, there seems to
be a substantial amount of some explicit lookahead definitions, while
in sablecc I have not seen any.

What is the reason of this? Are sablecc grammars on some higher level or what?

Hi Artur,

Lookahead is same as goto statement - it means that something is (most likely) deeply messed up, and to unwind it, you need to use a hack. In sablecc you rarely "mess up" things, and, you do not need to use such a hack. Javacc is a more low level tool for the job. It happens often that you need a low level solution. Javacc might be a bit easier to understand for imperative programming model. Sablecc is easy if you use object-oriented mindset. Use sablecc. It is a nice, object oriented and strongly typed solution to parser generation. It is easy to develop and maintain your custom parser. The grammar is almost plain EBNF. The only price you will pay is in terms of performance. If you are looking for a extremely small and fast parser, that is for simple grammar - sablecc may not be the way to go. If you want complex grammar, that will be maintained and developed for a long time, use sablecc.

hth

--
mariusz