alex / rply

An attempt to port David Beazley's PLY to RPython, and give it a cooler API.
BSD 3-Clause "New" or "Revised" License
381 stars 60 forks source link

Recursion in parser rules #115

Open DecrepitHuman opened 2 years ago

DecrepitHuman commented 2 years ago

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]: