aboutsummaryrefslogtreecommitdiff
path: root/src/Parser.hs
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2022-08-14 19:19:26 +0100
committerJuan J. Martinez <jjm@usebox.net>2022-08-14 19:19:26 +0100
commit641de5e4f68385da3b53bfc532c2d6585a6d958d (patch)
tree33098b477d2e98331db8174cbc51cbb3b5630182 /src/Parser.hs
parent2b78e2b5689d05e484254c9878eeb08542dcfbc5 (diff)
downloadmicro-lang-hs-641de5e4f68385da3b53bfc532c2d6585a6d958d.tar.gz
micro-lang-hs-641de5e4f68385da3b53bfc532c2d6585a6d958d.zip
Limit lambdas to only use local variables
Dynamic allocation (and hence closures) is not supported.
Diffstat (limited to 'src/Parser.hs')
-rw-r--r--src/Parser.hs10
1 files changed, 5 insertions, 5 deletions
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