confusing `ignore` behavior with PEG parsing

Jade Hagborg <[email protected]> Fri, 05 Dec 2025 20:08:46 -0500
Newsgroups gmane.lisp.guile.user
Message-ID <0ff5222cb962b9bd067a1ddfefede708b0ee98a2.camel@quasicoherent.solutions>
Hi all,

Consider the following example REPL session using PEG parsing:

scheme@(guile-user)> (define-peg-pattern example body "example")
scheme@(guile-user)> (define-peg-pattern ignore-example all (ignore example))
scheme@(guile-user)> (match-pattern ignore-example "example")
$13 = #<prec start: 0 end: 7 string: "example" tree: (ignore-example "example")>

OK, I figure `ignore` is not able to cancel the effect of `body` on the
earlier line, or something like that.

scheme@(guile-user)> (define-peg-pattern ignore-some-example all (ignore (+ example)))
scheme@(guile-user)> (match-pattern ignore-some-example "example")
$14 = #<prec start: 0 end: 7 string: "example" tree: ignore-some-example>

Hm... but when `+` enters the picture, that changes?

Is this the expected behavior?  What is the general rule here?

Thanks,
Jade