diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2016-08-31 18:50:16 +0000 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2016-08-31 18:50:16 +0000 |
| commit | c59f10a0b0f58840c02327fc602a681c5410b212 (patch) | |
| tree | d378e2560ae8a81de5e1a9451241941902988e5e | |
| parent | 4d076ce2d3023ea8174d88f390ebc63cf2645d49 (diff) | |
Add string support
| -rw-r--r-- | parser.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
@@ -5,8 +5,27 @@ Parser::Parser(std::string& input) { std::vector<std::string> 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; + } } } |
