Skip to content

Commit

Permalink
Allow the minimum count of a bound to be omitted.
Browse files Browse the repository at this point in the history
  • Loading branch information
dag-erling committed Jun 30, 2024
1 parent 71dd637 commit 5fd3de1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 11 additions & 4 deletions doc/tre-syntax.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,23 @@ <h3>Repeat operators</h3>

<ol>
<li><tt>{</tt><i>m</i><tt>,</tt><i>n</i><tt>}</tt></li>
<li><tt>{,</tt><i>n</i><tt>}</tt></li>
<li><tt>{</tt><i>m</i><tt>,}</tt></li>
<li><tt>{</tt><i>m</i><tt>}</tt></li>
<li><tt>{,}</tt></li>
</ol>

<p>
An atom followed by [1] matches a sequence of <i>m</i> through <i>n</i>
(inclusive) matches of the atom. An atom followed by [2]
matches a sequence of <i>m</i> or more matches of the atom. An atom
followed by [3] matches a sequence of exactly <i>m</i> matches of the
atom.
(inclusive) matches of the atom.
An atom followed by [2] matches a sequence of up to <i>n</i> matches
of the atom.
An atom followed by [3] matches a sequence of <i>m</i> or more matches
of the atom.
An atom followed by [4] matches a sequence of exactly <i>m</i> matches
of the atom.
An atom followed by [5] matches a sequence of zero or more matches of
the atom.
</p>


Expand Down
2 changes: 2 additions & 0 deletions lib/tre-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,8 @@ tre_parse_bound(tre_parse_ctx_t *ctx, tre_ast_node_t **result)
max = min;
if (r < ctx->re_end && *r == CHAR_COMMA)
{
if (min < 0)
min = 0;
r++;
DPRINT(("tre_parse: max count: '%.*" STRF "'\n", REST(r)));
max = tre_parse_int(&r, ctx->re_end);
Expand Down

0 comments on commit 5fd3de1

Please sign in to comment.