Created
December 24, 2014 16:52
-
-
Save LukaHorvat/dfc33a97b4f9578f7e09 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
connectStatement :: String -> State -> Statement -> State | |
connectStatement name state stmt = case stmt of | |
AST.Line expr -> connectExpression name expr state | |
AST.If cond th el -> let s = connectStatement name (connectExpression name state cond) th in case el of | |
Just ex -> connectExpression name s ex | |
Nothing -> s | |
AST.While cond s -> connectStatement name (connectEpxression name state cond) s | |
AST.Routine ss -> foldl (connectStatement name) state ss | |
_ -> | |
let (this, expr) = case stmt of | |
AST.Assignment s e -> (Variable name s, e) | |
AST.Return e -> (Return name, e) | |
in case expr of | |
AST.Number _ -> addType this Number state | |
AST.String _ -> addType this String state | |
AST.Boolean _ -> addType this Boolean state | |
AST.Variable v -> addConnection this (Variable name v) state | |
AST.Application f es -> addConnection this (Return f) $ foldl (connectExpression name) state es |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment