aboutsummaryrefslogtreecommitdiffstats
path: root/parser.cpp
diff options
context:
space:
mode:
authorjantuomi <jans.tuomi@gmail.com>2016-09-01 11:20:59 +0300
committerjantuomi <jans.tuomi@gmail.com>2016-09-01 11:20:59 +0300
commit50bafbdd68160d00606a4e83d9759c21223c11f8 (patch)
tree66c58cfb012dc0b7d222a03e8c55507b75e9af1f /parser.cpp
parentbe011366f249b8ebed3905030ce3b7021597ee34 (diff)
Restructure project
Diffstat (limited to 'parser.cpp')
-rw-r--r--parser.cpp88
1 files changed, 0 insertions, 88 deletions
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 <iostream>
-#include <string>
-#include <vector>
-#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<int> Parser::parseValues(const std::string& input) {
- std::vector<int> 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<int>(c) );
- }
- }
-
- tmp = "";
- }
- }
- return res;
-}
-
-std::vector<Token> Parser::parseCode(const std::string& input) {
- std::vector<Token> 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<Token>& tokens) {
- for (auto& token : tokens) {
- std::cout << "Token[" << token.getLexeme() << "] ";
- }
- std::cout << std::endl;
-}
-
-void Parser::printValues(const std::vector<int>& values) {
- for (auto& value : values) {
- std::cout << "Value[" << value << "] ";
- }
- std::cout << std::endl;
-}