|
3 | 3 | ; for most operators X there is a .X "elementwise" equivalent
|
4 | 4 | (define (add-dots ops) (append! ops (map (lambda (op) (symbol (string "." op))) ops)))
|
5 | 5 |
|
6 |
| -;; note: there are some strange-looking things in here because |
7 |
| -;; the way the lexer works, every prefix of an operator must also |
8 |
| -;; be an operator. |
9 | 6 | (define prec-assignment
|
10 | 7 | (append! (add-dots '(= += -= *= /= //= |\\=| ^= ÷= %= <<= >>= >>>= |\|=| &= ⊻= ≔ ⩴ ≕))
|
11 | 8 | (add-dots '(~))
|
12 | 9 | '(:= $=)))
|
13 | 10 | ;; comma - higher than assignment outside parentheses, lower when inside
|
14 | 11 | (define prec-pair (add-dots '(=>)))
|
15 | 12 | (define prec-conditional '(?))
|
16 |
| -(define prec-arrow (append! |
17 |
| - '(-- -->) |
18 |
| - (add-dots '(← → ↔ ↚ ↛ ↞ ↠ ↢ ↣ ↦ ↤ ↮ ⇎ ⇍ ⇏ ⇐ ⇒ ⇔ ⇴ ⇶ ⇷ ⇸ ⇹ ⇺ ⇻ ⇼ ⇽ ⇾ ⇿ ⟵ ⟶ ⟷ ⟹ ⟺ ⟻ ⟼ ⟽ ⟾ ⟿ ⤀ ⤁ ⤂ ⤃ ⤄ ⤅ ⤆ ⤇ ⤌ ⤍ ⤎ ⤏ ⤐ ⤑ ⤔ ⤕ ⤖ ⤗ ⤘ ⤝ ⤞ ⤟ ⤠ ⥄ ⥅ ⥆ ⥇ ⥈ ⥊ ⥋ ⥎ ⥐ ⥒ ⥓ ⥖ ⥗ ⥚ ⥛ ⥞ ⥟ ⥢ ⥤ ⥦ ⥧ ⥨ ⥩ ⥪ ⥫ ⥬ ⥭ ⥰ ⧴ ⬱ ⬰ ⬲ ⬳ ⬴ ⬵ ⬶ ⬷ ⬸ ⬹ ⬺ ⬻ ⬼ ⬽ ⬾ ⬿ ⭀ ⭁ ⭂ ⭃ ⭄ ⭇ ⭈ ⭉ ⭊ ⭋ ⭌ ← → ⇜ ⇝ ↜ ↝ ↩ ↪ ↫ ↬ ↼ ↽ ⇀ ⇁ ⇄ ⇆ ⇇ ⇉ ⇋ ⇌ ⇚ ⇛ ⇠ ⇢ ↷ ↶ ↺ ↻ <-- <-->)))) |
| 13 | +(define prec-arrow (add-dots '(← → ↔ ↚ ↛ ↞ ↠ ↢ ↣ ↦ ↤ ↮ ⇎ ⇍ ⇏ ⇐ ⇒ ⇔ ⇴ ⇶ ⇷ ⇸ ⇹ ⇺ ⇻ ⇼ ⇽ ⇾ ⇿ ⟵ ⟶ ⟷ ⟹ ⟺ ⟻ ⟼ ⟽ ⟾ ⟿ ⤀ ⤁ ⤂ ⤃ ⤄ ⤅ ⤆ ⤇ ⤌ ⤍ ⤎ ⤏ ⤐ ⤑ ⤔ ⤕ ⤖ ⤗ ⤘ ⤝ ⤞ ⤟ ⤠ ⥄ ⥅ ⥆ ⥇ ⥈ ⥊ ⥋ ⥎ ⥐ ⥒ ⥓ ⥖ ⥗ ⥚ ⥛ ⥞ ⥟ ⥢ ⥤ ⥦ ⥧ ⥨ ⥩ ⥪ ⥫ ⥬ ⥭ ⥰ ⧴ ⬱ ⬰ ⬲ ⬳ ⬴ ⬵ ⬶ ⬷ ⬸ ⬹ ⬺ ⬻ ⬼ ⬽ ⬾ ⬿ ⭀ ⭁ ⭂ ⭃ ⭄ ⭇ ⭈ ⭉ ⭊ ⭋ ⭌ ← → ⇜ ⇝ ↜ ↝ ↩ ↪ ↫ ↬ ↼ ↽ ⇀ ⇁ ⇄ ⇆ ⇇ ⇉ ⇋ ⇌ ⇚ ⇛ ⇠ ⇢ ↷ ↶ ↺ ↻ --> <-- <-->))) |
19 | 14 | (define prec-lazy-or '(|\|\||))
|
20 | 15 | (define prec-lazy-and '(&&))
|
21 | 16 | (define prec-comparison
|
|
66 | 61 | ; only allow/strip suffixes for some operators
|
67 | 62 | (define no-suffix? (Set (append prec-assignment prec-conditional prec-lazy-or prec-lazy-and
|
68 | 63 | prec-colon prec-decl prec-dot
|
69 |
| - '(-- --> -> |<:| |>:| in isa $) |
| 64 | + '(-> |<:| |>:| in isa $) |
70 | 65 | (list ctrans-op trans-op vararg-op))))
|
71 | 66 | (define (maybe-strip-op-suffix op)
|
72 | 67 | (if (symbol? op)
|
|
115 | 110 | ; operators that are special forms, not function names
|
116 | 111 | (define syntactic-operators
|
117 | 112 | (append! (add-dots '(= += -= *= /= //= |\\=| ^= ÷= %= <<= >>= >>>= |\|=| &= ⊻=))
|
118 |
| - '(:= --> $= && |\|\|| |.| ... ->))) |
| 113 | + '(:= $= && |\|\|| |.| ... ->))) |
119 | 114 | (define syntactic-unary-operators '($ & |::|))
|
120 | 115 |
|
121 | 116 | (define syntactic-op? (Set syntactic-operators))
|
|
252 | 247 | (if (or (operator? opsym)
|
253 | 248 | (and (or (eq? opsym '<---) (eq? opsym '.<---))
|
254 | 249 | (error (string "invalid operator \"" newop "\"")))
|
| 250 | + ;; -- is not an operator but --> is |
| 251 | + (and (or (eq? opsym '--) (eq? opsym '.--)) |
| 252 | + (read-char port) |
| 253 | + (or (begin0 (eqv? (peek-char port) #\>) |
| 254 | + (io.ungetc port #\-)) |
| 255 | + (error (string "invalid operator \"" newop "\"")))) |
255 | 256 | ;; <- is not an operator but <-- and <--> are
|
256 | 257 | (and (or (eq? opsym '<-) (eq? opsym '.<-))
|
257 | 258 | (read-char port)
|
|
261 | 262 | (loop newop (peek-char port) sufchar?))
|
262 | 263 | str))
|
263 | 264 | str))))))
|
264 |
| - (if (equal? str "--") |
265 |
| - (error (string "invalid operator \"" str "\""))) |
266 | 265 | (string->symbol str))))
|
267 | 266 |
|
268 | 267 | (define (accum-digits c pred port _-digit-sep)
|
|
0 commit comments