aboutsummaryrefslogtreecommitdiff
path: root/src/Evaluator.hs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2020-10-10 06:45:42 +0100
committerAkshay <[email protected]>2020-10-10 06:45:42 +0100
commitf74d9c9bb3722fd20cea000b4f0c2a74be289a9c (patch)
treeceec2de1fdc82f6f2e9693449b969c24925fac8e /src/Evaluator.hs
parent5097a20545bbeeafec191f97e9d0ae3d215ada90 (diff)
add quasiquote, unquote modifiers, basic boolean operations
add more info to readme
Diffstat (limited to 'src/Evaluator.hs')
-rw-r--r--src/Evaluator.hs16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/Evaluator.hs b/src/Evaluator.hs
index c8d8d34..10e5e58 100644
--- a/src/Evaluator.hs
+++ b/src/Evaluator.hs
@@ -10,10 +10,10 @@ import Parser
10import Text.ParserCombinators.Parsec 10import Text.ParserCombinators.Parsec
11 11
12apply :: String -> [Expr] -> LispResult Expr 12apply :: String -> [Expr] -> LispResult Expr
13apply fn args = 13apply fn args = maybe
14 case lookup fn primitives of 14 (throwError $ UnknownFunction fn)
15 Just f -> f args 15 ($ args)
16 _ -> throwError $ UnknownFunction fn 16 (lookup fn primitives)
17 17
18eval :: Expr -> LispResult Expr 18eval :: Expr -> LispResult Expr
19eval v@(StringLiteral s) = return v 19eval v@(StringLiteral s) = return v
@@ -21,9 +21,11 @@ eval v@(IntLiteral i) = return v
21eval v@(BoolLiteral b) = return v 21eval v@(BoolLiteral b) = return v
22eval v@(FloatLiteral f) = return v 22eval v@(FloatLiteral f) = return v
23-- handle quotes as literals 23-- handle quotes as literals
24eval (List[Id "quote", val]) = return val 24eval (List[Id "quote", val]) = return val
25eval (List (Id fn : args)) = mapM eval args >>= apply fn 25eval (List[Id "quasiquote", val]) = undefined
26eval (List[Id "unquote", val]) = undefined
27eval (List (Id fn : args)) = mapM eval args >>= apply fn
26 28
27-- handle bad forms 29-- handle bad forms
28eval idk = throwError $ BadForm "lisk can't recognize this form" idk 30eval invalidForm = throwError $ BadForm "lisk can't recognize this form" invalidForm
29 31