diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/css/CSSParser.cpp | 11 | ||||
-rw-r--r-- | src/plugins/css/CSSParser.hpp | 3 | ||||
-rw-r--r-- | src/plugins/xml/XmlParser.cpp | 3 | ||||
-rw-r--r-- | src/plugins/xml/XmlParser.hpp | 2 |
4 files changed, 13 insertions, 6 deletions
diff --git a/src/plugins/css/CSSParser.cpp b/src/plugins/css/CSSParser.cpp index 40179bf..a09a69f 100644 --- a/src/plugins/css/CSSParser.cpp +++ b/src/plugins/css/CSSParser.cpp @@ -74,15 +74,22 @@ static const std::map<int, CodeTokenDescriptor> CSS_DESCRIPTORS = { {ESCAPE, {CodeTokenMode::ESCAPE, ESCAPE}}, {LINEBREAK, {CodeTokenMode::LINEBREAK, LINEBREAK}}}; -Rooted<Node> CSSParser::doParse(CharReader &reader, ParserContext &ctx) +void CSSParser::doParse(CharReader &reader, ParserContext &ctx) { CodeTokenizer tokenizer{reader, CSS_ROOT, CSS_DESCRIPTORS}; tokenizer.ignoreComments = true; tokenizer.ignoreLinebreaks = true; + + // Create the root node and push it onto the parser scope Rooted<model::SelectorNode> root = { new model::SelectorNode{ctx.getManager(), "root"}}; + ctx.getScope().push(root); + + // Parse the document into the root node parseDocument(root, tokenizer, ctx); - return root; + + // Remove the element from the parser scope + ctx.getScope().pop(); } void CSSParser::parseDocument(Rooted<model::SelectorNode> root, diff --git a/src/plugins/css/CSSParser.hpp b/src/plugins/css/CSSParser.hpp index 2f37e6a..b2a760f 100644 --- a/src/plugins/css/CSSParser.hpp +++ b/src/plugins/css/CSSParser.hpp @@ -35,6 +35,7 @@ #include <core/common/CharReader.hpp> #include <core/model/Style.hpp> #include <core/parser/Parser.hpp> +#include <core/parser/ParserScope.hpp> namespace ousia { @@ -158,7 +159,7 @@ protected: * @return returns the root node of the resulting SelectorTree. For more * information on the return conventions consult the Parser.hpp. */ - Rooted<Node> doParse(CharReader &reader, ParserContext &ctx) override; + void doParse(CharReader &reader, ParserContext &ctx) override; }; } diff --git a/src/plugins/xml/XmlParser.cpp b/src/plugins/xml/XmlParser.cpp index bb9d678..51c52bc 100644 --- a/src/plugins/xml/XmlParser.cpp +++ b/src/plugins/xml/XmlParser.cpp @@ -289,7 +289,7 @@ static void xmlCharacterDataHandler(void *p, const XML_Char *s, int len) /* Class XmlParser */ -Rooted<Node> XmlParser::doParse(CharReader &reader, ParserContext &ctx) +void XmlParser::doParse(CharReader &reader, ParserContext &ctx) { // Create the parser object ScopedExpatXmlParser p{"UTF-8"}; @@ -335,7 +335,6 @@ Rooted<Node> XmlParser::doParse(CharReader &reader, ParserContext &ctx) break; } } - return nullptr; } } diff --git a/src/plugins/xml/XmlParser.hpp b/src/plugins/xml/XmlParser.hpp index 3c0ffb7..c8b6302 100644 --- a/src/plugins/xml/XmlParser.hpp +++ b/src/plugins/xml/XmlParser.hpp @@ -46,7 +46,7 @@ protected: * @param ctx is a reference to the ParserContext instance that should be * used. */ - Rooted<Node> doParse(CharReader &reader, ParserContext &ctx) override; + void doParse(CharReader &reader, ParserContext &ctx) override; }; } |