fix: seq expression following decl expression

pull/625/head^2
Nikolaj Sidorenco 2024-04-25 22:41:07 +07:00
parent 0b7fcabb78
commit 7a793db220
No known key found for this signature in database
5 changed files with 16416 additions and 16360 deletions

@ -1,6 +1,7 @@
do
Serializer(
1,
2,
3
)
let f x =
let y = x + 1
printfn y
printfn y
printfn y
printfn y

@ -702,16 +702,13 @@ module.exports = grammar({
)),
declaration_expression: $ =>
prec.right(PREC.LET_EXPR,
seq(
choice(
seq(choice('use', 'use!'), $.identifier, '=', scoped($._expression, $._indent, $._dedent)),
$.function_or_value_defn,
),
field('in',
prec.right(PREC.SEQ_EXPR + 1, $._expression)
),
)),
seq(
choice(
seq(choice('use', 'use!'), $.identifier, '=', scoped($._expression, $._indent, $._dedent)),
$.function_or_value_defn,
),
field('in', $._expression)
),
do_expression: $ =>
prec(PREC.DO_EXPR,

130
src/grammar.json generated

@ -2663,77 +2663,69 @@
}
},
"declaration_expression": {
"type": "PREC_RIGHT",
"value": 60,
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "use"
},
{
"type": "STRING",
"value": "use!"
}
]
},
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "STRING",
"value": "="
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_indent"
},
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "SYMBOL",
"name": "_dedent"
}
]
}
]
},
{
"type": "SYMBOL",
"name": "function_or_value_defn"
}
]
},
{
"type": "FIELD",
"name": "in",
"content": {
"type": "PREC_RIGHT",
"value": 2,
"content": {
"type": "SYMBOL",
"name": "_expression"
}
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "use"
},
{
"type": "STRING",
"value": "use!"
}
]
},
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "STRING",
"value": "="
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_indent"
},
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "SYMBOL",
"name": "_dedent"
}
]
}
]
},
{
"type": "SYMBOL",
"name": "function_or_value_defn"
}
]
},
{
"type": "FIELD",
"name": "in",
"content": {
"type": "SYMBOL",
"name": "_expression"
}
]
}
}
]
},
"do_expression": {
"type": "PREC",

32550
src/parser.c generated

File diff suppressed because it is too large Load Diff

@ -99,3 +99,69 @@ do
(const (int))
(const (int)))
(const (int)))))))
================================================================================
declaration expression should contain all sequential expressions
================================================================================
let f x =
let y = x + 1
printfn y
printfn y
printfn y
printfn y
--------------------------------------------------------------------------------
(file
(value_declaration
(function_or_value_defn
(function_declaration_left
(identifier)
(argument_patterns
(long_identifier
(identifier))))
(declaration_expression
(function_or_value_defn
(value_declaration_left
(identifier_pattern
(long_identifier
(identifier))))
(infix_expression
(long_identifier_or_op
(long_identifier
(identifier)))
(infix_op)
(const
(int))))
(sequential_expression
(application_expression
(long_identifier_or_op
(long_identifier
(identifier)))
(long_identifier_or_op
(long_identifier
(identifier))))
(sequential_expression
(application_expression
(long_identifier_or_op
(long_identifier
(identifier)))
(long_identifier_or_op
(long_identifier
(identifier))))
(sequential_expression
(application_expression
(long_identifier_or_op
(long_identifier
(identifier)))
(long_identifier_or_op
(long_identifier
(identifier))))
(application_expression
(long_identifier_or_op
(long_identifier
(identifier)))
(long_identifier_or_op
(long_identifier
(identifier)))))))))))