[antlr-interest] Problem generating simple AST's
Johannes Luber
jaluber at gmx.de
Mon Apr 21 11:51:17 PDT 2008
Scott McLoughlin schrieb:
> 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?
If you use '!' or '^', you can't use the rewrite rules, too. Just change
"'=>'!" to "'=>'" when using the rewrite rule.
Johannes
More information about the antlr-interest
mailing list