From eb6ecdcc85ece4eb84b90f3c9bb920dc1ad2b6d1 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Tue, 27 Jan 2015 16:01:53 +0100 Subject: Parsers do no longer return the node they have parsed (as this may be ill-defined -- if a parser only parses a partial document via include, there may be many to no nodes that are returned). Parsers should just use the ParserScope.push funciton. All nodes pushed onto the top-level of the ParserScope are added treated as the nodes the parser has parsed. Adapted all code and all tests accordingly. --- src/core/parser/Parser.hpp | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'src/core/parser/Parser.hpp') diff --git a/src/core/parser/Parser.hpp b/src/core/parser/Parser.hpp index e4419f5..54c5bfc 100644 --- a/src/core/parser/Parser.hpp +++ b/src/core/parser/Parser.hpp @@ -32,9 +32,6 @@ #include #include -#include -#include - namespace ousia { // Forward declarations @@ -61,7 +58,7 @@ protected: * calling code will try to resolve these. If no valid node can be produced, * a corresponding LoggableException must be thrown by the parser. */ - virtual Rooted doParse(CharReader &reader, ParserContext &ctx) = 0; + virtual void doParse(CharReader &reader, ParserContext &ctx) = 0; public: /** @@ -82,32 +79,30 @@ public: /** * Parses the given input stream and returns a corresponding node for * inclusion in the document graph. This method should be overridden by - * derived classes. + * derived classes. The created nodes should be placed onto the ParserScope + * using the "push" methods and removed using the "pop" methods. Nodes + * pushed to the top level of the ParserScope are considered as the subgraph + * the parser has created. * * @param reader is a reference to the CharReader that should be used. * @param ctx is a reference to the context that should be used while * parsing the document. - * @return a reference to the node representing the subgraph that has been - * created. The resulting node may point at not yet resolved entities, the - * calling code will try to resolve these. If no valid node can be produced, - * a corresponding ParserException must be thrown by the parser. */ - Rooted parse(CharReader &reader, ParserContext &ctx); + void parse(CharReader &reader, ParserContext &ctx); /** * Parses the given string and returns a corresponding node for * inclusion in the document graph. This method should be overridden by - * derived classes. + * derived classes. The created nodes should be placed onto the ParserScope + * using the "push" methods and removed using the "pop" methods. Nodes + * pushed to the top level of the ParserScope are considered as the subgraph + * the parser has created. * * @param str is the string that should be parsed. * @param ctx is a reference to the context that should be used while * parsing the document. - * @return a reference to the node representing the subgraph that has been - * created. The resulting node may point at not yet resolved entities, the - * calling code will try to resolve these. If no valid node can be produced, - * a corresponding ParserException must be thrown by the parser. */ - Rooted parse(const std::string &str, ParserContext &ctx); + void parse(const std::string &str, ParserContext &ctx); }; } -- cgit v1.2.3