computerscare-vcv-modules

computerscare modules for VCV Rack
Log | Files | Refs

commit 6dca453cb1e8283fd0fcec552a2a00f4ed0b0be9
parent 775bd5968ac9c7b11f7a4a8bb3d4ef980a30c4fe
Author: Adam Malone <1319733+freddyz@users.noreply.github.com>
Date:   Thu, 15 Nov 2018 12:08:32 -0600

nesting parens for interleaveExpansion

Diffstat:
Asrc/.dtpulse.cpp.swp | 0
Asrc/.test.cpp.swp | 0
Msrc/dtpulse.cpp | 31++++++++++++++-----------------
Msrc/test.cpp | 8+++++---
4 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/src/.dtpulse.cpp.swp b/src/.dtpulse.cpp.swp Binary files differ. diff --git a/src/.test.cpp.swp b/src/.test.cpp.swp Binary files differ. diff --git a/src/dtpulse.cpp b/src/dtpulse.cpp @@ -4,7 +4,7 @@ std::string b64lookup = "123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRST std::string integerlookup = "0123456789"; std::string knoblookup = "abcdefghijklmnopqrstuvwxyz"; std::string inputlookup= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - +std::string knobandinputlookup=knoblookup+inputlookup; bool is_digits(const std::string &str) { @@ -134,34 +134,31 @@ std::vector<int> parseDt(std::string input, int offset, std::string lookup) { return absoluteSequence; } std::string splitRecur(std::string input) { - std::vector<std::string> outputVec; - std::string tempStack; + std::vector<std::string> tempVec; + std::vector<std::vector<std::string>> stackVec; + std::string tempString; std::string output; std::string c; - bool inside = false; + stackVec.push_back({}); for(unsigned int i = 0; i < input.length(); i++) { c = input[i]; if(c == "(") { - tempStack = ""; - inside = true; + stackVec.push_back({}); } else if(c == ")") { - outputVec.push_back(tempStack); - tempStack = ""; - inside = false; + //evaluate top of stack + tempString = interleaveExpand(stackVec.back()); + //pop top of stack + stackVec.pop_back(); + //push this evaluated string to new top + stackVec.back().push_back(tempString); } else { - // any other character - if(inside) { - tempStack += c; - } - else { - outputVec.push_back(c.c_str()); - } + stackVec.back().push_back(c); } } - output = interleaveExpand(outputVec); + output = interleaveExpand(stackVec[0]); return output; } diff --git a/src/test.cpp b/src/test.cpp @@ -5,6 +5,7 @@ int main(int argc, char** argv) std::vector<int> output; std::string strResult = ""; std::string strParens = ""; + std::vector <std::string> input; if(argv[2]) { type = std::stoi(argv[2]); } @@ -15,13 +16,14 @@ int main(int argc, char** argv) output = parseEntireString(argv[1],knoblookup,1); } else if(type==2) { - std::vector <std::string> input; + strParens = splitRecur(argv[1]); + printf(" splitRecur: %s\n",strParens.c_str()); + } + else if(type==3) { for(int i = 0; i < argc-3; i++) { input.push_back(argv[i+3]); } strResult = interleaveExpand(input); - strParens = splitRecur(argv[1]); - printf(" splitRecur: %s\ninterleaveExpand: %s\n",strParens.c_str(),strResult.c_str()); } printVector(output); return 0;