diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/css/CSSParser.cpp | 8 | ||||
-rw-r--r-- | src/plugins/css/CSSParser.hpp | 20 | ||||
-rw-r--r-- | src/plugins/xml/XmlParser.cpp | 12 | ||||
-rw-r--r-- | src/plugins/xml/XmlParser.hpp | 18 |
4 files changed, 10 insertions, 48 deletions
diff --git a/src/plugins/css/CSSParser.cpp b/src/plugins/css/CSSParser.cpp index 40486cc..8cb41ea 100644 --- a/src/plugins/css/CSSParser.cpp +++ b/src/plugins/css/CSSParser.cpp @@ -19,10 +19,9 @@ #include "CSSParser.hpp" #include <core/common/VariantReader.hpp> +#include <core/parser/ParserContext.hpp> namespace ousia { -namespace parser { -namespace css { // CSS code tokens static const int CURLY_OPEN = 1; @@ -75,7 +74,7 @@ static const std::map<int, CodeTokenDescriptor> CSS_DESCRIPTORS = { {ESCAPE, {CodeTokenMode::ESCAPE, ESCAPE}}, {LINEBREAK, {CodeTokenMode::LINEBREAK, LINEBREAK}}}; -Rooted<Node> CSSParser::parse(CharReader &reader, ParserContext &ctx) +Rooted<Node> CSSParser::doParse(CharReader &reader, ParserContext &ctx) { CodeTokenizer tokenizer{reader, CSS_ROOT, CSS_DESCRIPTORS}; tokenizer.ignoreComments = true; @@ -362,5 +361,4 @@ bool CSSParser::expect(int expectedType, CodeTokenizer &tokenizer, Token &t, return true; } } -} -} + diff --git a/src/plugins/css/CSSParser.hpp b/src/plugins/css/CSSParser.hpp index 1ec54f5..c6594f6 100644 --- a/src/plugins/css/CSSParser.hpp +++ b/src/plugins/css/CSSParser.hpp @@ -24,6 +24,7 @@ * * @author Benjamin Paassen - bpaassen@techfak.uni-bielefeld.de */ + #ifndef _OUSIA_CSS_PARSER_HPP_ #define _OUSIA_CSS_PARSER_HPP_ @@ -36,8 +37,6 @@ #include <core/parser/Parser.hpp> namespace ousia { -namespace parser { -namespace css { /** * This is a context free, recursive parser for a subset of the CSS3 language @@ -139,7 +138,7 @@ private: bool expect(int expectedType, CodeTokenizer &tokenizer, Token &t, bool force, ParserContext &ctx); -public: +protected: /** * This parses the given input as CSS content as specified by the grammar * seen above. The return value is a Rooted reference to the root of the @@ -157,21 +156,8 @@ public: * @return returns the root node of the resulting SelectorTree. For more * information on the return conventions consult the Parser.hpp. */ - Rooted<Node> parse(CharReader &reader, ParserContext &ctx) override; - - using Parser::parse; - - /** - * As befits a class called CSSParser, this Parser parses CSS. - */ - std::set<std::string> mimetypes() - { - std::set<std::string> out{"text/css"}; - return out; - } + Rooted<Node> doParse(CharReader &reader, ParserContext &ctx) override; }; } -} -} #endif diff --git a/src/plugins/xml/XmlParser.cpp b/src/plugins/xml/XmlParser.cpp index 434a72c..ef738d8 100644 --- a/src/plugins/xml/XmlParser.cpp +++ b/src/plugins/xml/XmlParser.cpp @@ -25,13 +25,12 @@ #include <core/common/Utils.hpp> #include <core/common/VariantReader.hpp> #include <core/parser/ParserStack.hpp> +#include <core/parser/ParserScope.hpp> #include <core/model/Typesystem.hpp> #include "XmlParser.hpp" namespace ousia { -namespace parser { -namespace xml { using namespace ousia::model; @@ -291,12 +290,7 @@ static void xmlCharacterDataHandler(void *p, const XML_Char *s, int len) /* Class XmlParser */ -std::set<std::string> XmlParser::mimetypes() -{ - return std::set<std::string>{{"text/vnd.ousia.oxm", "text/vnd.ousia.oxd"}}; -} - -Rooted<Node> XmlParser::parse(CharReader &reader, ParserContext &ctx) +Rooted<Node> XmlParser::doParse(CharReader &reader, ParserContext &ctx) { // Create the parser object ScopedExpatXmlParser p{"UTF-8"}; @@ -346,6 +340,4 @@ Rooted<Node> XmlParser::parse(CharReader &reader, ParserContext &ctx) return nullptr; } } -} -} diff --git a/src/plugins/xml/XmlParser.hpp b/src/plugins/xml/XmlParser.hpp index 62f0128..3c0ffb7 100644 --- a/src/plugins/xml/XmlParser.hpp +++ b/src/plugins/xml/XmlParser.hpp @@ -31,23 +31,13 @@ #include <core/parser/Parser.hpp> namespace ousia { -namespace parser { -namespace xml { /** * The XmlParser class implements parsing the various types of Ousía XML * documents using the expat stream XML parser. */ class XmlParser : public Parser { -public: - /** - * Returns the mimetype supported by the XmlParser which is - * "text/vnd.ousia.oxm" and "text/vnd.ousia.oxd". - * - * @return a list containing the mimetype supported by Ousía. - */ - std::set<std::string> mimetypes() override; - +protected: /** * Parses the given input stream as XML file and returns the parsed * top-level node. @@ -56,14 +46,10 @@ public: * @param ctx is a reference to the ParserContext instance that should be * used. */ - Rooted<Node> parse(CharReader &reader, ParserContext &ctx) override; - - using Parser::parse; + Rooted<Node> doParse(CharReader &reader, ParserContext &ctx) override; }; } -} -} #endif /* _OUSIA_XML_PARSER_HPP_ */ |