Skip to content

Commit b01921a

Browse files
committed
Remove pipe last (|>) syntax
1 parent 1f2349d commit b01921a

File tree

7 files changed

+13
-54
lines changed

7 files changed

+13
-54
lines changed

analysis/reanalyze/src/Exception.ml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -304,17 +304,6 @@ let traverseAst () =
304304
let exceptions = [arg] |> raiseArgs in
305305
currentEvents := {Event.exceptions; loc; kind = Raises} :: !currentEvents;
306306
arg |> snd |> iterExprOpt self
307-
| Texp_apply
308-
{
309-
funct = {exp_desc = Texp_ident (atat, _, _)};
310-
args = [arg; (_lbl1, Some {exp_desc = Texp_ident (callee, _, _)})];
311-
}
312-
when (* Exn(...) |> raise *)
313-
atat |> Path.name = "Pervasives.|>" && callee |> Path.name |> isRaise
314-
->
315-
let exceptions = [arg] |> raiseArgs in
316-
currentEvents := {Event.exceptions; loc; kind = Raises} :: !currentEvents;
317-
arg |> snd |> iterExprOpt self
318307
| Texp_apply {funct = {exp_desc = Texp_ident (callee, _, _)} as e; args} ->
319308
let calleeName = Path.name callee in
320309
if calleeName |> isRaise then

compiler/syntax/src/res_comments_table.ml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,9 +1483,8 @@ and walk_expression expr t comments =
14831483
txt =
14841484
Longident.Lident
14851485
( ":=" | "||" | "&&" | "==" | "===" | "<" | ">" | "!="
1486-
| "!==" | "<=" | ">=" | "|>" | "+" | "+." | "-" | "-."
1487-
| "++" | "^" | "*" | "*." | "/" | "/." | "**" | "->"
1488-
| "<>" );
1486+
| "!==" | "<=" | ">=" | "+" | "+." | "-" | "-." | "++"
1487+
| "^" | "*" | "*." | "/" | "/." | "**" | "->" | "<>" );
14891488
};
14901489
};
14911490
args = [(Nolabel, operand1); (Nolabel, operand2)];

compiler/syntax/src/res_core.ml

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,25 +2186,9 @@ and parse_binary_expr ?(context = OrdinaryExpr) ?a p prec =
21862186
let b = parse_binary_expr ~context p token_prec in
21872187
let loc = mk_loc a.Parsetree.pexp_loc.loc_start b.pexp_loc.loc_end in
21882188
let expr =
2189-
match (token, b.pexp_desc) with
2190-
| ( BarGreater,
2191-
Pexp_apply {funct = fun_expr; args; partial; transformed_jsx} ) ->
2192-
{
2193-
b with
2194-
pexp_desc =
2195-
Pexp_apply
2196-
{
2197-
funct = fun_expr;
2198-
args = args @ [(Nolabel, a)];
2199-
partial;
2200-
transformed_jsx;
2201-
};
2202-
}
2203-
| BarGreater, _ -> Ast_helper.Exp.apply ~loc b [(Nolabel, a)]
2204-
| _ ->
2205-
Ast_helper.Exp.apply ~loc
2206-
(make_infix_operator p token start_pos end_pos)
2207-
[(Nolabel, a); (Nolabel, b)]
2189+
Ast_helper.Exp.apply ~loc
2190+
(make_infix_operator p token start_pos end_pos)
2191+
[(Nolabel, a); (Nolabel, b)]
22082192
in
22092193
Parser.eat_breadcrumb p;
22102194
loop expr)

compiler/syntax/src/res_parsetree_viewer.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ let operator_precedence operator =
280280
| "&&" -> 3
281281
| "^" -> 4
282282
| "&" -> 5
283-
| "==" | "===" | "<" | ">" | "!=" | "<>" | "!==" | "<=" | ">=" | "|>" -> 6
283+
| "==" | "===" | "<" | ">" | "!=" | "<>" | "!==" | "<=" | ">=" -> 6
284284
| "<<" | ">>" | ">>>" -> 7
285285
| "+" | "+." | "-" | "-." | "++" -> 8
286286
| "*" | "*." | "/" | "/." | "%" -> 9
@@ -317,8 +317,8 @@ let is_unary_bitnot_expression expr =
317317
let is_binary_operator operator =
318318
match operator with
319319
| ":=" | "||" | "&&" | "==" | "===" | "<" | ">" | "!=" | "!==" | "<=" | ">="
320-
| "|>" | "+" | "+." | "-" | "-." | "++" | "*" | "*." | "/" | "/." | "**"
321-
| "->" | "<>" | "%" | "&" | "^" | "<<" | ">>" | ">>>" ->
320+
| "+" | "+." | "-" | "-." | "++" | "*" | "*." | "/" | "/." | "**" | "->"
321+
| "<>" | "%" | "&" | "^" | "<<" | ">>" | ">>>" ->
322322
true
323323
| _ -> false
324324

