[antlr-interest] Simple grammar will not compile. I can't figure it out.

Sam Barnett-Cormack s.barnett-cormack at lancaster.ac.uk
Wed Mar 11 10:25:55 PDT 2009


Stevenson, Todd (GE Healthcare, consultant) wrote:
> This grammar will not compile.  I can't figure out why not.  It 
> generates the error:
>  
> reference to undefined rule: keypath
>  
> even though it exists.  Help!
>  
> Thanks.
>  
> ------------------------------------------------------------------------------------------------------------------------

>  
> DataPath
>  : CODE keypath
>  ;

The initial capital makes this a lexer rule

> keypath
>  : SEP CODE
>  | SEP DOMAIN
>  ;
>  


This is a parser rule.

Lexer rules can't refer to parser rules (obviously). You probably just 
want to make DataPath -> dataPath.

Sam


More information about the antlr-interest mailing list