[antlr-interest] Combining += with returns and actions

Ayende Rahien ayende at ayende.com
Fri Aug 10 20:04:07 PDT 2007


I have run into a snag when building a dialect with ANTLR 3, I have the
following:

selectClause[Query q]
    :    SELECT
        mr+=memberReference (COMMA mr+=memberReference)*
        {
            q.AddSelection($mr);
        }
    ;

Where memberReference is defined as:

memberReference returns[MemberReferenceExpression Reference]
    :    ids+=IDENTIFIER (DOT ids+=IDENTIFIER)?
    {
        $Reference = new MemberReferenceExpression();
        foreach(IToken token in $ids)
        {
            $Reference.AddReference(token.Text);
        }

    };


My problem is that I would like to get a list of MemberReferenceExpression,
but what I end up getting is a list of tree.
The problem is here:
PushFollow(FOLLOW_memberReference_in_selectClause76);
mr = memberReference();
followingStackPointer_--;

adaptor.AddChild(root_0, mr.Tree);
if (list_mr == null) list_mr = new ArrayList();
list_mr.Add(mr.Tree); // <-- I want to get mr.Reference, not mr.Tree

Any idea how to solve that?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070811/1b298ca3/attachment.html 


More information about the antlr-interest mailing list