diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2016-08-31 19:15:13 +0000 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2016-08-31 19:15:13 +0000 |
| commit | b7eeb6676b8f67be7cc1560d9586f2672a5ad0eb (patch) | |
| tree | 651f5c1dd84041b076b20ca2f4370ba6999b3d5f /parser.cpp | |
| parent | 251a9af5e8c4976373b71935457d1ce17c6888a1 (diff) | |
Print parsed tokens
Diffstat (limited to 'parser.cpp')
| -rw-r--r-- | parser.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -1,4 +1,5 @@ #include "parser.h" +#include <iostream> #include <string> #include <vector> #include "token.h" @@ -9,6 +10,10 @@ Parser::Parser(std::string& input) { bool isString = false; std::string tmp; for (auto& c : input) { + if (std::isspace(c)) { + continue; + } + if (c == '"' && !isString) { isString = true; continue; @@ -31,4 +36,17 @@ Parser::Parser(std::string& input) { tmp += c; } } + + m_tokens = result; +} + +std::vector<Token>& Parser::getTokens() { + return m_tokens; +} + +void Parser::printTokens() { + for (auto& token : getTokens()) { + std::cout << "Token[" << token.getLexeme() << "] "; + } + std::cout << std::endl; } |
