diff options
Diffstat (limited to 'src/core/parser')
-rw-r--r-- | src/core/parser/ParserScope.cpp | 12 | ||||
-rw-r--r-- | src/core/parser/ParserScope.hpp | 9 | ||||
-rw-r--r-- | src/core/parser/stack/DocumentHandler.cpp | 14 | ||||
-rw-r--r-- | src/core/parser/stack/DomainHandler.cpp | 16 | ||||
-rw-r--r-- | src/core/parser/stack/TypesystemHandler.cpp | 6 |
5 files changed, 33 insertions, 24 deletions
diff --git a/src/core/parser/ParserScope.cpp b/src/core/parser/ParserScope.cpp index b0a4945..dabb03c 100644 --- a/src/core/parser/ParserScope.cpp +++ b/src/core/parser/ParserScope.cpp @@ -216,7 +216,7 @@ void ParserScope::push(Handle<Node> node) nodes.push_back(node); } -void ParserScope::pop() +void ParserScope::pop(Logger &logger) { // Make sure pop is not called without an element on the stack const size_t currentDepth = nodes.size(); @@ -235,10 +235,14 @@ void ParserScope::pop() flags.resize(newLen); // Whenever a RootNode is popped from the stack, we have to perform deferred - // resolution -- however, postpone issuing error messages - if (nodes.back()->isa(&RttiTypes::RootNode)) { - Logger logger; + // resolution and validate the subtree + Rooted<Node> node = nodes.back(); + if (node->isa(&RttiTypes::RootNode)) { + // Perform pending resolutions -- do not issue errors now performDeferredResolution(logger, true); + + // Perform validation of the subtree. + node->validate(logger); } // Remove the element from the stack diff --git a/src/core/parser/ParserScope.hpp b/src/core/parser/ParserScope.hpp index 24af6b8..fa78c17 100644 --- a/src/core/parser/ParserScope.hpp +++ b/src/core/parser/ParserScope.hpp @@ -423,9 +423,14 @@ public: void push(Handle<Node> node); /** - * Removes the last pushed node from the scope. + * Removes the last pushed node from the scope. If the node that is popped + * from the internal stack is a RootNode, pending resolutions are performed + * and the RootNode is validated. + * + * @param logger is the Logger instance to which error messages should be + * logged. */ - void pop(); + void pop(Logger &logger); /** * Returns the top-level nodes. These are the nodes that are pushed onto the diff --git a/src/core/parser/stack/DocumentHandler.cpp b/src/core/parser/stack/DocumentHandler.cpp index 35146b1..e959b9a 100644 --- a/src/core/parser/stack/DocumentHandler.cpp +++ b/src/core/parser/stack/DocumentHandler.cpp @@ -47,7 +47,7 @@ bool DocumentHandler::start(Variant::mapType &args) return true; } -void DocumentHandler::end() { scope().pop(); } +void DocumentHandler::end() { scope().pop(logger()); } /* DocumentChildHandler */ @@ -200,9 +200,9 @@ bool DocumentChildHandler::start(Variant::mapType &args) // if we have transparent elements above us in the structure // tree we try to unwind them before we give up. // pop the implicit field. - scope().pop(); + scope().pop(logger()); // pop the implicit element. - scope().pop(); + scope().pop(logger()); continue; } throw LoggableException( @@ -237,7 +237,7 @@ void DocumentChildHandler::end() return; } // pop the "main" element. - scope().pop(); + scope().pop(logger()); } bool DocumentChildHandler::fieldStart(bool &isDefault, size_t fieldIdx) @@ -279,15 +279,15 @@ void DocumentChildHandler::fieldEnd() assert(scope().getLeaf()->isa(&RttiTypes::DocumentField)); // pop the field from the stack. - scope().pop(); + scope().pop(logger()); // pop all remaining transparent elements. while (scope().getLeaf()->isa(&RttiTypes::StructuredEntity) && scope().getLeaf().cast<StructuredEntity>()->isTransparent()) { // pop the transparent element. - scope().pop(); + scope().pop(logger()); // pop the transparent field. - scope().pop(); + scope().pop(logger()); } } diff --git a/src/core/parser/stack/DomainHandler.cpp b/src/core/parser/stack/DomainHandler.cpp index ddec1ee..aa18faa 100644 --- a/src/core/parser/stack/DomainHandler.cpp +++ b/src/core/parser/stack/DomainHandler.cpp @@ -53,7 +53,7 @@ bool DomainHandler::start(Variant::mapType &args) return true; } -void DomainHandler::end() { scope().pop(); } +void DomainHandler::end() { scope().pop(logger()); } /* DomainStructHandler */ @@ -85,7 +85,7 @@ bool DomainStructHandler::start(Variant::mapType &args) return true; } -void DomainStructHandler::end() { scope().pop(); } +void DomainStructHandler::end() { scope().pop(logger()); } /* DomainAnnotationHandler */ bool DomainAnnotationHandler::start(Variant::mapType &args) @@ -102,7 +102,7 @@ bool DomainAnnotationHandler::start(Variant::mapType &args) return true; } -void DomainAnnotationHandler::end() { scope().pop(); } +void DomainAnnotationHandler::end() { scope().pop(logger()); } /* DomainAttributesHandler */ @@ -118,7 +118,7 @@ bool DomainAttributesHandler::start(Variant::mapType &args) return true; } -void DomainAttributesHandler::end() { scope().pop(); } +void DomainAttributesHandler::end() { scope().pop(logger()); } /* DomainFieldHandler */ @@ -148,7 +148,7 @@ bool DomainFieldHandler::start(Variant::mapType &args) return true; } -void DomainFieldHandler::end() { scope().pop(); } +void DomainFieldHandler::end() { scope().pop(logger()); } /* DomainFieldRefHandler */ @@ -218,7 +218,7 @@ bool DomainPrimitiveHandler::start(Variant::mapType &args) return true; } -void DomainPrimitiveHandler::end() { scope().pop(); } +void DomainPrimitiveHandler::end() { scope().pop(logger()); } /* DomainChildHandler */ @@ -251,7 +251,7 @@ bool DomainParentHandler::start(Variant::mapType &args) return true; } -void DomainParentHandler::end() { scope().pop(); } +void DomainParentHandler::end() { scope().pop(logger()); } /* DomainParentFieldHandler */ @@ -414,4 +414,4 @@ namespace RttiTypes { const Rtti DomainParent = RttiBuilder<ousia::parser_stack::DomainParent>( "DomainParent").parent(&Node); } -}
\ No newline at end of file +} diff --git a/src/core/parser/stack/TypesystemHandler.cpp b/src/core/parser/stack/TypesystemHandler.cpp index 8fd9525..727c601 100644 --- a/src/core/parser/stack/TypesystemHandler.cpp +++ b/src/core/parser/stack/TypesystemHandler.cpp @@ -51,7 +51,7 @@ bool TypesystemHandler::start(Variant::mapType &args) return true; } -void TypesystemHandler::end() { scope().pop(); } +void TypesystemHandler::end() { scope().pop(logger()); } /* TypesystemEnumHandler */ @@ -70,7 +70,7 @@ bool TypesystemEnumHandler::start(Variant::mapType &args) return true; } -void TypesystemEnumHandler::end() { scope().pop(); } +void TypesystemEnumHandler::end() { scope().pop(logger()); } /* TypesystemEnumEntryHandler */ @@ -112,7 +112,7 @@ bool TypesystemStructHandler::start(Variant::mapType &args) return true; } -void TypesystemStructHandler::end() { scope().pop(); } +void TypesystemStructHandler::end() { scope().pop(logger()); } /* TypesystemStructFieldHandler */ |