instance toString SemError
instance toString Gamma
-sem :: AST -> Either [SemError] AST
+sem :: AST -> Either [SemError] (AST, Gamma)
$ extend "1printbool" (Forall [] (BoolType ->> VoidType))
zero
-sem :: AST -> Either [SemError] AST
+sem :: AST -> Either [SemError] (AST, Gamma)
sem (AST fd) = case foldM (const $ hasNoDups fd) () fd
>>| foldM (const isNiceMain) () fd
>>| hasMain fd
- >>| evalStateT (type fd) (defaultGamma, variableStream) of
+ >>| runStateT (type fd) (defaultGamma, variableStream) of
Left e = Left [e]
- Right (_,fds) = Right (AST fds)
+ Right ((_,fds),(gam,_)) = Right (AST fds, gam)
where
hasNoDups :: [FunDecl] FunDecl -> Either SemError ()
hasNoDups fds (FunDecl p n _ _ _ _)
stdin <<< "//PARSER\n" <<< toString parseOut <<< "//PARSER\n")
= case sem (preamble parseOut) of
(Left e) = snd $ fclose (stdin <<< join "\n" (map toString e) <<< "\n") w
- (Right ast)
+ (Right (ast, gam))
# stdin = if (not args.sem) stdin (stdin
- <<< "//SEM G\n" <<< toString ast <<< "//SEMA\n")
+ <<< "//SEM AST\n" <<< toString ast <<< "//SEM AST\n"
+ <<< "//SEM GAMMA\n" <<< toString gam <<< "//SEM GAMMA\n")
= case gen ast of
(Left e) = snd $ fclose (stdin <<< e) w
(Right asm)