|
90 | 90 | (begin |
91 | 91 | (define-syntax-parser @%app |
92 | 92 | [(~parens _ . args) |
93 | | - (syntax/loc this-syntax |
94 | | - (@%app/prefix . args))] |
| 93 | + (datum->syntax this-syntax (cons #'@%app/prefix #'args) this-syntax)] |
95 | 94 | [{~braces _ . args} |
96 | | - (syntax/loc this-syntax |
97 | | - (@%app/infix . args))]) |
| 95 | + (datum->syntax this-syntax (cons #'@%app/infix #'args) this-syntax)]) |
98 | 96 |
|
99 | 97 | (define-syntax-parser @%app/prefix |
100 | 98 | [(_ f:expr) #'f] |
101 | 99 | [(_ f:expr x:expr) |
102 | | - (syntax/loc this-syntax |
103 | | - (@%app1 f x))] |
| 100 | + (datum->syntax this-syntax (list #'@%app1 #'f #'x) this-syntax)] |
104 | 101 | [(_ f:expr x:expr xs:expr ...) |
105 | | - (quasisyntax/loc this-syntax |
106 | | - (@%app/prefix #,(~> (syntax/loc this-syntax |
107 | | - (@%app1 f x)) |
108 | | - (syntax-property 'omit-type-tooltip #t)) |
109 | | - xs ...))]) |
| 102 | + #:with inner-app (~> (datum->syntax this-syntax (list #'@%app1 #'f #'x) this-syntax) |
| 103 | + (syntax-property 'omit-type-tooltip #t)) |
| 104 | + (datum->syntax this-syntax (list* #'@%app/prefix #'inner-app #'(xs ...)) this-syntax)]) |
110 | 105 |
|
111 | 106 | (define-syntax-parser @%app/infix |
112 | 107 | [(_ a:expr op:infix-operator b:expr {~seq ops:infix-operator bs:expr} ...+) |
113 | 108 | #:when (eq? 'left (attribute op.fixity)) |
114 | 109 | #:and ~! |
115 | 110 | #:fail-unless (andmap #{eq? % 'left} (attribute ops.fixity)) |
116 | 111 | "cannot mix left- and right-associative operators in the same infix expression" |
117 | | - (quasitemplate/loc this-syntax |
118 | | - (@%app/infix #,(~> (syntax/loc this-syntax |
119 | | - (@%app/infix a op b)) |
| 112 | + #:with inner-app (~> (datum->syntax this-syntax (list #'@%app/infix #'a #'op #'b) this-syntax) |
120 | 113 | (syntax-property 'omit-type-tooltip #t)) |
121 | | - {?@ ops bs} ...))] |
| 114 | + (~> (list* #'@%app/infix #'inner-app (syntax->list #'({?@ ops bs} ...))) |
| 115 | + (datum->syntax this-syntax _ this-syntax))] |
122 | 116 | [(_ {~seq as:expr ops:infix-operator} ...+ a:expr op:infix-operator b:expr) |
123 | 117 | #:when (eq? 'right (attribute op.fixity)) |
124 | 118 | #:and ~! |
125 | 119 | #:fail-unless (andmap #{eq? % 'right} (attribute ops.fixity)) |
126 | 120 | "cannot mix left- and right-associative operators in the same infix expression" |
127 | | - (quasitemplate/loc this-syntax |
128 | | - (@%app/infix {?@ as ops} ... |
129 | | - #,(~> (syntax/loc this-syntax |
130 | | - (@%app/infix a op b)) |
131 | | - (syntax-property 'omit-type-tooltip #t))))] |
| 121 | + #:with inner-app (~> (datum->syntax this-syntax (list #'@%app/infix #'a #'op #'b) this-syntax) |
| 122 | + (syntax-property 'omit-type-tooltip #t)) |
| 123 | + (~> (append (list #'@%app/infix) (syntax->list #'({?@ as ops} ...)) (list #'inner-app)) |
| 124 | + (datum->syntax this-syntax _ this-syntax))] |
132 | 125 | [(_ a:expr op:expr b:expr) |
133 | | - (syntax/loc this-syntax |
134 | | - (@%app/prefix op a b))] |
| 126 | + (quasisyntax/loc this-syntax |
| 127 | + (#%expression |
| 128 | + #,(~> (datum->syntax this-syntax (list #'op #'a #'b) this-syntax) |
| 129 | + ; Explicitly make 'paren-shape #f on the new application form to avoid the #\{ value |
| 130 | + ; being copied onto the prefix application when #%expression is expanded. |
| 131 | + (syntax-property 'paren-shape #f))))] |
135 | 132 | [(_ a:expr) |
136 | 133 | #'a])))) |
137 | 134 |
|
|
0 commit comments