mirror of
https://github.com/azur1s/bobbylisp.git
synced 2024-10-16 02:37:40 -05:00
fix a bit of parser
This commit is contained in:
parent
a956b8c7d2
commit
16fca1cee6
|
@ -1,5 +1,6 @@
|
|||
# Hycron
|
||||
Programming language that compiles to C
|
||||
|
||||
Note: The syntax can still be changed, if you have an idea, feel free to make an issues about it.
|
||||
|
||||
# Prerequistie
|
||||
|
|
|
@ -3,8 +3,10 @@ let bar: string = "str";
|
|||
let baz: bool = true;
|
||||
|
||||
fun qux (lhs: int rhs: int) -> int = lhs + rhs;
|
||||
fun quux () -> string = "Hi, World!\n";
|
||||
fun main () -> int = do
|
||||
let msg: string = "Hello, World!";
|
||||
let msg: string = "Hello, World!\n";
|
||||
write(msg);
|
||||
write(quux());
|
||||
0;
|
||||
end;
|
|
@ -35,7 +35,7 @@ pub fn lexer() -> impl Parser<char, Vec<(Token, Span)>, Error = Simple<char>> {
|
|||
.map(|s: String| Token::Float(s));
|
||||
|
||||
let string = just('"')
|
||||
.ignore_then(filter(|c| *c != '\\' && *c != '"').repeated())
|
||||
.ignore_then(filter(|c| *c != '"').repeated())
|
||||
.then_ignore(just('"'))
|
||||
.collect::<String>()
|
||||
.map(|s: String| Token::String(s));
|
||||
|
@ -134,8 +134,6 @@ pub enum Expr {
|
|||
else_: Box<Self>,
|
||||
},
|
||||
Do { body: Vec<Self> },
|
||||
|
||||
Import(String),
|
||||
}
|
||||
|
||||
fn expr_parser() -> impl Parser<Token, Expr, Error = Simple<Token>> + Clone {
|
||||
|
@ -282,10 +280,6 @@ fn expr_parser() -> impl Parser<Token, Expr, Error = Simple<Token>> + Clone {
|
|||
body: Box::new(body),
|
||||
}).labelled("function");
|
||||
|
||||
let declare_import = just(Token::Import)
|
||||
.ignore_then(ident.clone())
|
||||
.map(Expr::Import);
|
||||
|
||||
let if_cond = just(Token::If)
|
||||
.ignore_then(expr.clone())
|
||||
.then_ignore(just(Token::Then))
|
||||
|
@ -307,7 +301,6 @@ fn expr_parser() -> impl Parser<Token, Expr, Error = Simple<Token>> + Clone {
|
|||
|
||||
declare_var
|
||||
.or(declare_fun)
|
||||
.or(declare_import)
|
||||
.or(if_cond)
|
||||
.or(do_block)
|
||||
.or(expr)
|
||||
|
|
Loading…
Reference in a new issue