diff options
author | Juan J. Martinez <jjm@usebox.net> | 2022-09-02 12:57:29 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2022-09-02 12:57:29 +0100 |
commit | f66874f1f5066e57ef5761cd7c87b5d498fd89b6 (patch) | |
tree | 0edef26cda608a79c92f9c64c847f214ba877f9c /src/Parser.hs | |
parent | a5633563e9bb579ed10cb7d6d43676485c13b1fb (diff) | |
download | micro-lang-hs-f66874f1f5066e57ef5761cd7c87b5d498fd89b6.tar.gz micro-lang-hs-f66874f1f5066e57ef5761cd7c87b5d498fd89b6.zip |
Private variables
Diffstat (limited to 'src/Parser.hs')
-rw-r--r-- | src/Parser.hs | 11 |
1 files changed, 6 insertions, 5 deletions
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 |