1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-29 19:30:36 +02:00

PEG: Add support for not-in-range and [^...]

Modern PEG supports inversed class like `[^a-z]` that would get any
character not in the `a-z` range. This commit adds support for that and
also for a new `not-in-range` PEG pattern for scheme.

* module/ice-9/peg/codegen.scm (cg-not-in-range): New function.
* module/ice-9/peg/string-peg.scm: Add support for `[^...]`
* test-suite/tests/peg.test: Test it.
* doc/ref/api-peg.texi: Document accordingly.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Ekaitz Zarraga 2024-10-11 14:24:30 +02:00 committed by Ludovic Courtès
parent ff11753df1
commit 25504ba216
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
5 changed files with 73 additions and 4 deletions

View file

@ -147,6 +147,14 @@ Parses any character falling between @var{a} and @var{z}.
@code{(range #\a #\z)}
@end deftp
@deftp {PEG Pattern} {inverse range of characters} a z
Parses any character not falling between @var{a} and @var{z}.
@code{"[^a-z]"}
@code{(not-in-range #\a #\z)}
@end deftp
Example:
@example