From 641de5e4f68385da3b53bfc532c2d6585a6d958d Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Sun, 14 Aug 2022 19:19:26 +0100 Subject: Limit lambdas to only use local variables Dynamic allocation (and hence closures) is not supported. --- src/Parser.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/Parser.hs') diff --git a/src/Parser.hs b/src/Parser.hs index 1c21700..851b4c0 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -59,8 +59,8 @@ arg = do t <- type' "type" return $ (i, t, pos) -fdef :: Ident -> Bool -> SourcePos -> Parser Expr -fdef ident priv pos = do +fdef :: Ident -> Bool -> Bool -> SourcePos -> Parser Expr +fdef ident priv anon pos = do args <- parens $ commaSep arg rtyp <- optionMaybe @@ -70,7 +70,7 @@ fdef ident priv pos = do return $ rtyp ) body <- braces $ many statement - return $ Func ident args rtyp body priv pos + return $ Func ident args rtyp body priv anon pos function :: Parser Expr function = do @@ -78,7 +78,7 @@ function = do priv <- optionMaybe $ reserved "private" reserved "def" ident <- identifier - fdef ident (isJust priv) pos + fdef ident (isJust priv) False pos lambdaId :: SourcePos -> Ident lambdaId s = @@ -87,7 +87,7 @@ lambdaId s = lambda :: Parser Expr lambda = do pos <- getPosition - fdef (lambdaId pos) True pos + fdef (lambdaId pos) True True pos return' :: Parser Expr return' = do -- cgit v1.2.3