[antlr-interest] Why is Filter thwarting me?

alan brown listbrownie at gmail.com
Wed Mar 5 22:53:02 PST 2008


I'm using 'filter=true' because I'm just trying to pluck out parts of the
input stream.  However, setting filter to true seems to prevent my java code
from running.  Here's an example:


grammar wibble;

options {filter=false;}

@header {package parse.grammar;}
@lexer::header{package parse.grammar;}

action            : WORD DIRT* {System.out.println("wibble");} play NL;
play            : 'bets' DIRT* NUMBER;

NUMBER            : DIGIT+ (',' DIGIT DIGIT DIGIT)* ;
WORD            : LETTER (LETTER | DIGIT)* | WORD_CHAR ;
NL            : '\r' | '\n';

DIRT            : '\'' | '|' | ' ';



fragment DIGIT        : ('0'..'9')  ;
fragment LETTER     : ('a'..'z') | ('A'..'Z') ;
fragment WORD_CHAR    : '_' | '&' | ',';

In this example I've added a definition for DIRT that catches spaces.
However, in my real project strict parsing would be a pain, so I'm fuzzy
parsing with filter=true.  My problem is that the output only produces
'wibble' if filter=false.  I've read the docs but haven't seen anything that
would explain why that would be the case.

Simply put, my question is how can I run java code from within ANTLR if I
use the filter option?

Thanks for your help.

alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080305/3bf1f861/attachment.html 


More information about the antlr-interest mailing list