Skip to content

Generic AST interface for convenience. #73

Open
@eddyb

Description

@eddyb

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions