ADDED: ... //0, describing an arbitrary number of elements
This is a very versatile nonterminal. For instance, repeated elements:
?- phrase((...,[E],...,[E],...), "hello!!").
%@ E = l
%@ ; E = !
%@ ; false.
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
phrase/2,
|
||||
phrase/3,
|
||||
seq//1,
|
||||
seqq//1]).
|
||||
seqq//1,
|
||||
... //0
|
||||
]).
|
||||
|
||||
:- use_module(library(error)).
|
||||
:- use_module(library(lists), [append/3]).
|
||||
@@ -188,3 +190,6 @@ seq([E|Es]) --> [E], seq(Es).
|
||||
% Describes a sequence of sequences
|
||||
seqq([]) --> [].
|
||||
seqq([Es|Ess]) --> seq(Es), seqq(Ess).
|
||||
|
||||
% Describes an arbitrary number of elements
|
||||
... --> [] | [_], ... .
|
||||
|
||||
Reference in New Issue
Block a user