Skip to content

Commit

Permalink
fix for-in slice expression
Browse files Browse the repository at this point in the history
  • Loading branch information
Nsidorenco committed Jun 1, 2024
1 parent 7d560d6 commit 0605512
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 14 deletions.
7 changes: 3 additions & 4 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const PREC = {
ELSE_EXPR: 11,
INTERFACE: 12,
COMMA: 13,
DOTDOT: 14,
PREFIX_EXPR: 15,
SPECIAL_INFIX: 16,
LARROW: 16,
Expand All @@ -43,7 +42,8 @@ const PREC = {
PAREN_APP: 21,
TYPED_EXPR: 22,
PAREN_EXPR: 21,
DOTDOT_SLICE: 22,
DOTDOT: 22,
DOTDOT_SLICE: 23,
};

module.exports = grammar({
Expand Down Expand Up @@ -429,7 +429,6 @@ module.exports = grammar({
$.match_expression,
$.try_expression,
$.literal_expression,
// $.call_expression,
$.tuple_expression,
$.application_expression,
alias($.preproc_if_in_expression, $.preproc_if),
Expand Down Expand Up @@ -676,7 +675,7 @@ module.exports = grammar({
array_expression: ($) => seq("[|", optional($._list_element), "|]"),

range_expression: ($) =>
prec.left(
prec(
PREC.DOTDOT,
seq(
$._expression,
Expand Down
12 changes: 6 additions & 6 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/parser.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 81 additions & 0 deletions test/corpus/expr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2975,3 +2975,84 @@ let f (x: #MyType) = ()
(identifier)))))))
(const
(unit)))))

================================================================================
for in slice expression
================================================================================

do
for x in 0..10 do
()

--------------------------------------------------------------------------------

(file
(value_declaration
(do
(for_expression
(identifier_pattern
(long_identifier_or_op
(identifier)))
(range_expression
(const
(int))
(const
(int)))
(const
(unit))))))

================================================================================
for in slice-skip expression
================================================================================

do
for x in 0..2..10 do
()

--------------------------------------------------------------------------------

(file
(value_declaration
(do
(for_expression
(identifier_pattern
(long_identifier_or_op
(identifier)))
(range_expression
(const
(int))
(const
(int))
(const
(int)))
(const
(unit))))))

================================================================================
for in slice expression complex
================================================================================

do
for x in n..x + 10 do
()

--------------------------------------------------------------------------------

(file
(value_declaration
(do
(for_expression
(identifier_pattern
(long_identifier_or_op
(identifier)))
(range_expression
(long_identifier_or_op
(identifier))
(infix_expression
(long_identifier_or_op
(identifier))
(infix_op)
(const
(int))))
(const
(unit))))))

0 comments on commit 0605512

Please sign in to comment.