Имплементирано нотирање "тачкасте листе"

This commit is contained in:
kappa 2019-02-06 16:44:39 +01:00
parent 687a1a8835
commit 075669842b
3 changed files with 40 additions and 0 deletions

View file

@ -5,6 +5,7 @@
char *errors[] =
{
"Конс објекат мора бити правилна листа да би могао бити евалуиран",
"Неправилан конс \".\" оператер",
"Неправилан тип аргумента прослеђен функцији",
"Непознати симбол",
"Објекат није примењив",

38
read.c
View file

@ -413,6 +413,44 @@ object macroFunction(wchar_t m)
SIGERR(ERR(error));
}
int properDotComb = 1, dotPlace = -1, length;
object *dot;
for (length = 0, listCurrent = &result; TYPE(*listCurrent) !=
nilObject; ++length, listCurrent = &CDR(*listCurrent))
{
if (TYPE(CAR(*listCurrent)) == symbolObject &&
!strcmp(SYM(CAR(*listCurrent)), "."))
{
if (dotPlace == -1)
{
dotPlace = length;
dot = listCurrent;
}
else
{
properDotComb = 0;
break;
}
}
}
if (dotPlace != -1)
{
if (dotPlace != length - 2 || dotPlace == 0)
{
properDotComb = 0;
}
}
if (!properDotComb)
{
SIGERR(improperDotNotation);
}
if (dotPlace != -1 && properDotComb)
{
object tmp = copyObject(CAR(CDR(*dot)));
deleteObject(*dot);
*dot = tmp;
}
return result;
break;
case L')':

1
util.h
View file

@ -51,6 +51,7 @@ typedef enum
typedef enum
{
improperListError,
improperDotNotation,
typeError,
unrecognizedSymbolError,
notApplicableError,