Skip to content

Recursion in parser rules #115

Description

@NicViviers

I'm unsure of how recursion works in parser rules, I assumed it would be similar to ply, but this does not work:

@self.production("struct : STRUCT IDENT (IDENT COLON IDENT (COMMA IDENT COLON IDENT)*)?")
def struct(tokens: list[Token]):
    ...

This would match the following text:

struct Foo {}
struct Bar {
    one: String,
    two: i32
}

This produces: KeyError: '(IDENT' pointing to rply\grammar.py line 148: for p in self.prod_names[n]:

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions