guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 01/03: PEG: string-peg: Fix [^...] interpretation.


From: Ludovic Courtès
Subject: [Guile-commits] 01/03: PEG: string-peg: Fix [^...] interpretation.
Date: Sun, 22 Dec 2024 16:19:00 -0500 (EST)

civodul pushed a commit to branch main
in repository guile.

commit c86a48a92f65ea499cc5becfb24c0de5ee23e035
Author: Ekaitz Zarraga <ekaitz@elenq.tech>
AuthorDate: Sun Dec 22 21:01:06 2024 +0100

    PEG: string-peg: Fix [^...] interpretation.
    
    * module/ice-9/peg/string-peg.scm (NotInClass->defn): Adjust.
    
    Signed-off-by: Ludovic Courtès <ludo@gnu.org>
---
 module/ice-9/peg/string-peg.scm | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/module/ice-9/peg/string-peg.scm b/module/ice-9/peg/string-peg.scm
index 0026f8930..745d8e8e7 100644
--- a/module/ice-9/peg/string-peg.scm
+++ b/module/ice-9/peg/string-peg.scm
@@ -301,11 +301,19 @@ EndOfFile < !.
 (define (Literal->defn lst for-syntax)
   (apply string (map (lambda (x) (Char->defn x for-syntax)) (cdr lst))))
 
-;; (NotInClass ...)
-;;  `-> (and ...)
+;; (NotInClass (Range ...) (Range ...))
+;;  `-> (and (followed-by (not-in-range ...))
+;;           (followed-by (not-in-range ...))
+;;           ...
+;;           (not-in-range ...))
+;; NOTE: the order doesn't matter, because all `not-in-range`s will always
+;; parse exactly one character, but all the elements but the last need not to
+;; consume the input.
 (define (NotInClass->defn lst for-syntax)
-  #`(and #,@(map (lambda (x) (NotInRange->defn x for-syntax))
-                 (cdr lst))))
+  #`(and
+      #,@(map (lambda (x) #`(followed-by #,(NotInRange->defn x for-syntax)))
+              (cddr lst))
+      #,(NotInRange->defn (cadr lst) for-syntax)))
 
 ;; (Class ...)
 ;;  `-> (or ...)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]