Closed chrisspre closed 4 years ago
Hi Christof! Thanks for the note. Normally, return type covariance would help with this, but it's not possible in Superpower's design. Some earlier discussion in #112 . There could be a better API/novel solution we've overlooked so far, though :-)
I will think about it but if you haven't come up with anything it is unlikely. Thanks.
Relatively new to using superpower but my inclination is to model the AST using shallow type hierarchies. For example interface ITypeElement {} class Property : ITypeElement {} class Function : ITypeElement {}
So the parser at some point conceptually looks like
In reality that doesn't work since the individual parsers need to be cast to TokenListParser<Token, ITypeElement > first.
Is there an established pattern to write these parser with less noise (i.e. fewer casts )?