[antlr-interest] ANTLRWorks bug - no such element exception

Jim Idle jimi at temporal-wave.com
Fri Apr 17 12:06:27 PDT 2009


Paul Bouché (NSN) wrote:
> Hi,
>
> I get the following error with my grammar when I try to use the debugger.
>
> [20:25:25] error(10):  internal error: 
>
> It does not occur when I leave namespaveDefinition from the following rule:
> start
>         :
>         namespaceDefinition? ({propsmessage}?=>propsmessage | 
> propertynode) EOF
>         ;
You are using a rule as a gated predicate evaluation expression, if you 
need to rule to parse all the way through as a predicate then you need:

(propsmessage)=>propsmessage | 


Otherwise, you need to change the name of your gated predicate boolean variable.

If you are using a rule as a predicate, then rather than call the whole rule (if it is a rule of any consequence), see if you can create a shorter rule that can be used as a predicate. For instance if the first two tokens will select the rule, then:

propsmessage_pred
	: TOK1 TOK2 ;

(propsmessage_pred)=>propsmessage


Or if you cannot do that, try to use a predicate rule that will fail quickly so that evaluating it a runtime is not expensive.

Jim



More information about the antlr-interest mailing list