Skip to content

Commit a007350

Browse files
committed
parse chains of binary ~ as a macro call to @~. closes #4882
1 parent c73a761 commit a007350

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

NEWS.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ New language features
99
* Tuples (of integers, symbols, or bools) can now be used as type
1010
parameters ([#5164]).
1111

12-
* `import module: name1, name2, ...` ([#5214]).
13-
1412
* Default "inner" constructors now accept any arguments. Constructors that
1513
look like `MyType(a, b) = new(a, b)` can and should be removed ([#4026]).
1614

@@ -21,6 +19,9 @@ New language features
2119
* When reloading code, types whose definitions have not changed can be
2220
ignored in some cases.
2321

22+
* Binary `~` now parses as a vararg macro call to `@~`.
23+
For example `x~y~z` => `@~ x y z` ([#4882]).
24+
2425
New library functions
2526
---------------------
2627

@@ -110,7 +111,6 @@ Deprecated or removed
110111

111112
[#4042]: https://github.com/JuliaLang/julia/issues/4042
112113
[#5164]: https://github.com/JuliaLang/julia/issues/5164
113-
[#5214]: https://github.com/JuliaLang/julia/issues/5214
114114
[#4026]: https://github.com/JuliaLang/julia/issues/4026
115115
[#4799]: https://github.com/JuliaLang/julia/issues/4799
116116
[#4862]: https://github.com/JuliaLang/julia/issues/4862
@@ -139,6 +139,7 @@ Deprecated or removed
139139
[#987]: https://github.com/JuliaLang/julia/issues/987
140140
[#2345]: https://github.com/JuliaLang/julia/issues/2345
141141
[#5330]: https://github.com/JuliaLang/julia/issues/5330
142+
[#4882]: https://github.com/JuliaLang/julia/issues/4882
142143

143144
Julia v0.2.0 Release Notes
144145
==========================
@@ -190,6 +191,8 @@ New language features
190191
* Methods can be added to functions in other modules using dot syntax,
191192
as in `Foo.bar(x) = 0`.
192193

194+
* `import module: name1, name2, ...` ([#5214]).
195+
193196
* A semicolon is now allowed after an `import` or `using` statement ([#4130]).
194197

195198
* In an interactive session (REPL), you can use `;cmd` to run `cmd` via an interactive
@@ -512,6 +515,7 @@ Too numerous to mention.
512515
[#4235]: https://github.com/JuliaLang/julia/issues/4235
513516
[#4284]: https://github.com/JuliaLang/julia/issues/4284
514517
[#4412]: https://github.com/JuliaLang/julia/issues/4412
518+
[#5214]: https://github.com/JuliaLang/julia/issues/5214
515519

516520
[packages chapter]: http://docs.julialang.org/en/latest/manual/packages/
517521
[sorting functions]: http://docs.julialang.org/en/latest/stdlib/sort/

src/julia-parser.scm

+11-3
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,9 @@
445445
; parse right-to-left binary operator
446446
; produces structures like (= a (= b (= c d)))
447447
(define (parse-RtoL s down ops)
448-
(let ((ex (down s))
449-
(t (peek-token s))
450-
(spc (ts:space? s)))
448+
(let loop ((ex (down s))
449+
(t (peek-token s))
450+
(spc (ts:space? s)))
451451
(if (not (memq t ops))
452452
ex
453453
(begin (take-token s)
@@ -457,6 +457,14 @@
457457
ex)
458458
((syntactic-op? t)
459459
(list t ex (parse-RtoL s down ops)))
460+
((eq? t '~)
461+
(let ((args (parse-chain s down '~)))
462+
(if (memq (peek-token s) ops)
463+
`(macrocall @~ ,ex ,@(butlast args)
464+
,(loop (last args)
465+
(peek-token s)
466+
(ts:space? s)))
467+
`(macrocall @~ ,ex ,@args))))
460468
(else
461469
(list 'call t ex (parse-RtoL s down ops))))))))
462470

0 commit comments

Comments
 (0)