swipl-devel icon indicating copy to clipboard operation
swipl-devel copied to clipboard

small glitch in docu of library(dcg/high_order)).

Open Jean-Luc-Picard-2021 opened this issue 6 months ago • 0 comments

While trying to do protobuf syntax with library(dcg/high_order)) it seems there is small glitch in the docu. It says here:

Element?, (Sep,Element)*

https://www.swi-prolog.org/pldoc/doc_for?object=sequence//3

But what it actually does is this here:

(Element, (Sep,Element)*) ?

Here is some testing. Omitting the first Element and then repeatedly sep with Element doesn't work, thats why the last test case fails. So it must have another specification:

?- phrase(foo(L), [i]).
L = [i].

?- phrase(foo(L), []).
L = [].

?- phrase(foo(L), [i,',',i]).
L = [i, i].

?- phrase(foo(L), [',',i]).
false.

The test code was:

foo(L) --> sequence(bar, baz, L).
bar(i) --> [i].
baz --> [','].

Jean-Luc-Picard-2021 avatar Aug 14 '24 06:08 Jean-Luc-Picard-2021