alex / alex/rply

Recursion in parser rules

Open
#115 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
391
Forks
62
PR merge metrics
No merged PRs in 30d

Description

I'm unsure of how recursion works in parser rules, I assumed it would be similar to `ply`, but this does not work:
```py
@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]:`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.