mirror of
https://github.com/IRBorisov/ConceptCore.git
synced 2025-06-26 01:00:36 +03:00
F: Allow enumeration in structure definition
This commit is contained in:
parent
97d94a8158
commit
dc395e1ac8
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1 +1 @@
|
|||
0.1.10
|
||||
0.1.11
|
Loading…
Reference in New Issue
Block a user