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

optional semicolons!!

This commit is contained in:
Natapat Samutpong 2022-02-12 18:51:43 +07:00
parent a3376f2492
commit 20decd8677
2 changed files with 12 additions and 7 deletions

View file

@ -1,5 +1,10 @@
func join :: (a, b) = {
let result :: String = from(a, b);
return result;
return result
};
func main :: () = {
let foo :: String = join("f", "oo");
print(foo);
return 0
};
let foo :: String = join("f", "oo");

View file

@ -1,7 +1,7 @@
use nom::{
branch::alt,
bytes::complete::take,
combinator::{verify, map},
combinator::{verify, map, opt},
Err,
error::{Error, ErrorKind},
IResult,
@ -155,7 +155,7 @@ fn parse_return_stmt(input: Tokens) -> IResult<Tokens, Stmt> {
delimited(
tag_return,
parse_expr_lowest,
tag_semicolon,
opt(tag_semicolon),
),
Stmt::Return,
)(input)
@ -168,7 +168,7 @@ fn parse_call_stmt(input: Tokens) -> IResult<Tokens, Stmt> {
tag_lparen,
parse_exprs,
tag_rparen,
tag_semicolon,
opt(tag_semicolon),
)),
|(ident, _, args, _, _)| Stmt::Call(ident, args),
)(input)
@ -189,7 +189,7 @@ fn parse_func_stmt(input: Tokens) -> IResult<Tokens, Stmt> {
tag_rparen,
tag_assign,
parse_block_stmt,
tag_semicolon,
opt(tag_semicolon),
)),
|(_, ident, _, _, params, _, _, block, _)| Stmt::Func(ident, params, block),
)(input)
@ -204,7 +204,7 @@ fn parse_let_stmt(input: Tokens) -> IResult<Tokens, Stmt> {
parse_ident,
tag_assign,
parse_expr_lowest,
tag_semicolon,
opt(tag_semicolon),
)),
|(_, ident, _, typehint, _, expr, _)| Stmt::Let(ident, typehint, expr),
)(input)