[antlr-interest] ANTLR3 What's wrong with this ST rule?

Kailey Joanette kaileyjo at bigbluebubble.com
Thu Mar 22 08:38:16 PDT 2007


I have the following simple ST rule

 

modSet(mods,rest) ::= "<mods; seperator=\" \"><rest>"

 

And the corresponding output rule

 

classOrInterfaceDeclaration

                :               ^(CLASS_INTERFACE_DEF accessModifier?
(m+=modifier)* (n=normalClassDeclaration)? ) -> modSet( mods={$m},
rest={$n.st} )

                ;

 

When I run the parser and try to get output I end up with a crash that looks
like this:

 

parsing C:\Java_Projects\antlr_java\examples-v3\java\java\Test.java

tree=(JAVA (CLASS_INTERFACE_DEF (NORMAL_CLASS Test CLASS_BODY)))

 

action parse error in group Cpp line 10; template context is [modSet]

line 1:5: expecting LPAREN, found 'null'

        at antlr.Parser.match(Parser.java:211)

        at
org.antlr.stringtemplate.language.ActionParser.singleArg(ActionParser.java:1
084)

        at
org.antlr.stringtemplate.language.ActionParser.function(ActionParser.java:96
4)

        at
org.antlr.stringtemplate.language.ActionParser.primaryExpr(ActionParser.java
:640)

 

I don't understand why I'm ending up with null. actually I'm not sure why
it's expecting an LPAREN either.

 

If I remove the <rest> from the ST rule it works but obviously I don't get
the right output.

Kailey

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070322/3013fed5/attachment.html 


More information about the antlr-interest mailing list