peggyjs / peggy

Peggy: Parser generator for JavaScript
https://peggyjs.org/
MIT License
883 stars 63 forks source link

Infinite repetition in RFCs #516

Closed zp-zpanda closed 3 weeks ago

zp-zpanda commented 2 months ago

Some RFCs such as RFC 5322 (Internet Message Format) allow infinite repetition in their ABNF:

(RFC 5322 3.2.5 Miscellaneous Tokens)
...
unstructured    =   (*([FWS] VCHAR) *WSP) / obs-unstruct
...

(RFC 5322 4.1 Miscellaneous Obsolete Tokens)
obs-unstruct    =   *((*LF *CR *(obs-utext *LF *CR)) / FWS)
...

(And many more)

I have tried using node-abnf to generate a full Peggy tree from the ABNF, but of course Peggy errors. Is there any method to mitigate that?

Related: #357, #367

hildjj commented 2 months ago

First, see errata 1905. Making that change in the ABNF yields a Peggy grammar that compiles.

Then, check the other errata for a few more grammar changes.

In general, these sorts of errors often mean there's something wrong with the starting assumptions, so there isn't a mechanical fix for them.

zp-zpanda commented 2 months ago

I see... I will try again after incorporating those errata. Thank you so much!

hildjj commented 3 weeks ago

I'm closing this, but please re-open it if you still have trouble.