From 075669842b491a4646161c0af330f767489e6ca6 Mon Sep 17 00:00:00 2001 From: kappa Date: Wed, 6 Feb 2019 16:44:39 +0100 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=BC=D0=BF=D0=BB=D0=B5=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D1=82=D0=B8=D1=80=D0=B0=D0=BD=D0=BE=20=D0=BD=D0=BE=D1=82?= =?UTF-8?q?=D0=B8=D1=80=D0=B0=D1=9A=D0=B5=20"=D1=82=D0=B0=D1=87=D0=BA?= =?UTF-8?q?=D0=B0=D1=81=D1=82=D0=B5=20=D0=BB=D0=B8=D1=81=D1=82=D0=B5"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- print.c | 1 + read.c | 38 ++++++++++++++++++++++++++++++++++++++ util.h | 1 + 3 files changed, 40 insertions(+) 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,