Thank you all for your replies. I was able to fix it and better understanding grammars :-)
Regards, David Santiago Patrick R. Michaud <pmich...@pobox.com> escreveu no dia quinta, 21/05/2020 à(s) 21:05: > > On Thu, May 21, 2020 at 08:40:08PM +0000, David Santiago wrote: > > Can someone explain me why my grammar isn't working? Unfortunately i > > can't figure it out :-( > > > > | headers > > | | header > > | | * MATCH "Proxy-Connection" > > | | header-value > > | | * MATCH "keep-alive\n" > > | | crlf > > | | * FAIL > > | * FAIL > > * FAIL > > Nil > > Notice how <header-value> is capturing the newline in "keep-alive\n"? That > means there's not a newline for the <.crlf> subrule that follows, and thus > the match fails. > > Try changing "rule header-value" to be a "token" instead. That will prevent > it from consuming any whitespace immediately following the <graph>+ sequence. > When I tried your script with header-value defined as a token, it got a lot > farther into the match: > > $ rakudo test.raku > TOP > | request-line > | | method > | | * MATCH "CONNECT" > | | request-uri > | | * MATCH "ssl.gstatic.com:443" > | | http-version > | | * MATCH "HTTP/1.1" > | | crlf > | | * MATCH "\n" > | * MATCH "CONNECT ssl.gstatic.com:443 HTTP/1.1\n" > | headers > | | header > | | * MATCH "Proxy-Connection" > | | header-value > | | * MATCH "keep-alive" > | | crlf > | | * MATCH "\n" > | * MATCH "Proxy-Connection: keep-alive\n" > * MATCH "CONNECT ssl.gstatic.com:443 HTTP/1.1\nProxy-Connection: keep-" > Nil > > > Personally, I would likely define <header-value> to be something more like > > token header-value { \N+ } > > which gets any sequence of non-newline characters, since some of the headers > coming afterwards contain spaces and characters which aren't part of <graph>. > > Pm