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) = { func join :: (a, b) = {
let result :: String = from(a, b); let result :: String = from(a, b);
return result; return result
}; };
let foo :: String = join("f", "oo");
func main :: () = {
let foo :: String = join("f", "oo");
print(foo);
return 0
};

View file

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