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/Env.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/Env.hs') diff --git a/src/Env.hs b/src/Env.hs index d4c4fa3..5433de0 100644 --- a/src/Env.hs +++ b/src/Env.hs @@ -6,7 +6,7 @@ import Data.Maybe (isJust) import Error import Text.Parsec (SourcePos) -type Sym = (A.Ident, A.Type, SourcePos) +type Sym = (A.Ident, A.Type, Bool, SourcePos) type SymMap = Map.Map A.Ident Sym @@ -44,7 +44,7 @@ existsSyml env sym = isJust $ getSyml env sym -- environment. It will create a new enviroment if the symbol already exists -- (shadowing). addSym :: Env -> Sym -> Env -addSym env@(Env m parent) sym@(id, typ, pos) = case getSym env id of +addSym env@(Env m parent) sym@(id, _, _, _) = case getSym env id of Nothing -> Env (Map.insert id sym m) parent Just s -> Env (Map.singleton id sym) $ Just env @@ -55,8 +55,8 @@ addEnv env = Env Map.empty $ Just env -- | @addSymUniq e s@ adds a local symbol @s@ to the enviroment @e@ if it -- doesn't exist. addSymUniq :: Env -> Sym -> Either Error Env -addSymUniq ev (id, typ, pos) = case getSyml ev id of +addSymUniq ev (id, typ, priv, pos) = case getSyml ev id of Nothing -> Right $ addSym ev sym - Just (_, _, p) -> Left $ Error AlreadyDefined ("symbol \"" ++ id ++ "\" already defined in " ++ show p) pos + Just (_, _, _, p) -> Left $ Error AlreadyDefined ("symbol \"" ++ id ++ "\" already defined in " ++ show p) pos where - sym = (id, typ, pos) + sym = (id, typ, priv, pos) -- cgit v1.2.3