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

Laurent Caillette laurent.caillette at gmail.com
Wed Mar 11 13:45:51 PDT 2009


ANTLR doesn't appreciate the uppercase 'D' of 'DataPath'. Uppercase
means a token. Turning 'DataPath' to 'dataPath' makes ANTLR happy.

c.

On Wed, Mar 11, 2009 at 6:17 PM, Stevenson, Todd (GE Healthcare,
consultant) <ToddStevenson at ge.com> 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.
>
> ------------------------------------------------------------------------------------------------------------------------
> grammar cepath;
>
> options {
>  output=AST;
>  ASTLabelType=CommonTree;
> }
>
>
>
> start
>  : cpath EOF
>  ;
>
> cpath
>  : KEY keypath
>  | DataPath
>  ;
>
> DataPath
>  : CODE keypath
>  ;
>
> keypath
>  : SEP CODE
>  | SEP DOMAIN
>  ;
>
> // $<lex
>
> KEY    : 'key';
> CODE   : 'code';
> DOMAIN   : 'domain';
>
> SEP  : '.';
> WS   :  ( '\r' | '\n')+ {skip();};
>
> // $>
>
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>


More information about the antlr-interest mailing list