[antlr-interest] Bug report: Composite grammar with all tokens defined in Lexer

George S. Cowan cowang at comcast.net
Sun Dec 28 11:00:54 PST 2008


The same error happens with the grammar at the end of the Composite Grammar
page on the wiki.
  http://www.antlr.org/wiki/display/ANTLR3/Composite+Grammars

The CLexer.java file is not generated for the grammars as written.

But we can generate the CLexer.java file if we comment out the SPACE rule in
grammar L and, in grammar P1, change rule spaces to
  spaces: ' '+ ;

For convenience here are the files that I copied from the Composite Grammar
page.

-------------------- begin L.g --------------
lexer grammar L ;

LETTER : 'a'..'z' ;
SPACE : ' ' ;

---- begin P1.g (note: changed grammer to grammar) ---
parser grammar P1 ;

letter : LETTER ;
spaces : SPACE+ ;

--- begin P2.g (note: changed grammer to grammar) ---
parser grammar P2 ;
import P1 ;

letters : letter+ ;

--------------- begin C.g ---------
grammar C ;
import L, P2 ;

stuff : ( letters spaces )+ ;

--------- end grammar files ------------

I ran my tests on Windows XP using the command line
  java -cp C:\Java\ANTLR\antlr-3.1.1.jar org.antlr.Tool -o work C.g.


Regards,
George



More information about the antlr-interest mailing list