diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-01-27 16:01:53 +0100 |
---|---|---|
committer | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-01-27 16:01:53 +0100 |
commit | eb6ecdcc85ece4eb84b90f3c9bb920dc1ad2b6d1 (patch) | |
tree | caaaaa969471552a13f5315a3de6e9db15b02a8b /src/core/parser/Parser.hpp | |
parent | 07d326d02415467ba7f5f238a8e72a9e4b7f1549 (diff) |
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.
Diffstat (limited to 'src/core/parser/Parser.hpp')
-rw-r--r-- | src/core/parser/Parser.hpp | 27 |
1 files changed, 11 insertions, 16 deletions
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 <set> #include <string> -#include <core/managed/Managed.hpp> -#include <core/model/Node.hpp> - 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<Node> 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<Node> 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<Node> parse(const std::string &str, ParserContext &ctx); + void parse(const std::string &str, ParserContext &ctx); }; } |