1
1
Fork 0
mirror of https://github.com/azur1s/bobbylisp.git synced 2024-10-16 02:37:40 -05:00

remove redundant token

This commit is contained in:
azur 2022-04-25 05:58:03 +07:00
parent fac86781dd
commit a5f5725cdf
5 changed files with 4 additions and 9 deletions

View file

@ -335,7 +335,7 @@ fn expr_parser() -> impl Parser<Token, Vec<Spanned<Expr>>, Error = Simple<Token>
)
});
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<Token, Vec<Spanned<Expr>>, Error = Simple<Token>
.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<Token, Vec<Spanned<Expr>>, Error = Simple<Token>
.or(return_)
.or(do_block)
.or(if_block)
.or(match_)
.or(case)
.or(pipeline)
}).labelled("expression");

View file

@ -6,7 +6,7 @@ pub enum Typehint {
Single(String), // e.g. `int`, `bool`, `string`
Tuple(Vec<Spanned<Self>>), // e.g. `(int, bool)`
Vector(Box<Spanned<Self>>), // e.g. `[int]`
Function(Vec<Spanned<Self>>, Box<Spanned<Self>>), // e.g. `(a: int, b: bool) -> string`, `(b: int) -> [bool]`
Function(Vec<Spanned<Self>>, Box<Spanned<Self>>), // e.g. `|A: int, B: bool| -> string`, `|A: int| -> [bool]`
}
#[derive(Clone, Debug)]

View file

@ -3,7 +3,6 @@ fun factorial (n: int) : int = do
| 0 -> return 1
| else return n * factorial(n - 1)
end
end
fun main : void = do
let result : int = factorial(5)

View file

@ -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

View file

@ -3,7 +3,6 @@ fun print_single (cell: bool): void = do
| true -> @write("█")
| else @write(" ")
end
end
fun print_vec (state: vec_bool) (length: int) (curr: int): void = do
if curr == length then @write("") else
@ -83,7 +82,6 @@ fun next (state: vec_bool) (pointer: int): bool = do
end
| else return false
end
end
fun iter (state: vec_bool) (for: int) (curr: int): void = do
if curr == for then