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 adds support for PEG as described in:
<https://bford.info/pub/lang/peg.pdf>
It adds support for the missing features (comments, underscores in
identifiers and escaping) while keeping the extensions (dashes in
identifiers, < and <--).
The naming system tries to be as close as possible to the one proposed
in the paper.
* module/ice-9/peg/string-peg.scm: Rewrite PEG parser.
* test-suite/tests/peg.test: Fix import
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* module/ice-9/peg.scm: rename 'peg-sexp-compile' to
'compile-peg-pattern'
* module/ice-9/peg/codegen.scm: same
* module/ice-9/peg/string-peg.scm: same
* module/ice-9/peg/using-parsers.scm: same
* doc/ref/api-peg.texi: same
* module/ice-9/peg.scm: rename 'define-grammar' to
'define-peg-string-patterns'
* module/ice-9/peg/string-peg.scm: same
* doc/ref/api-peg.texi: same
* test-suite/tests/peg.bench: same
* test-suite/tests/peg.test: same
* module/ice-9/peg.scm: rename 'define-nonterm' to 'define-peg-pattern'
* module/ice-9/peg/using-parsers.scm: same
* module/ice-9/peg/string-peg.scm: same
* test-suite/tests/peg.test: same
* doc/ref/api-peg.texi: same
* module/ice-9/peg.scm: rename 'peg-parse' to 'match-pattern'
* module/ice-9/peg/string-peg.scm: same
* module/ice-9/peg/using-parsers.scm: same
* doc/ref/api-peg.texi: same
* test-suite/tests/peg.test: same
* test-suite/tests/peg.bench: same
* doc/ref/api-peg.texi: rename 'peg-match' to 'search-for-pattern'
* module/ice-9/peg.scm: same
* module/ice-9/peg/using-parsers.scm: same
* test-suite/tests/peg.test: same
* module/ice-9/peg/codegen.scm: Make the PEG syntax extensible, and
move most of the current code generators to the new interface
* doc/ref/api-peg.texi: Document PEG extensions in the PEG Internals
section of the manual