alex / alex/rply

Recursion in parser rules

Aperta
#115 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
391
Fork
62
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.