Skip to content

Commit 2c741ec

Browse files
author
José Valim
committed
Merge pull request #2702 from alexrp/master
Introduce new operators intended for use by parser combinator libraries.
2 parents 12a4578 + c8bcd89 commit 2c741ec

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

lib/elixir/lib/macro.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ defmodule Macro do
1717
:<, :>, :->,
1818
:+, :-, :*, :/, :=, :|, :.,
1919
:and, :or, :when, :in,
20+
:~>>, :~>, :<~, :<~>, :|~>, :<|>,
2021
:<<<, :>>>, :|||, :&&&, :^^^, :~~~]
2122

2223
@doc false
@@ -39,7 +40,8 @@ defmodule Macro do
3940
o when o in [:&&, :&&&, :and] -> {:left, 140}
4041
o when o in [:==, :!=, :=~, :===, :!==] -> {:left, 150}
4142
o when o in [:<, :<=, :>=, :>] -> {:left, 160}
42-
o when o in [:|>, :<<<, :>>>] -> {:left, 170}
43+
o when o in [:|>, :<<<, :>>>, :~>>, :~>,
44+
:<~, :<~>, :|~>, :<|>] -> {:left, 170}
4345
:in -> {:left, 180}
4446
o when o in [:++, :--, :.., :<>] -> {:right, 200}
4547
o when o in [:+, :-] -> {:left, 210}

lib/elixir/src/elixir_parser.yrl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Left 140 and_op_eol. %% &&, &&&, and
5959
Left 150 comp_op_eol. %% ==, !=, =~, ===, !==
6060
Left 160 rel_op_eol. %% <, >, <=, >=
6161
Left 170 arrow_op_eol. %% < (op), (op) > (e.g |>, <<<, >>>)
62+
%% ~>>, ~>, <~, <~>, |~>, <|>
6263
Left 180 in_op_eol. %% in
6364
Right 200 two_op_eol. %% ++, --, .., <>
6465
Left 210 add_op_eol. %% + (op), - (op)

lib/elixir/src/elixir_tokenizer.erl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,16 @@
3333

3434
-define(arrow_op3(T1, T2, T3),
3535
T1 == $<, T2 == $<, T3 == $<;
36-
T1 == $>, T2 == $>, T3 == $>).
36+
T1 == $>, T2 == $>, T3 == $>;
37+
T1 == $~, T2 == $>, T3 == $>;
38+
T1 == $<, T2 == $~, T3 == $>;
39+
T1 == $|, T2 == $~, T3 == $>;
40+
T1 == $<, T2 == $|, T3 == $>).
3741

3842
-define(arrow_op(T1, T2),
39-
T1 == $|, T2 == $>).
43+
T1 == $|, T2 == $>;
44+
T1 == $~, T2 == $>;
45+
T1 == $<, T2 == $~).
4046

4147
-define(rel_op(T),
4248
T == $<;

0 commit comments

Comments
 (0)