Skip to content

Commit

Permalink
Update selfhost.lm
Browse files Browse the repository at this point in the history
  • Loading branch information
KajizukaTaichi committed Jan 12, 2025
1 parent 77c5354 commit 349bae7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions example/langs/selfhost.lm
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ let evalExpr = fn(e, x ->
[scope, scope[ast.value]]
},
#Apply => {
let [[scope, a], [scope, b]] = map (evalExpr scope) ast.value;
let [funcScope, expr] = [scope, betaReduct a.value[0] b a.value[1]];
evalExpr funcScope expr
let [[scope, func], [scope, value]] = map (evalExpr scope) ast.value;
let [[arg, body], funcScope] = [func.value, scope];
let body = betaReduct(arg, value, body);
evalExpr funcScope body
},
#Add => {
let [[scope, a], [scope, b]] = map (evalExpr scope) ast.value;
Expand Down Expand Up @@ -79,6 +80,10 @@ let parseExpr = fn(source ->
let token = token - "λ" / ".";
let [args, body] = [token[0], join token[1 ~ len(token)] "."];
@{ "class": #Lambda, "value": [args, (parseExpr body)] }
} else if (token[0] == "\\" & token["."]) {
let token = token - "\\" / ".";
let [args, body] = [token[0], join token[1 ~ len(token)] "."];
@{ "class": #Lambda, "value": [args, (parseExpr body)] }
} else {
@{ "class": #Symbol, "value": token }
}
Expand Down

0 comments on commit 349bae7

Please sign in to comment.