diff --git a/print.c b/print.c index 90391c7..ef85ad9 100644 --- a/print.c +++ b/print.c @@ -5,6 +5,7 @@ char *errors[] = { "Конс објекат мора бити правилна листа да би могао бити евалуиран", + "Неправилан конс \".\" оператер", "Неправилан тип аргумента прослеђен функцији", "Непознати симбол", "Објекат није примењив", diff --git a/read.c b/read.c index 4a9a0c3..b2fbb84 100644 --- a/read.c +++ b/read.c @@ -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')': diff --git a/util.h b/util.h index 65db8d6..a62d510 100644 --- a/util.h +++ b/util.h @@ -51,6 +51,7 @@ typedef enum typedef enum { improperListError, + improperDotNotation, typeError, unrecognizedSymbolError, notApplicableError,