From 50bafbdd68160d00606a4e83d9759c21223c11f8 Mon Sep 17 00:00:00 2001 From: jantuomi Date: Thu, 1 Sep 2016 11:20:59 +0300 Subject: Restructure project --- parser.cpp | 88 -------------------------------------------------------------- 1 file changed, 88 deletions(-) delete mode 100644 parser.cpp (limited to 'parser.cpp') diff --git a/parser.cpp b/parser.cpp deleted file mode 100644 index 2472f6d..0000000 --- a/parser.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include "parser.h" -#include -#include -#include -#include "token.h" - -Parser::Parser() { } - -bool isNumber(const std::string& str) { - for (const char& c : str) { - if (!std::isdigit(c)) { - return false; - } - } - return true; -} - -std::vector Parser::parseValues(const std::string& input) { - std::vector res; - std::string tmp; - for (const char& c : input) { - if (!std::isspace(c)) { - tmp += c; - } - else { - if (isNumber(tmp)) { - res.push_back(std::stoi(tmp)); - } else { - for (const char& c : tmp) { - res.push_back( static_cast(c) ); - } - } - - tmp = ""; - } - } - return res; -} - -std::vector Parser::parseCode(const std::string& input) { - std::vector result; - - bool isString = false; - std::string tmp; - for (auto& c : input) { - if (std::isspace(c)) { - continue; - } - - if (c == '"' && !isString) { - isString = true; - continue; - } - - if (c == '"' && isString) { - Token token(tmp, true); - result.push_back(token); - tmp = ""; - isString = false; - continue; - } - - if (!isString) { - std::string parsed(1, c); - Token token(parsed, false); - result.push_back(token); - } - else { - tmp += c; - } - } - - return result; -} - -void Parser::printTokens(const std::vector& tokens) { - for (auto& token : tokens) { - std::cout << "Token[" << token.getLexeme() << "] "; - } - std::cout << std::endl; -} - -void Parser::printValues(const std::vector& values) { - for (auto& value : values) { - std::cout << "Value[" << value << "] "; - } - std::cout << std::endl; -} -- cgit v1.3