1:- module(dcg_extras, [seq//1, seqq//1, (...)//0]).

Extra DCG utilities

Taken from The Power of Prolog by Markus Triska

It's recommended to set the flag to write lists of characters as strings:

:- set_prolog_flag(double_quotes, chars).
See also
- https://www.metalevel.at/prolog/dcg /
 seq(-List)// is det
seq(+List)// is det
Describes a sequence of elements.
?- phrase(("Hello, ",seq(Cs),"!"), "Hello, all!").
Cs = "all" ;
false.
   25seq([])     --> [].
   26seq([E|Es]) --> [E], seq(Es).
 seqq(-List)// is det
seqq(+List)// is det
Describes a sequence of sequences.
?- phrase(seqq(["ab","cd","ef"]), Ls).
   Ls = "abcdef".
   38seqq([]) --> [].
   39seqq([Es|Ess]) -->
   40        seq(Es),
   41        seqq(Ess).
 ...// is det
Describes "any sequence at all"
?- phrase((...,"you",...,"!"), "Hello, you all!").
   true ;
   false.
   54... --> [] | [_], ...