[antlr-interest] cant find tokenRefBangTrack

Brent Yates brent.yates at gmail.com
Mon Feb 18 11:16:10 PST 2008


I have seen this before when mixing rewrite and !^ styles.  I believe that
if you remove the !'s it will work fine.  Also, it may be a little clearer
if you write the rule like this (unverified):

 if_stmt    :  (IF LPAREN cond=expr RPAREN stmt=statement -> ^(IF $cond
$stmt) )
               (ELSE elsestmt = statement -> ^( IFELSE  $cond   $stmt
$elsestmt ) )?
            ;

Brent Yates

On Feb 18, 2008 1:49 PM, Ian Moor <iwm at doc.ic.ac.uk> wrote:

> I am constructing a grammar for a very small subset of C and
> the section for the if statement, which is similar to the example in the
> book
> generates an internal error :
>
>  error(10):  internal error: Pico.g : java.lang.IllegalArgumentException:
> Can't find template tokenRefBangTrack.st
>
> the code is
>  if_stmt    :  IF LPAREN! cond=expr RPAREN! stmt=statement
>              ( ( (ELSE) =>   ELSE) elsestmt = statement ->
>                  ^( IFELSE  $cond   $stmt $elsestmt )
>               | /* empty no else */  ->
>                  ^( IF $cond $stmt )
>
>              )             ;
>
> Without the rewrite rules the grammar compiles.
> Is there another way to do this ?
>  Ian W Moor                    Department of Computing,
> iwm at doc.ic.ac.uk           Imperial College.
>                                    180 Queensgate
>                                     London SW7 2AZ UK.
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080218/5a961f22/attachment.html 


More information about the antlr-interest mailing list