> -----Original Message-----
> From: [email protected] [mailto:antlr-interest-
> [email protected]] On Behalf Of Stephanie
> Sent: Friday, October 15, 2010 8:05 AM
> To: [email protected]
> Cc: [email protected]
> Subject: [antlr-interest] Tree grammar: How to handle rule arguments
>
> Hello,
>
> I have implemented a parser grammar as well as a tree parser for a
> little Java-like language. I have encounter difficulties with the
> following productions
>
>
>
> identList[Object varType]
>
> : id=Identifier ( ',' Identifier )*
>
> -> ^( VarDecl[$id, "VarDecl"] { $varType } Identifier )+
>
What does Identifier refer to here in your rewrite? It is just the last
variable that is parsed. When you are looking in Works, you are probably
looking at the parse tree and not the AST. Why are you trying to rewrite the
first token to an Imaginary?
What you want is:
: id+=Identifier (',' id+=Identifier)*
->^(VarDecl {$varType} $id)+
Then reflect that in your tree parser. I have never quite seen the reason
behind eliding the fact that multiple declarations were made on the same
type, but if that is what you want, then you need to do it as above.
Jim
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en.