summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/utils/CharReader.hpp6
-rw-r--r--src/core/variant/Reader.cpp32
-rw-r--r--src/core/variant/Reader.hpp32
-rw-r--r--src/plugins/css/CSSParser.cpp13
4 files changed, 45 insertions, 38 deletions
diff --git a/src/core/utils/CharReader.hpp b/src/core/utils/CharReader.hpp
index 5daa21d..86f09db 100644
--- a/src/core/utils/CharReader.hpp
+++ b/src/core/utils/CharReader.hpp
@@ -652,6 +652,12 @@ public:
void commit();
};
}
+
+/**
+ * Alias of the commonly used CharReader class.
+ */
+using CharReader = utils::CharReader;
+
}
#endif /* _OUSIA_CHAR_READER_HPP_ */
diff --git a/src/core/variant/Reader.cpp b/src/core/variant/Reader.cpp
index ba857af..3f1934e 100644
--- a/src/core/variant/Reader.cpp
+++ b/src/core/variant/Reader.cpp
@@ -32,7 +32,7 @@ namespace variant {
// TODO: Replace delims with single char delim where possible
// TODO: Use custom return value instead of std::pair
// TODO: Allow buffered char reader to "fork"
-// TODO: Rename BufferedCharReader to shorter CharReader
+// TODO: Rename CharReader to shorter CharReader
// TODO: Implement context in CharReader (to allow error messages to extract the
// current line)
@@ -97,7 +97,7 @@ private:
* Appends the value of the character c to the internal number
* representation and reports any errors that might occur.
*/
- bool appendChar(char c, int base, Part p, BufferedCharReader &reader,
+ bool appendChar(char c, int base, Part p, CharReader &reader,
Logger &logger)
{
// Check whether the given character is valid
@@ -176,7 +176,7 @@ public:
* the given logger instance. Numbers are terminated by one of the given
* delimiters.
*/
- bool parse(BufferedCharReader &reader, Logger &logger,
+ bool parse(CharReader &reader, Logger &logger,
const std::unordered_set<char> &delims)
{
State state = State::INIT;
@@ -186,7 +186,7 @@ public:
reader.consumeWhitespace();
// Iterate over the FSM to extract numbers
- while (reader.peek(&c)) {
+ while (reader.peek(c)) {
// Abort, once a delimiter or whitespace is reached
if (Utils::isWhitespace(c) || delims.count(c)) {
reader.resetPeek();
@@ -317,7 +317,7 @@ static const int STATE_WHITESPACE = 5;
static const int STATE_RESYNC = 6;
template <class T>
-static std::pair<bool, T> error(BufferedCharReader &reader, Logger &logger,
+static std::pair<bool, T> error(CharReader &reader, Logger &logger,
const char *err, T res)
{
logger.errorAt(err, reader);
@@ -325,7 +325,7 @@ static std::pair<bool, T> error(BufferedCharReader &reader, Logger &logger,
}
std::pair<bool, std::string> Reader::parseString(
- BufferedCharReader &reader, Logger &logger,
+ CharReader &reader, Logger &logger,
const std::unordered_set<char> *delims)
{
// Initialize the internal state
@@ -339,9 +339,9 @@ std::pair<bool, std::string> Reader::parseString(
// Statemachine whic iterates over each character in the stream
// TODO: Combination of peeking and consumePeek is stupid as consumePeek is
// the default (read and putBack would obviously be better, yet the latter
- // is not trivial to implement in the current BufferedCharReader).
+ // is not trivial to implement in the current CharReader).
char c;
- while (reader.peek(&c)) {
+ while (reader.peek(c)) {
switch (state) {
case STATE_INIT:
if (c == '"' || c == '\'') {
@@ -423,7 +423,7 @@ std::pair<bool, std::string> Reader::parseString(
}
std::pair<bool, Variant::arrayType> Reader::parseArray(
- BufferedCharReader &reader, Logger &logger, char delim)
+ CharReader &reader, Logger &logger, char delim)
{
Variant::arrayType res;
bool hadError = false;
@@ -436,7 +436,7 @@ std::pair<bool, Variant::arrayType> Reader::parseArray(
// Iterate over the characters, use the parseGeneric function to read the
// pairs
- while (reader.peek(&c)) {
+ while (reader.peek(c)) {
// Generically handle the end of the array
if (state != STATE_INIT && c == delim) {
reader.consumePeek();
@@ -491,7 +491,7 @@ std::pair<bool, Variant::arrayType> Reader::parseArray(
}
std::pair<bool, std::string> Reader::parseUnescapedString(
- BufferedCharReader &reader, Logger &logger,
+ CharReader &reader, Logger &logger,
const std::unordered_set<char> &delims)
{
std::stringstream res;
@@ -503,7 +503,7 @@ std::pair<bool, std::string> Reader::parseUnescapedString(
// Copy all characters, skip whitespace at the end
int state = STATE_IN_STRING;
- while (reader.peek(&c)) {
+ while (reader.peek(c)) {
if (delims.count(c)) {
reader.resetPeek();
return std::make_pair(true, res.str());
@@ -528,7 +528,7 @@ std::pair<bool, std::string> Reader::parseUnescapedString(
}
std::pair<bool, int64_t> Reader::parseInteger(
- BufferedCharReader &reader, Logger &logger,
+ CharReader &reader, Logger &logger,
const std::unordered_set<char> &delims)
{
Number n;
@@ -545,7 +545,7 @@ std::pair<bool, int64_t> Reader::parseInteger(
}
std::pair<bool, double> Reader::parseDouble(
- BufferedCharReader &reader, Logger &logger,
+ CharReader &reader, Logger &logger,
const std::unordered_set<char> &delims)
{
Number n;
@@ -554,14 +554,14 @@ std::pair<bool, double> Reader::parseDouble(
}
std::pair<bool, Variant> Reader::parseGeneric(
- BufferedCharReader &reader, Logger &logger,
+ CharReader &reader, Logger &logger,
const std::unordered_set<char> &delims)
{
char c;
// Skip all whitespace characters
reader.consumeWhitespace();
- while (reader.peek(&c)) {
+ while (reader.peek(c)) {
// Stop if a delimiter is reached
if (delims.count(c)) {
return error(reader, logger, ERR_UNEXPECTED_END, nullptr);
diff --git a/src/core/variant/Reader.hpp b/src/core/variant/Reader.hpp
index 710f7c4..4114d46 100644
--- a/src/core/variant/Reader.hpp
+++ b/src/core/variant/Reader.hpp
@@ -32,7 +32,7 @@
#include <unordered_set>
#include <utility>
-#include <core/BufferedCharReader.hpp>
+#include <core/utils/CharReader.hpp>
#include <core/Logger.hpp>
#include "Variant.hpp"
@@ -46,7 +46,7 @@ private:
* Parses a string which may either be enclosed by " or ', unescapes
* entities in the string as specified for JavaScript.
*
- * @param reader is a reference to the BufferedCharReader instance which is
+ * @param reader is a reference to the CharReader instance which is
* the source for the character data. The reader will be positioned after
* the terminating quote character or at the terminating delimiting
* character.
@@ -58,7 +58,7 @@ private:
* is read.
*/
static std::pair<bool, std::string> parseString(
- BufferedCharReader &reader, Logger &logger,
+ CharReader &reader, Logger &logger,
const std::unordered_set<char> *delims);
public:
@@ -66,7 +66,7 @@ public:
* Parses a string which may either be enclosed by " or ', unescapes
* entities in the string as specified for JavaScript.
*
- * @param reader is a reference to the BufferedCharReader instance which is
+ * @param reader is a reference to the CharReader instance which is
* the source for the character data. The reader will be positioned after
* the terminating quote character or at the terminating delimiting
* character.
@@ -77,7 +77,7 @@ public:
* outside).
*/
static std::pair<bool, std::string> parseString(
- BufferedCharReader &reader, Logger &logger,
+ CharReader &reader, Logger &logger,
const std::unordered_set<char> &delims)
{
return parseString(reader, logger, &delims);
@@ -87,14 +87,14 @@ public:
* Parses a string which may either be enclosed by " or ', unescapes
* entities in the string as specified for JavaScript.
*
- * @param reader is a reference to the BufferedCharReader instance which is
+ * @param reader is a reference to the CharReader instance which is
* the source for the character data. The reader will be positioned after
* the terminating quote character or at the terminating delimiting
* character.
* @param logger is the logger instance that should be used to log error
* messages and warnings.
*/
- static std::pair<bool, std::string> parseString(BufferedCharReader &reader,
+ static std::pair<bool, std::string> parseString(CharReader &reader,
Logger &logger)
{
return parseString(reader, logger, nullptr);
@@ -105,61 +105,61 @@ public:
* instance. This function just reads text until one of the given delimiter
* characters is reached.
*
- * @param reader is a reference to the BufferedCharReader instance which is
+ * @param reader is a reference to the CharReader instance which is
* the source for the character data. The reader will be positioned at the
* terminating delimiting character.
* @param delims is a set of characters which will terminate the string.
* These characters are not included in the result. May not be nullptr.
*/
static std::pair<bool, std::string> parseUnescapedString(
- BufferedCharReader &reader, Logger &logger,
+ CharReader &reader, Logger &logger,
const std::unordered_set<char> &delims);
/**
* Parses an integer from the given buffered char reader instance until one
* of the given delimiter characters is reached.
*
- * @param reader is a reference to the BufferedCharReader instance from
+ * @param reader is a reference to the CharReader instance from
* which the character data should been reader. The reader will be
* positioned at the terminating delimiting character or directly after the
* integer.
*/
static std::pair<bool, int64_t> parseInteger(
- BufferedCharReader &reader, Logger &logger,
+ CharReader &reader, Logger &logger,
const std::unordered_set<char> &delims);
/**
* Parses an double from the given buffered char reader instance until one
* of the given delimiter characters is reached.
*
- * @param reader is a reference to the BufferedCharReader instance from
+ * @param reader is a reference to the CharReader instance from
* which the character data should been reader. The reader will be
* positioned at the terminating delimiting character or directly after the
* integer.
*/
static std::pair<bool, double> parseDouble(
- BufferedCharReader &reader, Logger &logger,
+ CharReader &reader, Logger &logger,
const std::unordered_set<char> &delims);
/**
* Parses an array of values.
*/
static std::pair<bool, Variant::arrayType> parseArray(
- BufferedCharReader &reader, Logger &logger, char delim = 0);
+ CharReader &reader, Logger &logger, char delim = 0);
/**
* Tries to parse the most specific item from the given stream until one of
* the given delimiters is reached or a meaningful literal has been read.
* The resulting variant represents the value that has been read.
*
- * @param reader is a reference to the BufferedCharReader instance which is
+ * @param reader is a reference to the CharReader instance which is
* the source for the character data. The reader will be positioned at the
* terminating delimiting character.
* @param delims is a set of characters which will terminate the string.
* These characters are not included in the result. May not be nullptr.
*/
static std::pair<bool, Variant> parseGeneric(
- BufferedCharReader &reader, Logger &logger,
+ CharReader &reader, Logger &logger,
const std::unordered_set<char> &delims);
};
}
diff --git a/src/plugins/css/CSSParser.cpp b/src/plugins/css/CSSParser.cpp
index 4bbcc18..4cbe93f 100644
--- a/src/plugins/css/CSSParser.cpp
+++ b/src/plugins/css/CSSParser.cpp
@@ -227,14 +227,15 @@ Rooted<SelectorNode> CSSParser::parsePrimitiveSelector(CodeTokenizer &tokenizer,
// parse the argument list.
Variant::arrayType args;
// we require at least one argument, if parantheses are used
- args.push_back(variant::Reader::parseGeneric(tokenizer.getInput(),
+ // XXX
+ /*args.push_back(variant::Reader::parseGeneric(tokenizer.getInput(),
ctx.logger,
- {',', ')'}).second);
+ {',', ')'}).second);*/
while (expect(COMMA, tokenizer, t, false, ctx)) {
// as long as we find commas we expect new arguments.
- args.push_back(
+ /*args.push_back(
variant::Reader::parseGeneric(
- tokenizer.getInput(), ctx.logger, {',', ')'}).second);
+ tokenizer.getInput(), ctx.logger, {',', ')'}).second);*/
}
expect(PAREN_CLOSE, tokenizer, t, true, ctx);
// and we return with the finished Selector.
@@ -333,8 +334,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.
- value = variant::Reader::parseGeneric(tokenizer.getInput(), ctx.logger,
- {';'}).second;
+ /*value = variant::Reader::parseGeneric(tokenizer.getInput(), ctx.logger,
+ {';'}).second;*/
// and a ;
expect(SEMICOLON, tokenizer, t, true, ctx);
return true;