[antlr-interest] Re: problem with composing grammars: th anks and comments 
Gavin Lambert
antlr at mirality.co.nz
Thu Jul 24 04:56:00 PDT 2008
At 21:42 24/07/2008, Jean-Claude Durand wrote:
>Here are my comments:
>- putting the lex grammar as the first import does not help;
>- So, as you said, I declared the the 'lexer grammar' as
>'grammar'
>and run ANTLR on it, and also on the "composed grammar". Thus I
>got
>all the files (even one parser more, I do not use in compiling);
It makes sense that you can't compose lexer and parser grammars
together; they're quite different animals.
Instead of trying to do that, keep your lexers and parsers
separate. I guess you could still compose multiple lexers
together and compose multiple parsers together, but don't try to
mix lexers with parsers.
>- the remaining problem, is that the definitions of the tokens
>( #define ...) are not the same in the different .h files (see
>my
>example below) and
>some are missing. I just have to modify the files with the
>definitions given by LexLexer.h or LexParser.h, and it works !
You need to use the importVocab option in your parser to load the
.tokens file generated by the lexer. Then the definitions will
match.
More information about the antlr-interest
mailing list