From 7a498e3a581f26b81fc9c2c9c7af8448a7f84f0f Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Tue, 4 Oct 2022 14:46:45 +0300 Subject: Rename and refactor --- src/Builtins.hs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/Builtins.hs') diff --git a/src/Builtins.hs b/src/Builtins.hs index ebaad42..f68cc78 100644 --- a/src/Builtins.hs +++ b/src/Builtins.hs @@ -33,7 +33,12 @@ builtinEnv = M.fromList [ ("unit", makeNonsenseAST ASTUnit), ("_", makeNonsenseAST ASTHole), ("otherwise", makeNonsenseAST ASTHole), - builtinFatal + builtinFatal, + -- reserved keywords + reservedKeyword "\\", + reservedKeyword "let!", + reservedKeyword "match", + reservedKeyword "env!" ] argError1 :: String -> AST -> String @@ -48,6 +53,10 @@ argError3 :: String -> AST -> AST -> AST -> String argError3 fn arg1 arg2 arg3 = "invalid arguments to " ++ fn ++ ": " ++ show arg1 ++ ", " ++ show arg2 ++ ", " ++ show arg3 +reservedKeyword :: String -> (String, AST) +reservedKeyword name = (name, makeNonsenseAST $ ASTFunction fn1) where + fn1 _ ast1 = throwL (astPos ast1) $ "unreachable: " ++ name ++ " is a reserved word" + -- BUILTINS builtinAdd2 :: (String, AST) @@ -211,7 +220,7 @@ builtinConcat = (name, makeNonsenseAST $ ASTFunction fn1) where builtinFatal :: (String, AST) builtinFatal = (name, makeNonsenseAST $ ASTFunction fn1) where - name = "fatal" + name = "fatal!" fn1 _ ast1@AST { astNode = ASTString str } = throwL (astPos ast1) $ str fn1 _ ast1 = -- cgit v1.3