[antlr-interest] ArrayIndexOutOfBoundsException

Steve Bennett stevagewp at gmail.com
Fri Feb 1 19:48:41 PST 2008


I've managed to narrow it down a bit to this rule:

literal_right_bracket
         { !prohibit_literal_right_bracket &&
(prohibit_literal_link_end <= 0 || input.LA(2)!= RIGHT_BRACKET) }?
         RIGHT_BRACKET;

As written, the exception occurs in a string like [[foo]] (where this
rule should not apply due to the semantic predicate). I've had this
rule for a while and it normally works, so I don't know what else I
have changed.

Changing the rule to either of the following prevents the exception
occurring (but with incorrect behaviour):

/* remove the semantic predicate */
literal_right_bracket
         RIGHT_BRACKET;


/* change to a non-ambiguous token */
literal_right_bracket
        { !prohibit_literal_right_bracket &&
(prohibit_literal_link_end <= 0 || input.LA(2)!= RIGHT_BRACKET)  }? =>
'&';

Does this indicate anything?

Steve


More information about the antlr-interest mailing list