@@ -715,7 +715,7 @@ let is_single_pipe_expr expr =
715715
match expr.pexp_desc with
716716
| Pexp_apply
717717
{
718-
funct = {pexp_desc = Pexp_ident {txt = Longident.Lident ("->" | "|>")}};
718+
funct = {pexp_desc = Pexp_ident {txt = Longident.Lident "->"}};
719719
args = [(Nolabel, _operand1); (Nolabel, _operand2)];
720720
} ->
721721
true
@@ -724,7 +724,7 @@ let is_single_pipe_expr expr =
724724
match expr.pexp_desc with
725725
| Pexp_apply
726726
{
727-
funct = {pexp_desc = Pexp_ident {txt = Longident.Lident ("->" | "|>")}};
727+
funct = {pexp_desc = Pexp_ident {txt = Longident.Lident "->"}};
728728
args = [(Nolabel, operand1); (Nolabel, _operand2)];
729729
}
730730
when not (is_pipe_expr operand1) ->

compiler/syntax/src/res_printer.ml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3753,13 +3753,10 @@ and print_unary_expression ~state expr cmt_tbl =
37533753
and print_binary_expression ~state (expr : Parsetree.expression) cmt_tbl =
37543754
let print_binary_operator ~inline_rhs operator =
37553755
let spacing_before_operator =
3756-
if operator = "->" then Doc.soft_line
3757-
else if operator = "|>" then Doc.line
3758-
else Doc.space
3756+
if operator = "->" then Doc.soft_line else Doc.space
37593757
in
37603758
let spacing_after_operator =
37613759
if operator = "->" then Doc.nil
3762-
else if operator = "|>" then Doc.space
37633760
else if inline_rhs then Doc.space
37643761
else Doc.line
37653762
in
@@ -3930,10 +3927,7 @@ and print_binary_expression ~state (expr : Parsetree.expression) cmt_tbl =
39303927
match expr.pexp_desc with
39313928
| Pexp_apply
39323929
{
3933-
funct =
3934-
{
3935-
pexp_desc = Pexp_ident {txt = Longident.Lident (("->" | "|>") as op)};
3936-
};
3930+
funct = {pexp_desc = Pexp_ident {txt = Longident.Lident ("->" as op)}};
39373931
args = [(Nolabel, lhs); (Nolabel, rhs)];
39383932
}
39393933
when not
@@ -3952,8 +3946,6 @@ and print_binary_expression ~state (expr : Parsetree.expression) cmt_tbl =
39523946
(match (lhs_has_comment_below, op) with
39533947
| true, "->" -> Doc.concat [Doc.soft_line; Doc.text "->"]
39543948
| false, "->" -> Doc.text "->"
3955-
| true, "|>" -> Doc.concat [Doc.line; Doc.text "|> "]
3956-
| false, "|>" -> Doc.text " |> "
39573949
| _ -> Doc.nil);
39583950
rhs_doc;
39593951
])

compiler/syntax/src/res_scanner.ml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -820,9 +820,6 @@ let rec scan scanner =
820820
| '|' ->
821821
next2 scanner;
822822
Token.Lor
823-
| '>' ->
824-
next2 scanner;
825-
Token.BarGreater
826823
| _ ->
827824
next scanner;
828825
Token.Bar)

compiler/syntax/src/res_token.ml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ type t =
9494
| TemplateTail of string * Lexing.position
9595
| TemplatePart of string * Lexing.position
9696
| Backtick
97-
| BarGreater
9897
| Try
9998
| DocComment of Location.t * string
10099
| ModuleComment of Location.t * string
@@ -109,7 +108,7 @@ let precedence = function
109108
| Caret -> 4
110109
| Band -> 5
111110
| Equal | EqualEqual | EqualEqualEqual | LessThan | GreaterThan | BangEqual
112-
| BangEqualEqual | LessEqual | GreaterEqual | BarGreater ->
111+
| BangEqualEqual | LessEqual | GreaterEqual ->
113112
6
114113
| LeftShift | RightShift | RightShiftUnsigned -> 7
115114
| Plus | PlusDot | Minus | MinusDot | PlusPlus -> 8
@@ -213,7 +212,6 @@ let to_string = function
213212
| TemplatePart (text, _) -> text ^ "${"
214213
| TemplateTail (text, _) -> "TemplateTail(" ^ text ^ ")"
215214
| Backtick -> "`"
216-
| BarGreater -> "|>"
217215
| Try -> "try"
218216
| DocComment (_loc, s) -> "DocComment " ^ s
219217
| ModuleComment (_loc, s) -> "ModuleComment " ^ s

0 commit comments

Comments
 (0)