Skip to content

Commit

Permalink
parse chains of binary ~ as a macro call to @~. closes JuliaLang#4882
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored and tknopp committed Jan 13, 2014
1 parent 4b70431 commit 79ce2f8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
10 changes: 7 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ New language features
* Tuples (of integers, symbols, or bools) can now be used as type
parameters ([#5164]).

* `import module: name1, name2, ...` ([#5214]).

* Default "inner" constructors now accept any arguments. Constructors that
look like `MyType(a, b) = new(a, b)` can and should be removed ([#4026]).

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

* Binary `~` now parses as a vararg macro call to `@~`.
For example `x~y~z` => `@~ x y z` ([#4882]).

New library functions
---------------------

Expand Down Expand Up @@ -110,7 +111,6 @@ Deprecated or removed

[#4042]: https://github.com/JuliaLang/julia/issues/4042
[#5164]: https://github.com/JuliaLang/julia/issues/5164
[#5214]: https://github.com/JuliaLang/julia/issues/5214
[#4026]: https://github.com/JuliaLang/julia/issues/4026
[#4799]: https://github.com/JuliaLang/julia/issues/4799
[#4862]: https://github.com/JuliaLang/julia/issues/4862
Expand Down Expand Up @@ -139,6 +139,7 @@ Deprecated or removed
[#987]: https://github.com/JuliaLang/julia/issues/987
[#2345]: https://github.com/JuliaLang/julia/issues/2345
[#5330]: https://github.com/JuliaLang/julia/issues/5330
[#4882]: https://github.com/JuliaLang/julia/issues/4882

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

* `import module: name1, name2, ...` ([#5214]).

* A semicolon is now allowed after an `import` or `using` statement ([#4130]).

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

[packages chapter]: http://docs.julialang.org/en/latest/manual/packages/
[sorting functions]: http://docs.julialang.org/en/latest/stdlib/sort/
Expand Down
14 changes: 11 additions & 3 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,9 @@
; parse right-to-left binary operator
; produces structures like (= a (= b (= c d)))
(define (parse-RtoL s down ops)
(let ((ex (down s))
(t (peek-token s))
(spc (ts:space? s)))
(let loop ((ex (down s))
(t (peek-token s))
(spc (ts:space? s)))
(if (not (memq t ops))
ex
(begin (take-token s)
Expand All @@ -457,6 +457,14 @@
ex)
((syntactic-op? t)
(list t ex (parse-RtoL s down ops)))
((eq? t '~)
(let ((args (parse-chain s down '~)))
(if (memq (peek-token s) ops)
`(macrocall @~ ,ex ,@(butlast args)
,(loop (last args)
(peek-token s)
(ts:space? s)))
`(macrocall @~ ,ex ,@args))))
(else
(list 'call t ex (parse-RtoL s down ops))))))))

Expand Down

0 comments on commit 79ce2f8

Please sign in to comment.