[antlr-interest] ANTLR Masquerading as SED

Terence Parr parrt at jguru.com
Mon Apr 28 08:58:02 PDT 2003


On Monday, April 28, 2003, at 02:56  AM, djcordhose wrote:

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

I'm pretty sure it's ok.  Note that when it fails to find something 
that matches, it REWINDS the input and jumps to the filter rule, 
IGNORE. :)

Should work for anything k>=2 :)

Ter

>
> 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/
>
>
>
--
Co-founder, http://www.jguru.com
Creator, ANTLR Parser Generator: http://www.antlr.org
Co-founder, http://www.peerscope.com link sharing, pure-n-simple
Lecturer in Comp. Sci., University of San Francisco


 

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




More information about the antlr-interest mailing list