Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f032c61

Browse files
committedJul 19, 2020
add operators <-- and <-->. fixes #36666
1 parent 47989fa commit f032c61

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed
 

‎NEWS.md

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ New language features
66

77
* Types written with `where` syntax can now be used to define constructors, e.g.
88
`(Foo{T} where T)(x) = ...`.
9+
* `<--` and `<-->` are now available as infix operators, with the same precedence
10+
and associativity as other arrow-like operators ([#36666]).
911

1012
Language changes
1113
----------------

‎src/julia-parser.scm

+7-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
(define prec-conditional '(?))
1616
(define prec-arrow (append!
1717
'(-- -->)
18-
(add-dots '(← → ↔ ↚ ↛ ↞ ↠ ↢ ↣ ↦ ↤ ↮ ⇎ ⇍ ⇏ ⇐ ⇒ ⇔ ⇴ ⇶ ⇷ ⇸ ⇹ ⇺ ⇻ ⇼ ⇽ ⇾ ⇿ ⟵ ⟶ ⟷ ⟹ ⟺ ⟻ ⟼ ⟽ ⟾ ⟿ ⤀ ⤁ ⤂ ⤃ ⤄ ⤅ ⤆ ⤇ ⤌ ⤍ ⤎ ⤏ ⤐ ⤑ ⤔ ⤕ ⤖ ⤗ ⤘ ⤝ ⤞ ⤟ ⤠ ⥄ ⥅ ⥆ ⥇ ⥈ ⥊ ⥋ ⥎ ⥐ ⥒ ⥓ ⥖ ⥗ ⥚ ⥛ ⥞ ⥟ ⥢ ⥤ ⥦ ⥧ ⥨ ⥩ ⥪ ⥫ ⥬ ⥭ ⥰ ⧴ ⬱ ⬰ ⬲ ⬳ ⬴ ⬵ ⬶ ⬷ ⬸ ⬹ ⬺ ⬻ ⬼ ⬽ ⬾ ⬿ ⭀ ⭁ ⭂ ⭃ ⭄ ⭇ ⭈ ⭉ ⭊ ⭋ ⭌ ← → ⇜ ⇝ ↜ ↝ ↩ ↪ ↫ ↬ ↼ ↽ ⇀ ⇁ ⇄ ⇆ ⇇ ⇉ ⇋ ⇌ ⇚ ⇛ ⇠ ⇢ ↷ ↶ ↺ ↻))))
18+
(add-dots '(← → ↔ ↚ ↛ ↞ ↠ ↢ ↣ ↦ ↤ ↮ ⇎ ⇍ ⇏ ⇐ ⇒ ⇔ ⇴ ⇶ ⇷ ⇸ ⇹ ⇺ ⇻ ⇼ ⇽ ⇾ ⇿ ⟵ ⟶ ⟷ ⟹ ⟺ ⟻ ⟼ ⟽ ⟾ ⟿ ⤀ ⤁ ⤂ ⤃ ⤄ ⤅ ⤆ ⤇ ⤌ ⤍ ⤎ ⤏ ⤐ ⤑ ⤔ ⤕ ⤖ ⤗ ⤘ ⤝ ⤞ ⤟ ⤠ ⥄ ⥅ ⥆ ⥇ ⥈ ⥊ ⥋ ⥎ ⥐ ⥒ ⥓ ⥖ ⥗ ⥚ ⥛ ⥞ ⥟ ⥢ ⥤ ⥦ ⥧ ⥨ ⥩ ⥪ ⥫ ⥬ ⥭ ⥰ ⧴ ⬱ ⬰ ⬲ ⬳ ⬴ ⬵ ⬶ ⬷ ⬸ ⬹ ⬺ ⬻ ⬼ ⬽ ⬾ ⬿ ⭀ ⭁ ⭂ ⭃ ⭄ ⭇ ⭈ ⭉ ⭊ ⭋ ⭌ ← → ⇜ ⇝ ↜ ↝ ↩ ↪ ↫ ↬ ↼ ↽ ⇀ ⇁ ⇄ ⇆ ⇇ ⇉ ⇋ ⇌ ⇚ ⇛ ⇠ ⇢ ↷ ↶ ↺ ↻ <-- <-->))))
1919
(define prec-lazy-or '(|\|\||))
2020
(define prec-lazy-and '(&&))
2121
(define prec-comparison
@@ -249,7 +249,12 @@
249249
(or sufchar? (opchar? c)))
250250
(let* ((newop (string str c))
251251
(opsym (string->symbol newop)))
252-
(if (operator? opsym)
252+
(if (or (operator? opsym)
253+
;; <- is not an operator but <-- and <--> are
254+
(and (eq? opsym '<-)
255+
(read-char port)
256+
(begin0 (eqv? (peek-char port) #\-)
257+
(io.ungetc port #\-))))
253258
(begin (read-char port)
254259
(loop newop (peek-char port) sufchar?))
255260
str))

‎test/syntax.jl

+3
Original file line numberDiff line numberDiff line change
@@ -2292,3 +2292,6 @@ end
22922292

22932293
@test (Int .<: [Integer] .<: [Real]) == [true]
22942294
end
2295+
2296+
@test :(a <-- b <-- c) == Expr(:call, :<--, :a, Expr(:call, :<--, :b, :c))
2297+
@test :(a<-->b<-->c) == Expr(:call, :<-->, :a, Expr(:call, :<-->, :b, :c))

0 commit comments

Comments
 (0)
Please sign in to comment.