Created
April 25, 2025 09:08
-
-
Save MarioAriasC/1dbefc5171ac56784fe1c7e9adcb5c0f 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
let rec eval = (program: AST.program, env: environment) => { | |
let result: ref<option<mObject>> = ref(None) | |
let keep = ref(true) | |
program.statements->Array.forEach(statement => { | |
if keep.contents { | |
result := evaluateStatement(Some(statement), env) | |
result.contents->Option.forEach(contents => { | |
switch contents { | |
| MReturnValue({value}) => { | |
result := Some(value) | |
keep := false | |
} | |
| MError(_) => keep := false | |
| _ => () | |
} | |
}) | |
} | |
}) | |
result.contents | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment