Skip to content

Support non-single-pair types #11

@CAD97

Description

@CAD97
Collaborator

Things like how Vec<impl FromPest> works today. FromPest is now set up such that implementations pull from the front of a cursor instead of only getting a single Pair; we should let pest-ast use this!

Basically, this is translating a silent rule from pest.

rule = _{ a ~ b ~ c }

becomes

#[derive(FromPest)]
#[pest_ast(inline(Rule))]
pub struct rule {
    pub a: a,
    pub b: b,
    pub c: c,
}

The struct attribute is temporary and bikeshedable. I don't want just the absence of a rule(..) attribute to mean that it's inline, though, as this is likely to lead to mistakenly leaving it out. The rule enum also still has to be provided somehow, as I don't think it can be inferred from children.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

        Participants

        @CAD97

        Issue actions

          Support non-single-pair types · Issue #11 · pest-parser/ast