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:
parent
fac86781dd
commit
a5f5725cdf
|
@ -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())
|
.ignore_then(expr.clone())
|
||||||
.then_ignore(just(Token::KwOf))
|
.then_ignore(just(Token::KwOf))
|
||||||
.then(
|
.then(
|
||||||
|
@ -350,7 +350,6 @@ fn expr_parser() -> impl Parser<Token, Vec<Spanned<Expr>>, Error = Simple<Token>
|
||||||
.ignore_then(just(Token::KwElse))
|
.ignore_then(just(Token::KwElse))
|
||||||
.ignore_then(expr.clone())
|
.ignore_then(expr.clone())
|
||||||
)
|
)
|
||||||
.then_ignore(just(Token::KwEnd))
|
|
||||||
.map(|((expr, cases), default)| {
|
.map(|((expr, cases), default)| {
|
||||||
(
|
(
|
||||||
Expr::Case {
|
Expr::Case {
|
||||||
|
@ -370,7 +369,7 @@ fn expr_parser() -> impl Parser<Token, Vec<Spanned<Expr>>, Error = Simple<Token>
|
||||||
.or(return_)
|
.or(return_)
|
||||||
.or(do_block)
|
.or(do_block)
|
||||||
.or(if_block)
|
.or(if_block)
|
||||||
.or(match_)
|
.or(case)
|
||||||
.or(pipeline)
|
.or(pipeline)
|
||||||
}).labelled("expression");
|
}).labelled("expression");
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ pub enum Typehint {
|
||||||
Single(String), // e.g. `int`, `bool`, `string`
|
Single(String), // e.g. `int`, `bool`, `string`
|
||||||
Tuple(Vec<Spanned<Self>>), // e.g. `(int, bool)`
|
Tuple(Vec<Spanned<Self>>), // e.g. `(int, bool)`
|
||||||
Vector(Box<Spanned<Self>>), // e.g. `[int]`
|
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)]
|
#[derive(Clone, Debug)]
|
||||||
|
|
|
@ -2,7 +2,6 @@ fun factorial (n: int) : int = do
|
||||||
case n of
|
case n of
|
||||||
| 0 -> return 1
|
| 0 -> return 1
|
||||||
| else return n * factorial(n - 1)
|
| else return n * factorial(n - 1)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
fun main : void = do
|
fun main : void = do
|
||||||
|
|
|
@ -2,8 +2,7 @@ fun fib (n: int): int = do
|
||||||
case n of
|
case n of
|
||||||
| 1 -> return 1
|
| 1 -> return 1
|
||||||
| 2 -> return 1
|
| 2 -> return 1
|
||||||
| else -> return fib(n - 1) + fib(n - 2)
|
| else return fib(n - 1) + fib(n - 2)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
fun main: void = do
|
fun main: void = do
|
||||||
|
|
|
@ -2,7 +2,6 @@ fun print_single (cell: bool): void = do
|
||||||
case cell of
|
case cell of
|
||||||
| true -> @write("█")
|
| true -> @write("█")
|
||||||
| else @write(" ")
|
| else @write(" ")
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
fun print_vec (state: vec_bool) (length: int) (curr: int): void = do
|
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
|
return true
|
||||||
end
|
end
|
||||||
| else return false
|
| else return false
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
fun iter (state: vec_bool) (for: int) (curr: int): void = do
|
fun iter (state: vec_bool) (for: int) (curr: int): void = do
|
||||||
|
|
Loading…
Reference in a new issue