From a876c02003743a4e7b6c1a569aa4c9581bf77ac0 Mon Sep 17 00:00:00 2001 From: kappa Date: Thu, 19 Sep 2019 20:37:22 +0200 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D1=99?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=B1=D0=B0=D0=B3=20=D0=B7=D0=B1=D0=BE=D0=B3=20?= =?UTF-8?q?=D0=BA=D0=BE=D1=98=D0=B5=D0=B3=20=D1=81=D0=B5=20=D0=BC=D0=B0?= =?UTF-8?q?=D0=BA=D1=80=D0=BE=D0=B8=20=D0=BD=D0=B8=D1=81=D1=83=20=D0=B8?= =?UTF-8?q?=D0=B7=D0=B2=D1=80=D1=88=D0=B0=D0=B2=D0=B0=D0=BB=D0=B8,=20?= =?UTF-8?q?=D1=82=D0=B0=D0=BA=D0=BE=D1=92=D0=B5=20"=D0=BB=D0=B0=D0=BC?= =?UTF-8?q?=D0=B1=D0=B4=D0=B0"=20=D1=98=D0=B5=20=D1=81=D0=B0=D0=B4=D0=B0?= =?UTF-8?q?=20"=D1=99=D1=83=D0=B4=D0=B8"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cirilisp.c | 2 +- eval.c | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/cirilisp.c b/cirilisp.c index a9e0f0a..6d202ee 100644 --- a/cirilisp.c +++ b/cirilisp.c @@ -84,7 +84,7 @@ void init() addSymbolInternal("карактер", &charInt, 0); addSymbolInternal("карактер?", &charQInt, 0); addSymbolInternal("конс?", &consQInt, 0); - addSymbolInternal("ламбда", &lambdaInt, 1); + addSymbolInternal("људи", &lambdaInt, 1); addSymbolInternal("прикажи", &displayInt, 0); addSymbolInternal("нил?", &nilQInt, 0); addSymbolInternal("направи-ниску", &makeStrInt, 0); diff --git a/eval.c b/eval.c index 9e2ab9a..95e4b11 100644 --- a/eval.c +++ b/eval.c @@ -66,9 +66,10 @@ int bindArgs(object parameters, object args, env newEnv) object Eval(object input, env currentEnv) { object result; - int tailExpression = 0; + int tailExpression = 0, macroEvalPending; eval: + macroEvalPending = 0; if (TYPE(input) == symbolObject) { result = referVariable(SYM(input), currentEnv); @@ -126,13 +127,14 @@ eval: } else { - goto apply; if (TYPE(CAR(input)) == procedureObject && PROC_SPECIAL(CAR(input)) && PROC_TYPE(CAR(input)) == compoundProc) { - result = Eval(result, currentEnv); + macroEvalPending = 1; } + goto apply; + // big problem pendejo } } } @@ -153,7 +155,7 @@ apply: procedure = copyObject(CAR(input)); parameters = copyObject(CDR(input)); deleteObject(input); - if (tailExpression && PROC_TYPE(procedure) != builtinProc) + if (tailExpression && PROC_TYPE(procedure) != builtinProc && !macroEvalPending) { removeEnvironment(currentEnv); } @@ -231,7 +233,15 @@ apply: deleteObject(parameters); --currentRecursionDepth; input = currentExpr; - currentEnv = procEnv; - tailExpression = 1; + if (macroEvalPending) + { + input = Eval(input, procEnv); + removeEnvironment(procEnv); + } + else + { + currentEnv = procEnv; + tailExpression = 1; + } goto eval; }