[antlr-interest] Import problem

Andrey Breslav abreslav at gmail.com
Thu Aug 21 02:04:31 PDT 2008


Hello everybody.

I've just switched to ANTLR 3.1 for its beautiful grammar reuse
feature. But I'm stuck with the following problem.
Having the following three grammar descriptions

---A.g

grammar A;

import B, C;

superRule : TOKEN rule;

---End of A.g

---B.g

lexer grammar B;

TOKEN : 'x';

---End of B.g

--C.g

parser grammar C;

import B;

rule : TOKEN+;

---ENd of C.g

I get the following errors from ANTLR:

    [java] ANTLR Parser Generator  Version 3.1 (August 12, 2008)  1989-2008
     [java] error(103): B.g:5:0: parser rule rule not allowed in lexer
     [java] error(103): B.g:5:0: parser rule superRule not allowed in lexer
     [java] error(102): C.g:3:0: lexer rule TOKEN not allowed in parser
     [java] error(102): C.g:1:0: lexer rule Tokens not allowed in parser
     [java] Java Result: 1

Looks like ANTLR thinks I've included B into C and vice versa . Is it
a bug or I am doing something wrong?

Thank you.

--
Best regards,
  Andrey


More information about the antlr-interest mailing list