[antlr-interest] ArrayIndexOutOfBoundsException

Steve Bennett stevagewp at gmail.com
Sat Feb 2 00:53:23 PST 2008


On 2/2/08, Gavin Lambert <antlr at mirality.co.nz> wrote:
>  >I've managed to narrow it down a bit to this rule:

(I've actually narrowed it down slightly further: if the predicate
passes (eg, { true }? =>...), everything is ok. It's a failing
predicate that bombs)

> Predicates can be hoisted outside the rule they're defined in, to
> help in deciding whether that rule should be entered in the first
> place or not.  I thought that only applied to gated predicates,

Yeah, I've seen that before, and normally the symptom is unrecognised
variables, which are actually fields unreachable from the hoisting
object.

> but there might be a special case for a leading ungated predicate
> (since that's how you had to do it in ANTLR 2).
>
> So my best guess at this point is that it's the call to
> input.LA(2), which is occurring when there isn't two characters of
> lookahead available (eg. next character is EOF).  If that really
> is the problem, then failing the predicate early when input.LA(1)
> == EOF will probably sort it out.

Good thoughts, but it doesn't seem to be that here, as it's failing
mid sentence (well short of the EOF), and it's bombing even without
hte reference to input.LA(). Any others ideas?

Steve


More information about the antlr-interest mailing list