Specify repeating tokens in Recursive Descent Parser with NLTK

346 Views Asked by At

I am trying to parse a grammar similar to this.

PER -> 'noun' | 'noun1' | 'noun2'

PERS -> PER+

This is not a valid grammar for NLTK's recursive descent parser. How do specifiy one of more repeating tokens in this grammar

1

There are 1 best solutions below

3
On

try a rule like:

PERS -> PER PERS | PER