[antlr-interest] Whitespace is significant sometimes

Daniel Lidström daniel.lidstrom at gpsgate.com
Tue Sep 28 02:46:55 PDT 2010


From: "Loring Craymer" <lgcraymer at yahoo.com>
> This is the sort of problem that can be solved with lexer modes.  ANTLR 3 
> does
> not support lexer modes, however, so the usual approach is two phase 
> parsing,
> where the first pass would parse text outside of [ ] but recognizes [ 
> ... ]
> constructs as single tokens.  The second pass processes the text inside of
> braces.  Not pretty, but it works.  Trying to implement something which 
> requires
> feedback between parser and lexer is a bad idea, even if you can get it to 
> work:
> the resulting grammars will be very fragile.
>
> --Loring

Hello Loring. I was just about to implement my scheme when I realized just 
what
you are saying. The approach you suggest does seem a lot easier. I figured I 
can
use semantic actions at each rule to build an expression tree of my own 
classes.
Then I can build a special node that handles the "inner" grammar of variable 
rules ([xxx]).
Sounds reasonable to me, at the moment anyway.
Thank you for your suggestion!

Daniel
 



More information about the antlr-interest mailing list