mondo: proper lambda functions with local scope

This commit is contained in:
Felix Roos 2025-03-19 18:16:37 +01:00
parent 642ddcdb59
commit e04f250adb
No known key found for this signature in database
2 changed files with 29 additions and 19 deletions

View file

@ -4,8 +4,12 @@ import { MondoRunner } from '../mondo/mondo.mjs';
let runner = new MondoRunner(strudelScope);
strudelScope.leaf = (token) => {
strudelScope.leaf = (token, scope) => {
let { value } = token;
// local scope
if (token.type === 'plain' && scope[value]) {
return reify(scope[value]); // -> local scope has no location
}
const [from, to] = token.loc;
if (token.type === 'plain' && strudelScope[value]) {
// what if we want a string that happens to also be a variable name?