[antlr-interest] ANTLR Masquerading as SED

djcordhose oliver at zeigermann.de
Mon Apr 28 02:56:51 PDT 2003


Hi all,

I may have missed something, but it occurs to me the example 
provided in the ANTLR docs is broken:

class T extends Lexer;
options {
  k=2;
  filter=IGNORE;
  charVocabulary = '\3'..'\177';
}
P  : "<p>" {System.out.print("<P>");};
BR : "<br>" {System.out.print("<BR>");};
protected
IGNORE
  :  ( "\r\n" | '\r' | '\n' )
     {newline(); System.out.println("");}
  |  c:. {System.out.print(c);}
  ;


While this example works with filter=true, i.e. pure filtering, it 
fails in this version when trying to parse "<b>" which will lead to 
a parse error instead of being filtered. Even when you set lookahead 
to k=3 the top level predictive code checks only for the first two 
chars.


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list