diff --git a/private/global.rkt b/private/global.rkt index 55f6bee..1408c2b 100644 --- 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 index 97a155d..5008599 100644 --- 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