diff --git a/ccl/rslang/src/TypeAuditor.cpp b/ccl/rslang/src/TypeAuditor.cpp index e5e6b73..63b5f7c 100644 --- a/ccl/rslang/src/TypeAuditor.cpp +++ b/ccl/rslang/src/TypeAuditor.cpp @@ -7,8 +7,8 @@ namespace { // Helper functions [[nodiscard]] std::string ToString(const ExpressionType& type) noexcept(false); [[nodiscard]] constexpr bool IsSubset(TokenID token) noexcept; -[[nodiscard]] bool IsEchelon(SyntaxTree::Cursor iter); -[[nodiscard]] bool IsEchelon(SyntaxTree::Cursor iter, Index index); +[[nodiscard]] bool IsStructureDomain(SyntaxTree::Cursor iter); +[[nodiscard]] bool IsStructureDomain(SyntaxTree::Cursor iter, Index index); void MangleRadicals(const std::string& funcName, Typification& type); std::string ToString(const ExpressionType& type) noexcept(false) { @@ -26,7 +26,7 @@ constexpr bool IsSubset(const TokenID token) noexcept { || token == TokenID::NOTSUBSET; } -bool IsEchelon(SyntaxTree::Cursor iter) { +bool IsStructureDomain(SyntaxTree::Cursor iter) { switch (iter->id) { default: return false; @@ -34,19 +34,20 @@ bool IsEchelon(SyntaxTree::Cursor iter) { case TokenID::ID_GLOBAL: case TokenID::BOOLEAN: case TokenID::DECART: + case TokenID::NT_ENUMERATION: break; } for (Index i = 0; i < iter.ChildrenCount(); ++i) { - if (!IsEchelon(iter, i)) { + if (!IsStructureDomain(iter, i)) { return false; } } return true; } -bool IsEchelon(SyntaxTree::Cursor iter, const Index index) { +bool IsStructureDomain(SyntaxTree::Cursor iter, const Index index) { iter.MoveToChild(index); - return IsEchelon(iter); + return IsStructureDomain(iter); } bool IsRadical(const std::string& alias) { @@ -304,7 +305,7 @@ void TypeAuditor::Clear() noexcept { bool TypeAuditor::ViGlobalDeclaration(Cursor iter) { const auto childrenCount = iter.ChildrenCount(); if (iter->id == TokenID::PUNC_STRUCT) { - if (childrenCount != 2 || !IsEchelon(iter, 1)) { + if (childrenCount != 2 || !IsStructureDomain(iter, 1)) { OnError(SemanticEID::globalStructure, iter(0).pos.finish); return false; } diff --git a/ccl/rslang/test/src/testTypeAuditor.cpp b/ccl/rslang/test/src/testTypeAuditor.cpp index 8eb26fa..b3d4c4b 100644 --- a/ccl/rslang/test/src/testTypeAuditor.cpp +++ b/ccl/rslang/test/src/testTypeAuditor.cpp @@ -103,6 +103,7 @@ TEST_F(UTTypeAuditor, DefinitionsCorrect) { ExpectTypification(R"(S1 \deftype X1)", "X1"_t); ExpectTypification(R"(S1 \deftype Z)", "Z"_t); + ExpectTypification(R"(S1 \deftype {X1, X1})", "B(X1)"_t); ExpectTypification(R"(S1 \deftype X1*X1)", "X1*X1"_t); ExpectTypification(R"(F42 \defexpr [a \in X1] {a})", "B(X1)"_t); @@ -126,6 +127,7 @@ TEST_F(UTTypeAuditor, DefinitionsCorrect) { TEST_F(UTTypeAuditor, DefinitionsErrors) { ExpectError(R"(S1 \deftype R1)", SemanticEID::globalStructure); + ExpectError(R"(S1 \deftype {})", SemanticEID::globalStructure); ExpectError(R"(S1 \deftype 1)", SemanticEID::globalStructure); ExpectError(R"(S1 \deftype 1 \eq 1)", SemanticEID::globalStructure); ExpectError(R"(S1 \deftype [a \in X1] a \eq a)", SemanticEID::globalStructure); diff --git a/pyconcept/CHANGELOG.md b/pyconcept/CHANGELOG.md index cb59c82..2c0b721 100644 --- a/pyconcept/CHANGELOG.md +++ b/pyconcept/CHANGELOG.md @@ -19,6 +19,12 @@ Here we write upgrading notes. Make them as straightforward as possible. ### Fixed +## [0.1.11] - 2024-10-17 + +- Allow enumeration in structure definition + +### Changed + ## [0.1.10] - 2024-09-25 ### Fixed diff --git a/pyconcept/VERSION b/pyconcept/VERSION index 345f8cc..a34eaa5 100644 --- a/pyconcept/VERSION +++ b/pyconcept/VERSION @@ -1 +1 @@ -0.1.10 \ No newline at end of file +0.1.11 \ No newline at end of file