From f66874f1f5066e57ef5761cd7c87b5d498fd89b6 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Fri, 2 Sep 2022 12:57:29 +0100 Subject: Private variables --- src/Parser.hs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/Parser.hs') diff --git a/src/Parser.hs b/src/Parser.hs index de8cce0..f3fd03b 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -63,13 +63,13 @@ type' = do try typFn <|> typ "type" -arg :: Parser (String, Type, SourcePos) +arg :: Parser (String, Type, Bool, SourcePos) arg = do pos <- getPosition i <- identifier _ <- colonSep "\":\" before type" t <- type' "type" - return $ (i, t, pos) + return $ (i, t, True, pos) fdef :: Ident -> Bool -> Bool -> SourcePos -> Parser Expr fdef ident priv anon pos = do @@ -118,12 +118,13 @@ call = do var :: Parser Expr var = do + priv <- optionMaybe $ reserved "private" reserved "var" - (ident, typ, pos) <- arg + (ident, typ, _, pos) <- arg reservedOp "=" "assignation" value <- expr reservedOp ";" - return $ Var ident typ value pos + return $ Var ident typ value (isJust priv) pos factor :: Parser Expr factor = @@ -158,7 +159,7 @@ program = do m <- module' n <- many $ do - function + try function <|> var <|> statement "statement" return $ [m] ++ n -- cgit v1.2.3