It looks like a bug.

I suggest that in the file
/src/org/antlr/codegen/templates/Java/Java.stg modifies its definition
of filteringNextToken() to the following,
where a check for state.token==Token.SKIP_TOKEN occurs, and emit() is
only called if the state token is not previously set.

filteringNextToken() ::= <<
public Token nextToken() {
    while (true) {
        if ( input.LA(1)==CharStream.EOF ) {
            return Token.EOF_TOKEN;
        }
        state.token = null;
        state.channel = Token.DEFAULT_CHANNEL;
        state.tokenStartCharIndex = input.index();
        state.tokenStartCharPositionInLine = input.getCharPositionInLine();
        state.tokenStartLine = input.getLine();
        state.text = null;
        try {
            int m = input.mark();
            state.backtracking=1; <! means we won't throw slow exception !>
            state.failed=false;
            mTokens();
            state.backtracking=0;
            <! mTokens backtracks with synpred at backtracking==2
               and we set the synpredgate to allow actions at level 1. !>
            if ( state.failed ) {
                input.rewind(m);
                input.consume(); <! advance one char and try again !>
            }
            else {            <! emit a token only if it is not a SKIP_TOKEN !>
                                if ( state.token==null ) {
                                        emit();
                                }
                                else if ( state.token==Token.SKIP_TOKEN ) {
                                        continue;
                                }
                                return state.token;
            }
        }
        catch (RecognitionException re) {
            // shouldn't happen in backtracking mode, but...
            reportError(re);
            recover(re);
        }
    }
}

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to