[antlr-interest] Only one import level with ANTLR-3.1.1?

Laurent Caillette laurent.caillette at gmail.com
Mon Oct 27 10:25:37 PDT 2008


Hi all,

The import feature of ANTLR is great but I've found what seems to be a
bug with ANTLR-3.1.1.

Consider we have:
- A lexer grammar L.
- A parser grammar P1, importing L.
- A parser grammar P2, importing P1 (and L, but it doesn't matter here).

As a pure parser grammar, ANTLR doesn't let P1 import L. It produces
errors like this:
  error(103): P1.g:6:0: parser rule letter not allowed in lexer
The message denotes some kind of confusion because P1 is the *parser*,
so parser rules should be allowed here.

If I declare P1 as a combined grammar, ANTLR generates the code for P1
but fails on P2 as import of combined grammars is not supported. So I
see no way to go beyond one import level.

I can send some example code if needed but this should be easy to reproduce.

Does anybody know a workaround for this?

Regards,

c.


More information about the antlr-interest mailing list