kursjan / petitparser2

A high-performance top-down parser
MIT License
41 stars 19 forks source link

Grammar for URI IPv6address unexpectedly fails #72

Closed Rinzwind closed 1 year ago

Rinzwind commented 1 year ago

The following is based on the rule IPv6address given in appendix A in RFC 3986 (“Collected ABNF for URI”):

address := ((#digit asPParser , $: asPParser) min: 0 max: 5) , #digit asPParser , '::' asPParser , #digit asPParser.

This assertion passes as expected:

self assert: (address end parse: '1:2:3:4:5:6::7')
    = { OrderedCollection withAll: #(#($1 $:) #($2 $:) #($3 $:) #($4 $:) #($5 $:)). $6. '::'. $7 }.

But this assertion does not because #parse: returns a PP2Failure:

self assert: (address end parse: '1:2:3:4:5::6')
    = { OrderedCollection withAll: #(#($1 $:) #($2 $:) #($3 $:) #($4 $:)). $5. '::'. $6 }.

Perhaps my expectation is wrong, but shouldn’t that parse successfully as well?

Rinzwind commented 1 year ago

Duplicated from: https://github.com/moosetechnology/PetitParser/issues/67. I started out with the original PetitParser as it’s the version discussed in the book “Deep into Pharo”.

Rinzwind commented 1 year ago

I’ll close this, see the discussion in the other issue.