[antlr-interest] Bug when using multi-parameter generics as return values?
Niemeijer, R.A.
r.a.niemeijer at tue.nl
Thu Jul 31 02:58:59 PDT 2008
Hello everyone,
I have a question about using generics as return values (with C# as the
target language). When the generic has only one parameter everything
works correctly, e.g.
elements[Scene scene] returns [IEnumerable<BuildingElement> elems]
: ELEMS p=piece { $elems =
(IEnumerable<BuildingElement>)p.piece.Eval(scene); }
;
However, when I want to return a generic with more than one parameter,
e.g. a Func<BuildingElement, int>, the code generation screws up: it
splits the type at the comma, giving one line with Func<BuildingElement
and one with int>, which obviously results in a compile error.
It is possible to get around this problem with using-statements, such as
using FBI = System.Func<BuildingElement, int>;
and then saying returns [FBI func]. However, this is far from elegant,
especially when you have a lot of different types. Is there a correct
way to do this or if not, has this bug been fixed since Antlr 3.0.1?
Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080731/d8eae4c5/attachment.html
More information about the antlr-interest
mailing list