[antlr-interest] Problem generating simple AST's

Scott McLoughlin scott at adrenaline.com
Mon Apr 21 11:37:12 PDT 2008


I have the Antlr book, so let me know if there's a page/section I should
check out that addresses this problem.

Here's the sample production from the grammar.

funFormals
    :    OPAREN! formals ('=>'! typeList)? CPAREN! -> ^(DEF formals)
    ;

Looks normal enough, but that -> ^(DEF formals) is the killer.  When I
compile the grammar, I get a long error message that starts out.

    Cannot generate the grammar because:
    error(10) internal ...more stuff.....
    java.lang.IllegalArgumentException: Can't find template 
tokenRefBangTrack.st
    ....more stuff....

Removing the -> clause, and everything compiles fine, but generates a pretty
useless AST :-(

Any work arounds?

Scott





More information about the antlr-interest mailing list