-
-
Save cordawyn/0ea8cc1727e14857eecf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define-syntax nested-loop | |
(syntax-rules () | |
((NESTED-LOOP continuation ((state initial) ...) combiner | |
clause0 clause1+ ...) | |
(%NESTED-LOOP LOOP continuation ((state initial) ...) combiner | |
clause0 clause1+ ...)))) | |
(define-syntax %nested-loop | |
(syntax-rules (PARALLEL NESTED DO LET LET-VALUES IF NOT AND OR) | |
((%NESTED-LOOP looper continuation ((state initial) ...) combiner | |
expression) | |
(LET ((state initial) ...) | |
(combiner (LAMBDA () expression) continuation))) | |
((%NESTED-LOOP looper continuation ((state initial) ...) combiner | |
(PARALLEL (iterator ...) ...) | |
clause0 clause1+ ...) | |
(looper CONTINUE ((WITH state initial) | |
... | |
(iterator ...) | |
...) | |
=> (continuation state ...) | |
(%NESTED-LOOP looper (LAMBDA (state ...) (CONTINUE state ...)) | |
((state state) ...) | |
combiner | |
clause0 clause1+ ...))) | |
((%NESTED-LOOP looper continuation ((state initial) ...) combiner | |
(NESTED clause ...) | |
clause0 clause1+ ...) | |
(%NESTED-LOOP looper continuation ((state initial) ...) combiner | |
clause ... clause0 clause1+ ...)) | |
((%NESTED-LOOP looper continuation ((state initial) ...) combiner | |
(DO command ...) | |
clause0 clause1+ ...) | |
(BEGIN command ... | |
(%NESTED-LOOP looper continuation ((state initial) ...) combiner | |
clause0 clause1+ ...))) | |
((%NESTED-LOOP looper continuation ((state initial) ...) combiner | |
(LET ((variable value) ...)) | |
clause0 clause1+ ...) | |
(LET ((variable value) ...) | |
(%NESTED-LOOP looper continuation ((state initial) ...) combiner | |
clause0 clause1+ ...))) | |
((%NESTED-LOOP looper continuation ((state initial) ...) combiner | |
(LET variable value) | |
clause0 clause1+ ...) | |
(LET ((variable value)) | |
(%NESTED-LOOP looper continuation ((state initial) ...) combiner | |
clause0 clause1+ ...))) | |
((%NESTED-LOOP looper continuation ((state initial) ...) combiner | |
(LET-VALUES ((bvl expression) ...)) | |
clause0 clause1+ ...) | |
(LET-VALUES ((bvl expression) ...) | |
(%NESTED-LOOP looper continuation ((state initial) ...) combiner | |
clause0 clause1+ ...))) | |
((%NESTED-LOOP looper continuation ((state initial) ...) combiner | |
(LET-VALUES bvl expression) | |
clause0 clause1+ ...) | |
(LET-VALUES ((bvl expression)) | |
(%NESTED-LOOP looper continuation ((state initial) ...) combiner | |
clause0 clause1+ ...))) | |
((%NESTED-LOOP looper continuation ((state initial) ...) combiner | |
(IF condition) | |
clause0 clause1+ ...) | |
(IF condition | |
(%NESTED-LOOP looper continuation ((state initial) ...) combiner | |
clause0 clause1+ ...) | |
(continuation initial ...))) | |
((%NESTED-LOOP looper continuation ((state initial) ...) combiner | |
((iterator ...) ...) | |
clause0 clause1+ ...) | |
(%NESTED-LOOP looper continuation ((state initial) ...) combiner | |
(PARALLEL (iterator ...) ...) | |
clause0 clause1+ ...)) | |
;** This clause must come last! It would shadow the others. | |
((%NESTED-LOOP looper continuation ((state initial) ...) combiner | |
(iterator ...) | |
clause0 clause1+ ...) | |
(%NESTED-LOOP looper continuation ((state initial) ...) combiner | |
(PARALLEL (iterator ...)) | |
clause0 clause1+ ...)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment