Skip to content

Instantly share code, notes, and snippets.

@MarioAriasC
Created April 25, 2025 09:08
Show Gist options
  • Save MarioAriasC/1dbefc5171ac56784fe1c7e9adcb5c0f to your computer and use it in GitHub Desktop.
Save MarioAriasC/1dbefc5171ac56784fe1c7e9adcb5c0f to your computer and use it in GitHub Desktop.
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