glados-0.1.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

AST.Semantics.Check

Synopsis

Documentation

checkAst :: [Ast] -> Either String [Ast] Source #

Main entry point: validates AND transforms a list of AST nodes.

This function iterates over the top-level AST nodes, threading the environment state. It returns a new AST where auto types have been resolved to concrete types.

param asts: The list of raw AST nodes from the parser. return: Either an error message or the transformed AST list.

checkExpr :: CheckEnv -> Ast -> Either String Type Source #

Check Expression: Verifies an expression and returns its Semantic Type.

Does not modify the AST, only extracts the type. Handles literals (Int, Bool), variables (Symbol), and complex structures.

checkStmt :: CheckEnv -> Ast -> Either String (Ast, CheckEnv) Source #

Check Statement: Verifies AND transforms a statement.

Dispatcher function that routes AST nodes to specific handlers. Returns a tuple containing the transformed AST node (with inferred types) and the updated environment.

param env: Current Semantic Environment. param node: AST node to process.