Skip to content

Commit b4809da

Browse files
authored
Merge pull request #241 from ianthehenry/document-split
document the (split) PEG special
2 parents 0b51f5c + 151ccb0 commit b4809da

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

content/docs/peg.mdz

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,17 @@ compiled to bytecode).
218218
@code`patt` cannot match more than @code`window-patt`; it will
219219
see end-of-input at the end of the substring matched by
220220
@code`window-patt`. If @code`patt` also succeeds, @code`sub` will
221-
advance to the end of what @code`window-patt` matched. }}}
221+
advance to the end of what @code`window-patt` matched. }}
222+
223+
@tr{@td{@code`(split separator-patt patt)` }
224+
@td{ Split the remaining input by @code`separator-patt`, and execute
225+
@code`patt` on each substring. @code`patt` will execute with its
226+
input constrained to the next instance of @code`separator-patt`,
227+
as if narrowed by @code`(sub (to separator-patt) ...)`.
228+
@code`split` will continue to match separators and patterns until
229+
it reaches the end of the input; if you don't want to match to the
230+
end of the input you should first narrow it with
231+
@code`(sub ... (split ...))`. }}}
222232

223233
PEGs try to match an input text with a pattern in a greedy manner. This means
224234
that if a rule fails to match, that rule will fail and not try again. The only

0 commit comments

Comments
 (0)