commit 8c1b7dcf132204dc18122aabdccbc7e1139f04c5
parent 8ac38f4a3a2e5a8dedbefe4f48980b953e200016
Author: Georges Dupéron <georges.duperon@gmail.com>
Date: Mon, 19 Sep 2016 21:00:39 +0200
Put 'none back as a result for ~global-and with no matches.
Diffstat:
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/private/global.rkt b/private/global.rkt
@@ -44,11 +44,13 @@
(make-~global #'aggregate-global-or #'#t))
(define (aggregate-global-and . bs)
- (true? ;; force the result to be a boolean, the order of terms is unimportant
- (andmap unbox ;; remove the layer of protection
- (cons (box-immutable 'none) ;; default value when no bindings matched
- (filter identity ;; remove failed bindings
- (flatten bs)))))) ;; don't care about ellipsis nesting
+ (let ([matches (filter identity ;; remove failed bindings
+ (flatten bs))])
+ (if (null? matches)
+ 'none ;; no matches occurred
+ (true? ;; coerce to boolean, so that the order of terms is unimportant
+ (andmap unbox ;; remove the layer of protection
+ matches))))) ;; don't care about ellipsis nesting
(define-eh-mixin-expander ~global-and
(make-~global #'aggregate-global-and))
diff --git a/scribblings/extensible-parser-specifications.scrbl b/scribblings/extensible-parser-specifications.scrbl
@@ -262,8 +262,13 @@ the notion of order irrelevant.
matches of a global pattern using the same @racket[#,tribute-name]. See above
for a description of how global operations work.
- The result is always transformed into a boolean, so @racket[_attribute-name] is
- always bound to either @racket[#t] or @racket[#f].}
+ If there is at least one occurrence of @racket[~global-and] for that
+ @racket[_attribute-name] which successfully matches, the result of the
+ @racket[(and valueᵢ ...)] is always coerced to a boolean, so
+ @racket[_attribute-name] is always bound to either @racket[#t] or @racket[#f].
+
+ If there are no matches at all, the special value @racket['none] is used
+ instead of @racket[#t] as would be produced by @racket[(and)].}
@defform[(~global-counter attribute-name+value #,ntax-pattern ...)
#:grammar