From 5d500ea305db7185314cc2b500257529e9e9696a Mon Sep 17 00:00:00 2001 From: Benjamin Paassen Date: Fri, 5 Dec 2014 17:09:34 +0100 Subject: Successfully (hopefully) implemented CSS Parsing and the respective test. --- src/core/CSS.cpp | 6 ++++++ src/core/CSS.hpp | 9 +++++---- src/core/Tokenizer.hpp | 2 ++ src/plugins/css/CSSParser.cpp | 6 ++++-- 4 files changed, 17 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/core/CSS.cpp b/src/core/CSS.cpp index c3900e8..d131fec 100644 --- a/src/core/CSS.cpp +++ b/src/core/CSS.cpp @@ -20,6 +20,12 @@ namespace ousia { +void RuleSet::merge(Rooted other){ + for(auto& o : other->rules){ + rules[o.first] = o.second; + } +} + /* * different versions of "getChildren". */ diff --git a/src/core/CSS.hpp b/src/core/CSS.hpp index 4cf15be..aa701b5 100644 --- a/src/core/CSS.hpp +++ b/src/core/CSS.hpp @@ -85,10 +85,11 @@ public: return rules; } - void merge(Rooted other) - { - rules.insert(other->rules.begin(), other->rules.end()); - } + /** + * This implements an overriding "insert all" of all rules in the other + * RuleSet to the rules in this RuleSet. + */ + void merge(Rooted other); }; /** diff --git a/src/core/Tokenizer.hpp b/src/core/Tokenizer.hpp index 4aebf56..8f80150 100644 --- a/src/core/Tokenizer.hpp +++ b/src/core/Tokenizer.hpp @@ -225,6 +225,8 @@ public: void consumePeek(); const BufferedCharReader &getInput() const { return input; } + + BufferedCharReader &getInput() { return input; } }; } diff --git a/src/plugins/css/CSSParser.cpp b/src/plugins/css/CSSParser.cpp index 82ed7e1..fc37184 100644 --- a/src/plugins/css/CSSParser.cpp +++ b/src/plugins/css/CSSParser.cpp @@ -18,6 +18,8 @@ #include "CSSParser.hpp" +#include + namespace ousia { namespace parser { namespace css { @@ -330,8 +332,8 @@ bool CSSParser::parseRule(CodeTokenizer &tokenizer, ParserContext &ctx, expect(COLON, tokenizer, t, true, ctx); // then the value // TODO: Resolve key for appropriate parsing function here. - expect(STRING, tokenizer, t, true, ctx); - value = variant::Variant(t.content.c_str()); + value = variant::Reader::parseGeneric(tokenizer.getInput(), ctx.logger, + {';'}).second; // and a ; expect(SEMICOLON, tokenizer, t, true, ctx); return true; -- cgit v1.2.3