From c59f10a0b0f58840c02327fc602a681c5410b212 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Wed, 31 Aug 2016 18:50:16 +0000 Subject: Add string support --- parser.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'parser.cpp') diff --git a/parser.cpp b/parser.cpp index 026e516..91e4067 100644 --- a/parser.cpp +++ b/parser.cpp @@ -5,8 +5,27 @@ Parser::Parser(std::string& input) { std::vector result; + bool isString = false; + std::string tmp; for (auto& c : input) { - std::string parsed(1, c); - result.push_back(parsed); + if (c == '"' && !isString) { + isString = true; + continue; + } + + if (c == '"' && isString) { + result.push_back(tmp); + tmp = ""; + isString = false; + continue; + } + + if (!isString) { + std::string parsed(1, c); + result.push_back(parsed); + } + else { + tmp += c; + } } } -- cgit v1.3