refactor: make missing return type message more precise

This commit is contained in:
Gleb Koval 2025-02-07 16:22:00 +00:00
parent d32855cc29
commit 4738207523
Signed by: cyclane
GPG Key ID: 15E168A8B332382C

View File

@ -117,12 +117,17 @@ object parser {
// Statements
private lazy val `<program>` = Program(
"begin" ~> many(
atomic(`<type>`.label("function declaration") <~> `<ident>` <~ "(") <**> `<partial-func-decl>`
).label("function declaration"),
(atomic(`<ident>` <~ "(").verifiedExplain("function is missing return type") | `<stmt>`.label(
"begin" ~> (
many(
atomic(
`<type>`.label("function declaration") <~> `<ident>` <~ "("
) <**> `<partial-func-decl>`
).label("function declaration") |
atomic(`<ident>` <~ "(").verifiedExplain("function declaration is missing return type")
),
`<stmt>`.label(
"main program body"
)) <~ "end"
) <~ "end"
)
private lazy val `<partial-func-decl>` =
FuncDecl(