merge new changes from master into semantic errors #10

Merged
al4423 merged 19 commits from master into semantic-error-messages 2025-02-06 23:39:05 +00:00
7 changed files with 173 additions and 474 deletions
Showing only changes of commit 057d625464 - Show all commits

View File

@@ -73,11 +73,15 @@ object parser {
) )
private lazy val `<pair-elem-type>` = private lazy val `<pair-elem-type>` =
(`<base-type>` <**> (`<array-type>` </> identity)) | (`<base-type>` <**> (`<array-type>` </> identity)) |
`<pair-type>` ~> ((`<pair-elems-type>` <**> `<array-type>`.explain("for a pair to contain a pair type, it must be an array or erased pair")) </> UntypedPairType) `<pair-type>` ~> ((`<pair-elems-type>` <**> `<array-type>`.explain(
"for a pair to contain a pair type, it must be an array or erased pair"
)) </> UntypedPairType)
// TODO: better explanation here? // TODO: better explanation here?
// Statements // Statements
private lazy val `<program>` = Program( private lazy val `<program>` = Program(
"begin" ~> many(atomic(`<type>`.label("function declaration") <~> `<ident>` <~ "(") <**> `<partial-func-decl>`).label("function declaration"), "begin" ~> many(
atomic(`<type>`.label("function declaration") <~> `<ident>` <~ "(") <**> `<partial-func-decl>`
).label("function declaration"),
`<stmt>`.label("main program body") <~ "end" `<stmt>`.label("main program body") <~ "end"
) )
private lazy val `<partial-func-decl>` = private lazy val `<partial-func-decl>` =
@@ -126,7 +130,7 @@ object parser {
) | `<expr>`.label("valid expression") ) | `<expr>`.label("valid expression")
private lazy val `<pair-elem>` = private lazy val `<pair-elem>` =
Fst("fst" ~> `<lvalue>`.label("a valid pair")) Fst("fst" ~> `<lvalue>`.label("a valid pair"))
| Snd("snd" ~> `<lvalue>`.label("a valid pair")) | Snd("snd" ~> `<lvalue>`.label("a valid pair"))
private lazy val `<array-liter>` = ArrayLiter( private lazy val `<array-liter>` = ArrayLiter(
"[" ~> sepBy(`<expr>`, ",") <~ "]" "[" ~> sepBy(`<expr>`, ",") <~ "]"
) )