Hi Garry,

You either use inline operators ^ and !, or use a rewrite rule, not both. To
reference a rule, add a $ before its label:

mapType
  :  'map' '<' k=anyType ',' v=anyType '>' -> ^('map' $k $v)
  ;

but I think this should work too:

mapType
  :  'map' '<' anyType ',' anyType '>' -> ^('map' anyType anyType)
  ;

Regards,

Bart.

On Thu, Aug 25, 2011 at 5:22 PM, Garry Watkins <[email protected]> wrote:

>  mapType
>
> : 'map' '<'! anyType ','! anyType '>'!
> | 'map<' k=anyType ','! v=anyType '>'! -> ^('map' k v)
> ;
>
>
> I am trying to re-write the AST generated on this alternative:
>
> | 'map<' k=anyType ','! v=anyType '>'! -> ^('map' k v)
>
>
> How does one alias the anyTypes?  I am getting an error on the code above?
>
> However the bigger question is my parser won't recognize the following
> map<string,string> if it uses just the first line in my rule.  However, it
> will recognize map <string,string>.
>
> Thanks
> Garry
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>

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.

Reply via email to