diff --git a/CHANGELOG.md b/CHANGELOG.md index ac4cfa10..9b4ec619 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ Released: TBD - [#280](https://github.com/peggyjs/peggy/issues/280) Add inline examples to the documentation, from @hildjj +- [#291](https://github.com/peggyjs/peggy/pull/291): Add support for repetition + operator `expression|min .. max, delimiter|`, from @Mingun ### Minor Changes diff --git a/docs/documentation.html b/docs/documentation.html index 6345af4f..daea678c 100644 --- a/docs/documentation.html +++ b/docs/documentation.html @@ -832,6 +832,63 @@
expression |count|
+
expression |min..max|
+
expression |count, delimiter|
+
expression |min..max, delimiter|
Match exact count
repetitions of expression
.
+ If the match succeeds, return their match results in an array.
-or-
+ +Match expression at least min
but not more then max
times.
+ If the match succeeds, return their match results in an array. Both min
+ and max
may be omitted. If min
is omitted, then it is assumed
+ to be 0
. If max
is omitted, then it is assumed to be infinity.
+ Hence
expression |..|
is an equivalent of expression |0..|
+ and expression *
expression |1..|
is an equivalent of expression +
Optionally, delimiter
expression can be specified. Delimiter must appear
+ between expressions exactly once and it is not included in the final array.
count
, min
and max
can be represented as:
start = "a"|2|;
+ start = count:n1 "a"|count|;
+n1 = n:$[0-9] { return parseInt(n); };
+ start = "a"|{ return options.count; }|;
+ 0
.
+ repetition = "a"|2..3, ","|
"a,a"
, "a,a,a"
"a"
, "b,b"
,
+ "a,a,a,"
, "a,a,a,a"
expression ?