[antlr-interest] v3: can't seem to work out filter=true
    Mark Mandel 
    mark.mandel at gmail.com
       
    Mon May 28 17:52:22 PDT 2007
    
    
  
Heya,
I'm trying to wrap my head around filter=true, and failing.
I'm currently just trying to implement a grammar that will pick up
<tag> 's anywhere in a string, regardless of the string.
I figured a perfect opportunity for filter=true, which I had thought
would ignore what I didn't want, and allow me to filter down a list of
intended tokens in order (which is very handy).. but I can't seem to
get it to work for me.
When I do a test string of '<h>' against the below grammar, I get a
TokenException, but if I take out the filter=true, then it works
fine... I'm confused?
Can someone please point me in the right direction?
grammar TAG:
options
{
	output=AST;
	filter=true;
}
/* Parser */
basicTag
	:
	TAG_OPEN TAG_CLOSE
	;
/* Lexer */
TAG_OPEN
	:
	'<'TAG_NAME
	;
	
TAG_CLOSE
	:
	'>'
	;
	
/* fragments */
fragment TAG_NAME
	:
	(LETTER)(LETTER | DIGIT | '_')*
	;
fragment DIGIT
	:
	'0'..'9'
	;
fragment LETTER
	:
	'a'..'z' | 'A'..'Z'
	;
/* hidden tokens */
WS
	:
	(' '|'\r'|'\t'|'\u000C'|'\n')
	{
		$channel=HIDDEN;
	}
	;
Thanks,
Mark
-- 
E: mark.mandel at gmail.com
W: www.compoundtheory.com
    
    
More information about the antlr-interest
mailing list