aboutsummaryrefslogtreecommitdiff
path: root/src/Env.hs
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2022-09-02 12:57:29 +0100
committerJuan J. Martinez <jjm@usebox.net>2022-09-02 12:57:29 +0100
commitf66874f1f5066e57ef5761cd7c87b5d498fd89b6 (patch)
tree0edef26cda608a79c92f9c64c847f214ba877f9c /src/Env.hs
parenta5633563e9bb579ed10cb7d6d43676485c13b1fb (diff)
downloadmicro-lang-hs-f66874f1f5066e57ef5761cd7c87b5d498fd89b6.tar.gz
micro-lang-hs-f66874f1f5066e57ef5761cd7c87b5d498fd89b6.zip
Private variables
Diffstat (limited to 'src/Env.hs')
-rw-r--r--src/Env.hs10
1 files changed, 5 insertions, 5 deletions
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)