[antlr-interest] Using ANTLR 3.1 to parse macros (for a Macro Assembler)

Gavin Lambert antlr at mirality.co.nz
Wed Oct 1 02:01:57 PDT 2008


At 16:54 1/10/2008, Wayne Venables wrote:
 >In ANTLR3, how do I get the parser to switch to a new lexer
 >in the middle of the processing and then retry the match?  Or
 >is there a different/better way of handling this in ANTLR3?
 >I'm using the CSharp target.  So far I haven't had any luck
 >with the book, the online manuals, or google.

If you can unambiguously detect that you need to switch over while 
in the lexer, then you can have a look at the 'island-grammar' 
example in the ANTLR examples pack.  This is by far the simplest 
method.

If things are sufficiently ambiguous that you can't decide until 
the parser, then have a look at this:
   <<http://www.antlr.org/wiki/display/ANTLR3/Island+Grammars+Under+Parser+Control>http://www.antlr.org/wiki/display/ANTLR3/Island+Grammars+Under+Parser+Control>



More information about the antlr-interest mailing list