summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--devel/compiler/Eval.hs22
1 files changed, 22 insertions, 0 deletions
diff --git a/devel/compiler/Eval.hs b/devel/compiler/Eval.hs
new file mode 100644
index 000000000..e62336ede
--- /dev/null
+++ b/devel/compiler/Eval.hs
@@ -0,0 +1,22 @@
+module Eval where
+
+import AbsSrc
+import AbsTgt
+
+import qualified Data.Map as M
+
+eval :: Env -> Exp -> Val
+eval env e = case e of
+ ECon c -> look c
+ EStr s -> VTok s
+ ECat x y -> VCat (ev x) (ev y)
+ where
+ look = lookCons env
+ ev = eval env
+
+data Env = Env {
+ constants :: M.Map Ident Val
+ }
+
+lookCons :: Env -> Ident -> Val
+lookCons env c = maybe undefined id $ M.lookup c $ constants env