Поправљен баг због којег се макрои нису извршавали, такође "ламбда" је сада "људи"
This commit is contained in:
parent
a765bf886f
commit
a876c02003
|
@ -84,7 +84,7 @@ void init()
|
||||||
addSymbolInternal("карактер", &charInt, 0);
|
addSymbolInternal("карактер", &charInt, 0);
|
||||||
addSymbolInternal("карактер?", &charQInt, 0);
|
addSymbolInternal("карактер?", &charQInt, 0);
|
||||||
addSymbolInternal("конс?", &consQInt, 0);
|
addSymbolInternal("конс?", &consQInt, 0);
|
||||||
addSymbolInternal("ламбда", &lambdaInt, 1);
|
addSymbolInternal("људи", &lambdaInt, 1);
|
||||||
addSymbolInternal("прикажи", &displayInt, 0);
|
addSymbolInternal("прикажи", &displayInt, 0);
|
||||||
addSymbolInternal("нил?", &nilQInt, 0);
|
addSymbolInternal("нил?", &nilQInt, 0);
|
||||||
addSymbolInternal("направи-ниску", &makeStrInt, 0);
|
addSymbolInternal("направи-ниску", &makeStrInt, 0);
|
||||||
|
|
18
eval.c
18
eval.c
|
@ -66,9 +66,10 @@ int bindArgs(object parameters, object args, env newEnv)
|
||||||
object Eval(object input, env currentEnv)
|
object Eval(object input, env currentEnv)
|
||||||
{
|
{
|
||||||
object result;
|
object result;
|
||||||
int tailExpression = 0;
|
int tailExpression = 0, macroEvalPending;
|
||||||
|
|
||||||
eval:
|
eval:
|
||||||
|
macroEvalPending = 0;
|
||||||
if (TYPE(input) == symbolObject)
|
if (TYPE(input) == symbolObject)
|
||||||
{
|
{
|
||||||
result = referVariable(SYM(input), currentEnv);
|
result = referVariable(SYM(input), currentEnv);
|
||||||
|
@ -126,13 +127,14 @@ eval:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
goto apply;
|
|
||||||
if (TYPE(CAR(input)) == procedureObject &&
|
if (TYPE(CAR(input)) == procedureObject &&
|
||||||
PROC_SPECIAL(CAR(input)) &&
|
PROC_SPECIAL(CAR(input)) &&
|
||||||
PROC_TYPE(CAR(input)) == compoundProc)
|
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));
|
procedure = copyObject(CAR(input));
|
||||||
parameters = copyObject(CDR(input));
|
parameters = copyObject(CDR(input));
|
||||||
deleteObject(input);
|
deleteObject(input);
|
||||||
if (tailExpression && PROC_TYPE(procedure) != builtinProc)
|
if (tailExpression && PROC_TYPE(procedure) != builtinProc && !macroEvalPending)
|
||||||
{
|
{
|
||||||
removeEnvironment(currentEnv);
|
removeEnvironment(currentEnv);
|
||||||
}
|
}
|
||||||
|
@ -231,7 +233,15 @@ apply:
|
||||||
deleteObject(parameters);
|
deleteObject(parameters);
|
||||||
--currentRecursionDepth;
|
--currentRecursionDepth;
|
||||||
input = currentExpr;
|
input = currentExpr;
|
||||||
|
if (macroEvalPending)
|
||||||
|
{
|
||||||
|
input = Eval(input, procEnv);
|
||||||
|
removeEnvironment(procEnv);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
currentEnv = procEnv;
|
currentEnv = procEnv;
|
||||||
tailExpression = 1;
|
tailExpression = 1;
|
||||||
|
}
|
||||||
goto eval;
|
goto eval;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue