[antlr-interest] ANTLR3 Nested parser

Harald M. Müller harald_m_mueller at gmx.de
Mon Jan 21 22:24:38 PST 2008


I wouldn't do it like this.
If you want to really do this in the (non-nested) lexer: "Lex" the symbol;
and then start a NEW StringReader on the symbols's getText(), from which you
feed your (nested) lexer and parser.
Maybe you want to do this in the (non-nested) parser ... easy if the symbol
turns up there; a little work if you pushed the symbol into the HIDDEN
channel (or some other channel) in the (non-nested) lexer, so that you have
to "undig" it somehow in the (non-nested) parser
Hope this very short explanation helps.
Regards
Harald

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org 
> [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Bertalan Fodor
> Sent: Tuesday, January 22, 2008 12:45 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] ANTLR3 Nested parser
> 
> Hi,
> 
> I'm creating a parser with nested parser. To make it simple I 
> tell you my problem as if I was doing Javadoc parsing inside 
> a Java parser.
> So I have this in my lexer:
> JAVADOC: '/**' { JavadocParser javadocParser = new 
> JavadocParser(new CommonTokenStream(new 
> JavadocLexer(this.input))); javadocParser.rootRule(); }
> 
> The problem is that while this code correctly switches to the 
> Javadoc lexer, and parses the Javadoc parts correctly, upon 
> returning from the Javadoc parsing, the character stream is 
> not correctly positioned.
> 
> Can you help me how to achieve the nested parsing in antlr 3?
> 
> Thank you very much,
> 
> Bertalan Fodor
> 
> ps I've already asked this on this list, but got no answer, 
> so I tried to make my question more simple.
> 



More information about the antlr-interest mailing list