Merge branch 'master' of https://github.com/dopefishh/cc1516
authorpimjager <pim@pimjager.nl>
Thu, 7 Apr 2016 11:26:35 +0000 (13:26 +0200)
committerpimjager <pim@pimjager.nl>
Thu, 7 Apr 2016 11:26:35 +0000 (13:26 +0200)
Makefile
examples/example.spl
sem.icl

index 593d5d0..fb45bca 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ all: spl
 
 man: spl.1
 
-spl: spl.icl lex.icl lex.dcl parse.icl parse.dcl spl.prj
+spl: spl.icl lex.icl lex.dcl parse.icl parse.dcl spl.prj sem.icl sem.dcl
        $(CPM) make
 
 %.1: %
index 0bf275e..4a55e35 100644 (file)
@@ -2,6 +2,9 @@
        Three ways to implement the f acto rial function in SPL.
        First the recursive version .
 */
+var r = 1;
+var facN = 1;
+var ok = True;
 
 facR(n) :: Int -> Int {
        if (n < 2) {
diff --git a/sem.icl b/sem.icl
index 1cb9e54..02d0117 100644 (file)
--- a/sem.icl
+++ b/sem.icl
@@ -1,6 +1,7 @@
 implementation module sem
 
-from Data.Map import :: Map
+import qualified Data.Map as Map
+from Data.Func import $
 import Data.Either
 import Control.Monad.State
 import StdMisc
@@ -9,17 +10,17 @@ import AST
 from parse import :: ParserOutput
 from yard import :: Error
 
-:: Gamma :== Map String Type
+:: Gamma :== 'Map'.Map String Type
 :: Env a :== State Gamma a
 
 sem :: ParserOutput -> SemOutput
 sem (Left p) = Left p
-sem (Right (AST vd fd)) = undef
+sem (Right (AST vd fd)) = Right $ AST vd fd
 //     foldM semVarDecl vd 
 //     >>= \gamma ->foldM typecheck gamma fd
 
-semVarDecl :: Env VarDecl
-semVarDecl = undef
+semVarDecl :: VarDecl -> Env VarDecl
+semVarDecl (Vardecl pos type ident expr) = undef