[antlr-interest] Rewriting an AST with the same type listed twice

Garry Watkins garry at dynafocus.com
Thu Aug 25 08:22:12 PDT 2011


 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


More information about the antlr-interest mailing list