Reputation: 340
I write options{filter=true;}
in lexer grammar file and compile it with ANTLR4.
It said
unsupported option 'filter'
It seems 'filter' only works with ANTLR3
I checked wiki http://www.antlr.org/wiki/display/ANTLR4/Options and can not find the answer. 'filter' key word is not in the source file https://github.com/antlr/antlr4/blob/master/tool/src/org/antlr/v4/tool/Grammar.java either.
How could I fix this?
Upvotes: 2
Views: 806
Reputation: 170158
There is no filter
option in ANTLR 4 lexer grammars. However, it is easy to mimic this behavior as follows:
lexer grammar L;
RULE
: [a-zA-Z]+
;
FILTER
: . -> skip
;
which is equivalent to the ANTLR 3 lexer grammar:
lexer grammar L;
options {
filter=true;
}
RULE
: ('a'..'z' | 'A'..'Z')+
;
Upvotes: 1