[antlr-interest] ANTLR or java

Martin Probst mail at martin-probst.com
Fri Jul 22 06:18:16 PDT 2005


Hi,
> 
> As I'm newbie to ANTLR, I wonder whether I have to write a grammar and
> use ANTLR,
> or simply use java (because I don't want to rewrite code like a
> function to add integers...).

The question is probably which way is simpler. With ANTLR you'll have
the learning curve, but a much easier way to write and maintain grammars
& lexers, especially for complex languages.

Just think about what you would have to do to write the recognition and
handling in Java instead of using a tool. If it's getting awkward and
complex (e.g. more than some regexp hacks and 300 SLOC), then probably
better use ANTLR.

A hint may be that if your language is freely composable (e.g. you can
write "foo AND bar" but also any nesting of "foo AND (bar OR baz AND
whatnot)", then ANTLR will probably safe you from a lot of complexity.

> Can anyone give me a starting point to achieve this ?

Look at the examples, they'll show you how to define your keywords and
compose a grammar.

Martin



More information about the antlr-interest mailing list