Open
Description
Instead of the current setup where everything assumes Handle
, we could have structs/enums generic over something that will let them extract their field types, e.g.:
enum Expr<L: ApplyT<Expr<L>> + ApplyT<Type<L>>> {
Cast {
expr: <L as ApplyT<Expr<L>>>::Out,
ty: <L as ApplyT<Type<L>>>::Out,
},
Call {
callee: <L as ApplyT<Expr<L>>>::Out,
callee: <L as ApplyT<[Expr<L>]>>::Out,
},
}
This would turn Handle<'.., Expr<'..>>
into Handle<'.., Expr<HandleL<'..>>>
, but could also be used for an AST (only replacing certain types, and using e.g. Box<Expr<MyAst>>
for others), and allow for automating lowering the parse forest to that AST, including disambiguation (on the AST types).
Note that disambiguation performed on a bottom-up constructed "eager AST" would sometimes be more expensive than shallow SPPF disambiguation, but it's easier to implement.