Fixes a bug with `where' clauses

This commit is contained in:
Casey Klein 2010-07-19 09:20:56 -05:00
parent 8eb25bb2b9
commit 72b98b77fb
2 changed files with 16 additions and 2 deletions

View File

@ -266,7 +266,9 @@
#,
(case where-mode
[(flatten)
#`(apply append (map result mtchs))]
#`(for/fold ([r '()]) ([m mtchs])
(let ([s (result m)])
(if s (append s r) r)))]
[(predicate)
#`(ormap result mtchs)]
[else (error 'unknown-where-mode "~s" where-mode)])

View File

@ -886,6 +886,18 @@
'(x 4)))
'(x))
; test multiply matching `where' with failing `where' inside
(test (apply-reduction-relation
(reduction-relation
empty-language
(--> ()
()
(where (number_1 ... number_i number_i+1 ...)
(1 2 3))
(where number_i 2)))
'())
'(()))
(test (apply-reduction-relation/tag-with-names
(reduction-relation
grammar
@ -1703,7 +1715,7 @@
(where (y ... w z ...) (x ...)))))
(test (apply-reduction-relation red (term (a b c)))
(list (term (a b)) (term (a c)) (term (b c)))))
(list (term (b c)) (term (a c)) (term (a b)))))
(let ([r (reduction-relation