| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
(define-syntax infix/postfix |
| 26 |
(syntax-rules () |
| 27 |
((infix/postfix x somewhat?) |
| 28 |
(somewhat? x)) |
| 29 |
|
| 30 |
((infix/postfix left related-to? right) |
| 31 |
(related-to? left right)) |
| 32 |
|
| 33 |
((infix/postfix left related-to? right . likewise) |
| 34 |
(let ((right* right)) |
| 35 |
(and (infix/postfix left related-to? right*) |
| 36 |
(infix/postfix right* . likewise)))))) |
| 37 |
|
| 38 |
(define-syntax extract-placeholders |
| 39 |
(lambda (x) |
| 40 |
(syntax-case x () |
| 41 |
[(_ final () () body) #'(final (infix/postfix . body))] |
| 42 |
[(_ final () args body) #'(lambda args (final (infix/postfix . body)))] |
| 43 |
[(k final (underscore op . rest) (args ...) (body ...)) |
| 44 |
(eq? (syntax->datum #'underscore) '_) |
| 45 |
#'(k final rest (args ... arg) (body ... arg op))] |
| 46 |
[(k final (arg op . rest) args (body ...)) |
| 47 |
#'(k final rest args (body ... arg op))] |
| 48 |
[(k final (underscore) (args ...) (body ...)) |
| 49 |
(eq? (syntax->datum #'underscore) '_) |
| 50 |
#'(k final () (args ... arg) (body ... arg))] |
| 51 |
[(k final (arg) args (body ...)) |
| 52 |
#'(k final () args (body ... arg))]))) |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
extract-placeholders finalbody |
| 57 |
finalinfix/postfix . body |
| 58 |
|
| 59 |
extract-placeholders finalargs body |
| 60 |
lambda argsfinalinfix/postfix . body |
| 61 |
|
| 62 |
extract-placeholders final_ op . restargs ...body ... |
| 63 |
extract-placeholders final restargs ... argbody ... arg op |
| 64 |
|
| 65 |
extract-placeholders finalarg op . restargsbody ... |
| 66 |
extract-placeholders final rest argsbody ... arg op |
| 67 |
|
| 68 |
extract-placeholders final_args ...body ... |
| 69 |
extract-placeholders finalargs ... argbody ... arg |
| 70 |
|
| 71 |
extract-placeholders finalargargsbody ... |
| 72 |
extract-placeholders finalargsbody ... arg |
| 73 |
|
| 74 |
(define-syntax identity-syntax |
| 75 |
(syntax-rules () |
| 76 |
((identity-syntax form) |
| 77 |
form))) |
| 78 |
|
| 79 |
(define-syntax is |
| 80 |
(syntax-rules () |
| 81 |
((is . something) |
| 82 |
(extract-placeholders identity-syntax something () ())))) |
| 83 |
|
| 84 |
(define-syntax isnt |
| 85 |
(syntax-rules () |
| 86 |
((isnt . something) |
| 87 |
(extract-placeholders not something () ())))) |