You're almost there! The grammar you have right now will produce strings like /var/var/var/{id}/
but also /{id}/var/var/{id}/var/
. So what you need to do is remove {id}
from the expr
rule. But then you still need to tack on {id}
at the end to fit the definition of your language, and this can be done in the start
rule. The resulting grammar is then:
start::= token "{id}"
token::= token expr token
token::= "/"
expr::= "var"