[antlr-interest] Check the next token in Hidden Channel

Johannes Luber jaluber at gmx.de
Mon Apr 14 05:55:21 PDT 2008


Alexander Gängel schrieb:
> I hace to check in my Parser once if the next Token is a Whitspace.
> 
> I tried the code from:
> http://www.antlr.org/wiki/pages/viewpage.action?pageId=557063
> 
> So is copied it to my Grammar:
> @members{
>    protected int skipOffTokenChannels(int i) {
>        int n = tokens.size();
>        while ( i<n && ((Token)tokens.get(i)).getChannel()!=channel ) {
>            i++;
>        }
>        return i;
> }
> }
> 
> But the Code compains that tokens cannot be resolved?
> 
> I use 3.1 so I think there is something changed sice 3.0.
> 
> Can anybody give me an hint how to do this ?

Looking at the wiki text, I believe you have to modify 
CommonTokenStream.java, not your grammar. Alternatively you could derive 
a class from CommonTokenStream which is the cleaner solution.

Johannes


More information about the antlr-interest mailing list