Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ module.exports = grammar({
'member',
'call',
$.spread_element,
$.await_expression,
$.pipe_expression,
$.await_expression,
$.lazy_expression,
'binary_times',
'binary_pow',
Expand Down Expand Up @@ -106,7 +106,10 @@ module.exports = grammar({
[$.variant_declaration],
[$.unit, $._function_type_parameter_list],
[$.functor_parameter, $.module_primary_expression, $.module_identifier_path],
[$._reserved_identifier, $.function]
[$._reserved_identifier, $.function],
[$.expression, $._jsx_child],
[$.expression, $._jsx_attribute_value],
[$.block, $.jsx_expression]
],

rules: {
Expand Down Expand Up @@ -743,17 +746,9 @@ module.exports = grammar({
)),

pipe_expression: $ => prec.left(seq(
$.primary_expression,
$.expression,
choice('->', '|>'),
choice(
$.value_identifier,
$.value_identifier_path,
$.variant_identifier,
$.polyvar_identifier,
$.nested_variant_identifier,
$.parenthesized_expression,
$.block,
),
$.expression,
Comment on lines 748 to +751
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change makes pipe_expression rule equal to binary_expression, We can do a simplification here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #177

)),

module_pack: $ => seq(
Expand Down
25 changes: 16 additions & 9 deletions test/corpus/expressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ foo->{
baz
}

{foo}->print()

---

(source_file
Expand All @@ -209,24 +211,24 @@ foo->{
(value_identifier)))
(expression_statement
(pipe_expression
(call_expression
(pipe_expression
(value_identifier)
(pipe_expression
(value_identifier)
(call_expression
(value_identifier_path
(module_identifier)
(value_identifier)))
(arguments (value_identifier)))
(module_identifier) (value_identifier))
(arguments
(value_identifier))))
(value_identifier_path
(module_identifier)
(value_identifier))))
(expression_statement
(pipe_expression
(number)
(variant_identifier)))
(variant (variant_identifier))))
(expression_statement
(pipe_expression
(value_identifier)
(polyvar_identifier)))
(polyvar (polyvar_identifier))))
(expression_statement
(pipe_expression
(value_identifier)
Expand All @@ -243,7 +245,12 @@ foo->{
(value_identifier)
(block
(open_statement (module_identifier))
(expression_statement (value_identifier))))))
(expression_statement (value_identifier)))))
(expression_statement
(pipe_expression
(block
(expression_statement (value_identifier)))
(call_expression (value_identifier) (arguments)))))

===========================================
Record
Expand Down