definition module sem
+import qualified Data.Map as Map
from Data.Either import :: Either
from AST import :: AST, :: Pos, :: Type
from StdOverloaded import class toString
| UnifyError Pos Type Type
| UnifyErrorStub Type Type
| Error String
-:: SemOutput :== Either [SemError] AST
-
+:: Gamma
+:: SemOutput :== Either [SemError] (AST, Gamma)
instance toString SemError
+instance toString Gamma
sem :: AST -> SemOutput
toString t1, ". Given: ", toString t2]
sem :: AST -> SemOutput
-sem (AST vd fd) = case evalStateT m ('Map'.newMap, getRandomStream 0) of
+sem (AST vd fd) = case runStateT m ('Map'.newMap, getRandomStream 0) of
Left e = Left [e]
- Right (vds, fds) = Right (AST vds fds)
+ Right ((vds, fds), gamma) = Right ((AST vds fds), gamma)
where
m :: Env (([VarDecl], [FunDecl]))
m = (mapM semVarDecl vd) >>= \vds ->
extrPos (BoolExpr p _) = p
extrPos (FunExpr p _) = p
extrPos (EmptyListExpr p) = p
-extrPos (TupleExpr p _) = p
\ No newline at end of file
+extrPos (TupleExpr p _) = p
+
+instance toString Gamma where
+ toString (mp, _) = concat
+ [concat [k, ": ", toString v, "\n"]\\(k, v) <- 'Map'.toList mp]
import Data.Func
import System.CommandLine
import GenPrint
+import Data.Map
from Text import class Text(concat,join), instance Text String
import parse
stdin <<< "//PARSER\n" <<< toString parseOut <<< "//PARSER\n")
= case sem parseOut of
(Left e) = snd $ fclose (stdin <<< join "\n" (map toString e)) w
- (Right semOut)
+ (Right (semOut, gamma))
# stdin = if (not args.sem) stdin (
- stdin <<< "//SEM\n" <<< toString semOut <<< "//SEM\n")
+ stdin <<< "//SEM\n" <<< toString gamma <<< "//SEM\n")
= snd $ fclose stdin w
where
printTokens :: [Token] -> String