Fix multiline stab clause with trailing identifier (#20)
This commit is contained in:
parent
1b3ecf7765
commit
94d6471cc8
11
grammar.js
11
grammar.js
|
@ -672,12 +672,23 @@ module.exports = grammar({
|
||||||
),
|
),
|
||||||
|
|
||||||
_call_arguments_without_parentheses: ($) =>
|
_call_arguments_without_parentheses: ($) =>
|
||||||
|
// In stab clauses a newline can either separate multiple body expressions
|
||||||
|
// or multiple stab clauses, this falls under the $.body conflict. Given a
|
||||||
|
// multiline stab clause with trailing identifier like `1 -> 1 \n x \n 2 -> x`,
|
||||||
|
// there are two matching interpretations:
|
||||||
|
// * `x` as identifier and `2` as stab argument
|
||||||
|
// * `x 2` call as stab argument
|
||||||
|
// Similarly for `Mod.fun` or `mod.fun` the newline should terminate the call.
|
||||||
|
// Consequently, we reject the second interpretation using dynamic precedence
|
||||||
|
prec.dynamic(
|
||||||
|
-1,
|
||||||
// Right precedence, because `fun1 fun2 x, y` is `fun1(fun2(x, y))`
|
// Right precedence, because `fun1 fun2 x, y` is `fun1(fun2(x, y))`
|
||||||
prec.right(
|
prec.right(
|
||||||
choice(
|
choice(
|
||||||
seq(sep1($._expression, ","), optional(seq(",", $.keywords))),
|
seq(sep1($._expression, ","), optional(seq(",", $.keywords))),
|
||||||
$.keywords
|
$.keywords
|
||||||
)
|
)
|
||||||
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
do_block: ($) =>
|
do_block: ($) =>
|
||||||
|
|
|
@ -4791,6 +4791,9 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"_call_arguments_without_parentheses": {
|
"_call_arguments_without_parentheses": {
|
||||||
|
"type": "PREC_DYNAMIC",
|
||||||
|
"value": -1,
|
||||||
|
"content": {
|
||||||
"type": "PREC_RIGHT",
|
"type": "PREC_RIGHT",
|
||||||
"value": 0,
|
"value": 0,
|
||||||
"content": {
|
"content": {
|
||||||
|
@ -4853,6 +4856,7 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"do_block": {
|
"do_block": {
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
|
|
|
@ -380813,8 +380813,8 @@ static const TSParseActionEntry ts_parse_actions[] = {
|
||||||
[3028] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym__items_with_trailing_separator_repeat1, 2),
|
[3028] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym__items_with_trailing_separator_repeat1, 2),
|
||||||
[3030] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym__items_with_trailing_separator_repeat1, 2),
|
[3030] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym__items_with_trailing_separator_repeat1, 2),
|
||||||
[3032] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym__items_with_trailing_separator_repeat1, 2), SHIFT_REPEAT(741),
|
[3032] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym__items_with_trailing_separator_repeat1, 2), SHIFT_REPEAT(741),
|
||||||
[3035] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__call_arguments_without_parentheses, 2),
|
[3035] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__call_arguments_without_parentheses, 2, .dynamic_precedence = -1),
|
||||||
[3037] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym__call_arguments_without_parentheses, 2),
|
[3037] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym__call_arguments_without_parentheses, 2, .dynamic_precedence = -1),
|
||||||
[3039] = {.entry = {.count = 1, .reusable = false}}, SHIFT(315),
|
[3039] = {.entry = {.count = 1, .reusable = false}}, SHIFT(315),
|
||||||
[3041] = {.entry = {.count = 1, .reusable = true}}, SHIFT(5471),
|
[3041] = {.entry = {.count = 1, .reusable = true}}, SHIFT(5471),
|
||||||
[3043] = {.entry = {.count = 1, .reusable = true}}, SHIFT(5469),
|
[3043] = {.entry = {.count = 1, .reusable = true}}, SHIFT(5469),
|
||||||
|
@ -380961,8 +380961,8 @@ static const TSParseActionEntry ts_parse_actions[] = {
|
||||||
[3325] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1257),
|
[3325] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1257),
|
||||||
[3327] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1256),
|
[3327] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1256),
|
||||||
[3329] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1253),
|
[3329] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1253),
|
||||||
[3331] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__call_arguments_without_parentheses, 1),
|
[3331] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__call_arguments_without_parentheses, 1, .dynamic_precedence = -1),
|
||||||
[3333] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym__call_arguments_without_parentheses, 1),
|
[3333] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym__call_arguments_without_parentheses, 1, .dynamic_precedence = -1),
|
||||||
[3335] = {.entry = {.count = 1, .reusable = false}}, SHIFT(443),
|
[3335] = {.entry = {.count = 1, .reusable = false}}, SHIFT(443),
|
||||||
[3337] = {.entry = {.count = 1, .reusable = false}}, SHIFT(337),
|
[3337] = {.entry = {.count = 1, .reusable = false}}, SHIFT(337),
|
||||||
[3339] = {.entry = {.count = 1, .reusable = false}}, SHIFT(630),
|
[3339] = {.entry = {.count = 1, .reusable = false}}, SHIFT(630),
|
||||||
|
@ -381019,10 +381019,10 @@ static const TSParseActionEntry ts_parse_actions[] = {
|
||||||
[3442] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_block, 6),
|
[3442] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_block, 6),
|
||||||
[3444] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_block, 6),
|
[3444] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_block, 6),
|
||||||
[3446] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1245),
|
[3446] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1245),
|
||||||
[3448] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__call_arguments_without_parentheses, 4),
|
[3448] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__call_arguments_without_parentheses, 4, .dynamic_precedence = -1),
|
||||||
[3450] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym__call_arguments_without_parentheses, 4),
|
[3450] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym__call_arguments_without_parentheses, 4, .dynamic_precedence = -1),
|
||||||
[3452] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__call_arguments_without_parentheses, 3),
|
[3452] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__call_arguments_without_parentheses, 3, .dynamic_precedence = -1),
|
||||||
[3454] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym__call_arguments_without_parentheses, 3),
|
[3454] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym__call_arguments_without_parentheses, 3, .dynamic_precedence = -1),
|
||||||
[3456] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1497),
|
[3456] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1497),
|
||||||
[3458] = {.entry = {.count = 1, .reusable = false}}, SHIFT(309),
|
[3458] = {.entry = {.count = 1, .reusable = false}}, SHIFT(309),
|
||||||
[3460] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1500),
|
[3460] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1500),
|
||||||
|
|
|
@ -575,6 +575,114 @@ fun do->end
|
||||||
(do_block
|
(do_block
|
||||||
(stab_clause))))
|
(stab_clause))))
|
||||||
|
|
||||||
|
|
||||||
|
=====================================
|
||||||
|
stab clause / edge cases / trailing call in multiline clause
|
||||||
|
=====================================
|
||||||
|
|
||||||
|
fun do
|
||||||
|
1 ->
|
||||||
|
1
|
||||||
|
x
|
||||||
|
|
||||||
|
1 ->
|
||||||
|
1
|
||||||
|
end
|
||||||
|
|
||||||
|
fun do
|
||||||
|
1 ->
|
||||||
|
1
|
||||||
|
Mod.fun
|
||||||
|
|
||||||
|
1 ->
|
||||||
|
1
|
||||||
|
end
|
||||||
|
|
||||||
|
fun do
|
||||||
|
1 ->
|
||||||
|
1
|
||||||
|
mod.fun
|
||||||
|
|
||||||
|
1 ->
|
||||||
|
1
|
||||||
|
end
|
||||||
|
|
||||||
|
fun do
|
||||||
|
1 ->
|
||||||
|
1
|
||||||
|
|
||||||
|
x 1 ->
|
||||||
|
1
|
||||||
|
end
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(source
|
||||||
|
(call
|
||||||
|
(identifier)
|
||||||
|
(do_block
|
||||||
|
(stab_clause
|
||||||
|
(arguments
|
||||||
|
(integer))
|
||||||
|
(body
|
||||||
|
(integer)
|
||||||
|
(identifier)))
|
||||||
|
(stab_clause
|
||||||
|
(arguments
|
||||||
|
(integer))
|
||||||
|
(body
|
||||||
|
(integer)))))
|
||||||
|
(call
|
||||||
|
(identifier)
|
||||||
|
(do_block
|
||||||
|
(stab_clause
|
||||||
|
(arguments
|
||||||
|
(integer))
|
||||||
|
(body
|
||||||
|
(integer)
|
||||||
|
(call
|
||||||
|
(dot
|
||||||
|
(alias)
|
||||||
|
(identifier)))))
|
||||||
|
(stab_clause
|
||||||
|
(arguments
|
||||||
|
(integer))
|
||||||
|
(body
|
||||||
|
(integer)))))
|
||||||
|
(call
|
||||||
|
(identifier)
|
||||||
|
(do_block
|
||||||
|
(stab_clause
|
||||||
|
(arguments
|
||||||
|
(integer))
|
||||||
|
(body
|
||||||
|
(integer)
|
||||||
|
(call
|
||||||
|
(dot
|
||||||
|
(identifier)
|
||||||
|
(identifier)))))
|
||||||
|
(stab_clause
|
||||||
|
(arguments
|
||||||
|
(integer))
|
||||||
|
(body
|
||||||
|
(integer)))))
|
||||||
|
(call
|
||||||
|
(identifier)
|
||||||
|
(do_block
|
||||||
|
(stab_clause
|
||||||
|
(arguments
|
||||||
|
(integer))
|
||||||
|
(body
|
||||||
|
(integer)))
|
||||||
|
(stab_clause
|
||||||
|
(arguments
|
||||||
|
(call
|
||||||
|
(identifier)
|
||||||
|
(arguments
|
||||||
|
(integer))))
|
||||||
|
(body
|
||||||
|
(integer))))))
|
||||||
|
|
||||||
=====================================
|
=====================================
|
||||||
pattern matching
|
pattern matching
|
||||||
=====================================
|
=====================================
|
||||||
|
|
Loading…
Reference in New Issue