diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs index 3a85b90..42f80cf 100644 --- a/crates/parser/src/lib.rs +++ b/crates/parser/src/lib.rs @@ -335,7 +335,7 @@ fn expr_parser() -> impl Parser>, Error = Simple ) }); - let match_ = just(Token::KwCase) + let case = just(Token::KwCase) .ignore_then(expr.clone()) .then_ignore(just(Token::KwOf)) .then( @@ -350,7 +350,6 @@ fn expr_parser() -> impl Parser>, Error = Simple .ignore_then(just(Token::KwElse)) .ignore_then(expr.clone()) ) - .then_ignore(just(Token::KwEnd)) .map(|((expr, cases), default)| { ( Expr::Case { @@ -370,7 +369,7 @@ fn expr_parser() -> impl Parser>, Error = Simple .or(return_) .or(do_block) .or(if_block) - .or(match_) + .or(case) .or(pipeline) }).labelled("expression"); diff --git a/crates/parser/src/types.rs b/crates/parser/src/types.rs index c20fc8c..358e46b 100644 --- a/crates/parser/src/types.rs +++ b/crates/parser/src/types.rs @@ -6,7 +6,7 @@ pub enum Typehint { Single(String), // e.g. `int`, `bool`, `string` Tuple(Vec>), // e.g. `(int, bool)` Vector(Box>), // e.g. `[int]` - Function(Vec>, Box>), // e.g. `(a: int, b: bool) -> string`, `(b: int) -> [bool]` + Function(Vec>, Box>), // e.g. `|A: int, B: bool| -> string`, `|A: int| -> [bool]` } #[derive(Clone, Debug)] diff --git a/example/factorial.hz b/example/factorial.hz index 3e3cb07..13236fb 100644 --- a/example/factorial.hz +++ b/example/factorial.hz @@ -2,7 +2,6 @@ fun factorial (n: int) : int = do case n of | 0 -> return 1 | else return n * factorial(n - 1) - end end fun main : void = do diff --git a/example/fibonacci.hz b/example/fibonacci.hz index be8cac9..cbeb9fc 100644 --- a/example/fibonacci.hz +++ b/example/fibonacci.hz @@ -2,8 +2,7 @@ fun fib (n: int): int = do case n of | 1 -> return 1 | 2 -> return 1 - | else -> return fib(n - 1) + fib(n - 2) - end + | else return fib(n - 1) + fib(n - 2) end fun main: void = do diff --git a/example/rule110.hz b/example/rule110.hz index 59d1518..d33178e 100644 --- a/example/rule110.hz +++ b/example/rule110.hz @@ -2,7 +2,6 @@ fun print_single (cell: bool): void = do case cell of | true -> @write("█") | else @write(" ") - end end fun print_vec (state: vec_bool) (length: int) (curr: int): void = do @@ -82,7 +81,6 @@ fun next (state: vec_bool) (pointer: int): bool = do return true end | else return false - end end fun iter (state: vec_bool) (for: int) (curr: int): void = do