Skip to content

Commit

Permalink
This is now a keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
EliasC committed Dec 10, 2014
1 parent f898b08 commit 26130e2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion emacs/encore-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
;; init-file. There is a hook to enable encore-mode for all files
;; with extension .enc.

(setq encore-keywords '("class" "def" "else" "get" "if" "in" "let" "new" "passive" "print" "then" "unless" "while" "and" "or" "not"))
(setq encore-keywords '("class" "def" "else" "get" "if" "in" "let" "new" "passive" "print" "then" "unless" "while" "and" "or" "not" "this"))
(setq encore-danger-words '("embed" "body" "end"))
(setq encore-constants '("true" "false" "null"))
(setq encore-primitives '("int" "string" "void" "bool"))
Expand Down
4 changes: 2 additions & 2 deletions src/parser/Parser/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ lexer =
P.identStart = letter,
P.reservedNames = ["passive", "class", "def", "let", "in", "if", "unless", "then", "else",
"and", "or", "not", "while", "get", "null", "true", "false", "new", "embed",
"body", "end", "Fut", "Par", "import", "qualified", "module"],
"body", "end", "Fut", "Par", "import", "qualified", "module", "this"],
P.reservedOpNames = [":", "=", "==", "!=", "<", ">", "<=", ">=", "+", "-", "*", "/", "%", "->", "\\", "()"]
}

Expand Down Expand Up @@ -380,7 +380,7 @@ expr = unit
body <- expression
return $ Closure (meta pos) params body
varAccess = do pos <- getPosition
id <- identifier
id <- (do reserved "this"; return "this") <|> identifier
return $ VarAccess (meta pos) $ Name id
null = do pos <- getPosition
reserved "null"
Expand Down
13 changes: 7 additions & 6 deletions src/types/Typechecker/Typechecker.hs
Original file line number Diff line number Diff line change
Expand Up @@ -291,18 +291,19 @@ instance Checkable Expr where

typecheck let_@(Let {decls, body}) =
do eDecls <- typecheckDecls decls
let declTypes = map (AST.getType . snd) eDecls
declNames = map fst eDecls
let declNames = map fst eDecls
declTypes = map (AST.getType . snd) eDecls
when (any isNullType declTypes) $
tcError $ "Cannot infer type of null-valued expression"
eBody <- local (extendEnvironment (zip declNames declTypes)) $ pushTypecheck body
return $ setType (AST.getType eBody) let_ {decls = eDecls, body = eBody}
where
typecheckDecls [] = return []
typecheckDecls ((name, expr):decls) = do eExpr <- pushTypecheck expr
eDecls <- local (extendEnvironment [(name, AST.getType eExpr)])
$ typecheckDecls decls
return $ (name, eExpr):eDecls
typecheckDecls ((name, expr):decls) =
do eExpr <- pushTypecheck expr
eDecls <- local (extendEnvironment [(name, AST.getType eExpr)]) $ typecheckDecls decls
return $ (name, eExpr):eDecls

typecheck seq@(Seq {eseq}) =
do eEseq <- mapM pushTypecheck eseq
let seqType = AST.getType (last eEseq)
Expand Down

0 comments on commit 26130e2

Please sign in to comment.