[antlr-interest] Antlr does not generate Lexer from a composite grammar
Ranco Marcus
ranco.marcus at epirion.nl
Mon Jan 25 02:35:56 PST 2010
I experienced the same problem and did not find a proper solution for it. As a work-around, I have found that adding a dummy lexer rule to the composite grammar causes the lexer to be generated.
grammar C ;
import L, P2 ;
stuff : ( letters spaces )+ ;
dummy : 'DUMMY';
In general, I would expect that no parser or lexer rule is required in the composite grammar. This way, we can use the composite grammer only as a way to glue things together and specify generation options for a particular use.
I hope this is of any help to you.
Best regards,
Ranco Marcus
From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Stevenson, Todd (GE Healthcare, consultant)
Sent: dinsdag 1 december 2009 19:09
To: antlr-interest at antlr.org
Subject: [antlr-interest] Antlr does not generate Lexer from a composite grammar
I built the grammars described at the bottom of the Composite Grammars page of the Antlr documentation(i.e. L, P1, P2, and C). When I run Antlr with no command line arguments on the combined grammar 'C', it generates C_P1.java, C_P2_P1.java, and CParser.java, but does not generate CLexer.java. Is this correct behavior? If so, how to I call the lexer from my source java program?
When I build the other grammars on that page (Root and Delegate), and run Antlr on 'Root', it generates RootParser.java Root_Delegate.java and RootLexer.java.
thanks.
I tried it with Antlr 3.2 and Antlr 3.1.3.
More information about the antlr-interest
mailing list