computerscare-vcv-modules

computerscare modules for VCV Rack
Log | Files | Refs

commit 93174f56101402bb114fb54c41d411363a301378
parent 493e1d36540ef774dbc3da84aebd3807ae1dbe48
Author: Adam Malone <1319733+freddyz@users.noreply.github.com>
Date:   Thu, 27 Dec 2018 17:07:35 -0600

add exact integer parsing for LaundrySoup parsing

Diffstat:
Msrc/dtpulse.cpp | 32+++++++++++++++++++++++++++++++-
Msrc/dtpulse.hpp | 4++++
Msrc/test.cpp | 3+++
3 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/src/dtpulse.cpp b/src/dtpulse.cpp @@ -372,7 +372,11 @@ void whoKnows(std::string input) { printVector(abs.workingIndexSequence); } } - +void whoKnowsLaundry(std::string input) { + printf("ujje man\n"); + Parser p = Parser(input); + p.setForLaundry(); +} AbsoluteSequence::AbsoluteSequence() { AbsoluteSequence("a",knobandinputlookup); } @@ -382,6 +386,7 @@ AbsoluteSequence::AbsoluteSequence(std::string expr, std::string lookup) { //expr = expr=="" ? "a" : expr; if(expr != "") { Parser p = Parser(expr); + p.setForCookies(); exactFloats = p.exactFloats; randomTokens=p.randomVector; if(p.inError || !p.tokenStack.size()) { @@ -485,6 +490,20 @@ Parser::Parser(std::string expr) { tokens = tokenizeString(expr); expression=expr; inError = false; +} +void Parser::setForLaundry() { + if(tokens.size() > 0) { + currentIndex=0; + setForExactIntegers(tokens[0]); + + if(!inError) { + currentIndex=0; + tokens=tokenStack; + } + } + printTokenVector(tokens); +} +void Parser::setForCookies() { if(tokens.size() > 0) { currentIndex=0; setExactValue(tokens[0]); @@ -584,6 +603,15 @@ void Parser::setForSquareBrackets(Token t) { t = skipAndPeekToken(); } } +void Parser::setForExactIntegers(Token t) { + while(t.type!="NULL") { + ParseExactInteger(t); + if(peekToken().type !="NULL") { + tokenStack.push_back(peekToken()); + } + t = skipAndPeekToken(); + } +} void Parser::ParseExactInteger(Token t) { if(t.type=="LeftAngle") { t=skipAndPeekToken(); @@ -594,6 +622,8 @@ void Parser::ParseExactInteger(Token t) { } if(t.type=="RightAngle") { tokenStack.push_back(Token("Integer",num)); + t=skipAndPeekToken(); + setForExactIntegers(t); } else { inError=true; diff --git a/src/dtpulse.hpp b/src/dtpulse.hpp @@ -37,8 +37,11 @@ class Parser { Token peekToken(); Token skipAndPeekToken(); + void setForCookies(); + void setForLaundry(); void skipToken(); void setExactValue(Token t); + void setForExactIntegers(Token t); void setForRandoms(Token t); void setForInterleave(Token t); void setForAtExpand(Token t); @@ -107,5 +110,6 @@ std::vector<Token> tokenizeString(std::string input); bool matchParens(std::string value); std::string evalToken(std::string input, std::string type,std::vector<Token> tStack); void whoKnows(std::string input); +void whoKnowsLaundry(std::string input); std::vector<int> getIndicesFromTokenStack(std::vector<Token> tokens); std::vector<int> duplicateIntVector(std::vector<int> input); diff --git a/src/test.cpp b/src/test.cpp @@ -36,6 +36,9 @@ int main(int argc, char** argv) else if(type==5) { whoKnows(argv[1]); } + else if(type==6) { + whoKnowsLaundry(argv[1]); + } return 0; } void printVector(std::vector <int> intVector) {