[antlr-interest] ANTLR 3: Problem with separated lexer / parser
Terence Parr
parrt at cs.usfca.edu
Sat Sep 10 10:51:42 PDT 2005
On Sep 9, 2005, at 9:26 AM, Oliver Zeigermann wrote:
> When lexer and parser are specified in different files I find no way
> to tell the parser to use the token vocabulary of the lexer. Doing
> something like this
>
> grammar XMLParser;
> options {
> tokenVocab=XMLLexer;
> }
Yep, I made it a one-way street.
> where the lexer is called XMLLexer sort of seems to work, but ANTLR
> still complains like this
>
> xmlParser.g:10:38: no lexer rule corresponding to token: VALUE
> xmlParser.g:25:20: no lexer rule corresponding to token: PCDATA
>
> which makes me suspicious that maybe it only worked incidentally.
>
> Any hints?
You have previously generated the lexer and so the vocab file
exists. Since you called the XMLParser a combined grammar it is
properly warning you that have not defined lexer rules. :) Try:
parser grammar XMLParser;
options {
tokenVocab=XMLLexer;
}
and joy shall be yours! (I hope) ;)
Ter
--
CS Professor & Grad Director, University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com
More information about the antlr-interest
mailing list