fix: parse more than three rules in match expression

pull/625/head^2
Nikolaj Sidorenco 2024-04-19 16:11:39 +07:00
parent ee8d1dcc6e
commit 5238929492
No known key found for this signature in database
5 changed files with 208357 additions and 208231 deletions

@ -1,4 +1,5 @@
let x =
{ new Base with
member _.A() = ()
member _.B() = () }
let a b =
match a, b with
| true, true -> sb.Append(basePath[1]) |> ignore
| false, false -> sb.Append('/').Append(basePath) |> ignore
| _ -> sb.Append(basePath) |> ignore

@ -787,7 +787,7 @@ module.exports = grammar({
prec.right(PREC.MATCH_EXPR,
seq(
optional('|'), $.rule,
repeat(seq(optional($._newline), '|', $.rule)),
prec.right(repeat(prec.right(seq(optional($._newline), '|', $.rule)))),
)),
begin_end_expression: $ => prec(PREC.PAREN_EXPR, seq('begin', $._expression, 'end')),
@ -1459,7 +1459,7 @@ module.exports = grammar({
optional($.attributes),
choice(
seq(optional('static'), optional($.access_modifier), 'member', $.method_or_prop_defn),
seq('abstract', optional($.access_modifier), 'member', $.member_signature),
seq('abstract', optional($.access_modifier), optional('member'), $.member_signature),
seq('override', optional($.access_modifier), $.method_or_prop_defn),
seq('default', optional($.access_modifier), $.method_or_prop_defn),
seq(optional('static'), 'val', optional('mutable'), optional($.access_modifier), $.identifier, ':', $.type),

54
src/grammar.json generated

@ -3071,31 +3071,39 @@
"name": "rule"
},
{
"type": "REPEAT",
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"type": "REPEAT",
"content": {
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_newline"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_newline"
},
{
"type": "BLANK"
}
]
},
{
"type": "BLANK"
"type": "STRING",
"value": "|"
},
{
"type": "SYMBOL",
"name": "rule"
}
]
},
{
"type": "STRING",
"value": "|"
},
{
"type": "SYMBOL",
"name": "rule"
}
]
}
}
}
]
@ -5642,8 +5650,16 @@
]
},
{
"type": "STRING",
"value": "member"
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "member"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",

416424
src/parser.c generated

File diff suppressed because it is too large Load Diff

@ -1738,6 +1738,103 @@ let test =
(const
(int))))))))
================================================================================
match expression 3 rules
================================================================================
let a b =
match a, b with
| true, true -> sb.Append(basePath[1]) |> ignore
| false, false -> sb.Append('/').Append(basePath) |> ignore
| _ -> sb.Append(basePath) |> ignore
--------------------------------------------------------------------------------
(file
(value_declaration
(function_or_value_defn
(function_declaration_left
(identifier)
(argument_patterns
(long_identifier
(identifier))))
(match_expression
(tuple_expression
(long_identifier_or_op
(long_identifier
(identifier)))
(long_identifier_or_op
(long_identifier
(identifier))))
(rules
(rule
(repeat_pattern
(const_pattern
(bool))
(const_pattern
(bool)))
(infix_expression
(call_expression
(long_identifier_or_op
(long_identifier
(identifier)
(identifier)))
(application_expression
(long_identifier_or_op
(long_identifier
(identifier)))
(list_expression
(const
(int)))))
(infix_op
(symbolic_op))
(long_identifier_or_op
(long_identifier
(identifier)))))
(rule
(repeat_pattern
(const_pattern
(bool))
(const_pattern
(bool)))
(infix_expression
(call_expression
(dot_expression
(call_expression
(long_identifier_or_op
(long_identifier
(identifier)
(identifier)))
(const
(char)))
(long_identifier_or_op
(long_identifier
(identifier))))
(long_identifier_or_op
(long_identifier
(identifier))))
(infix_op
(symbolic_op))
(long_identifier_or_op
(long_identifier
(identifier)))))
(rule
(wildcard_pattern)
(infix_expression
(call_expression
(long_identifier_or_op
(long_identifier
(identifier)
(identifier)))
(long_identifier_or_op
(long_identifier
(identifier))))
(infix_op
(symbolic_op))
(long_identifier_or_op
(long_identifier
(identifier))))))))))
================================================================================
object interface expression
================================================================================