commit bcfe68d8568b7dd260bab3189d3f8ea23b54c69d
parent b87bfbe5630ff1d8bdfa0004ae7e8efe747c0406
Author: Adam Malone <[email protected]>
Date: Mon, 19 Aug 2019 16:02:28 -0500
string replacement where it should be a tokenizer
Diffstat:
1 file changed, 5 insertions(+), 31 deletions(-)
diff --git a/src/dtpulse.cpp b/src/dtpulse.cpp
@@ -392,37 +392,11 @@ void whoKnowsLaundryPoly(std::string input) {
}
LaundryPoly::LaundryPoly(std::string formula) {
std::string newFormula = "";
- inError = false;
-
- std::vector<Token> defaultStack;
- std::vector<Token> calculatedTokens;
- defaultStack.push_back(Token("Error", "error", -1));
- if (formula != "") {
- Parser p = Parser(formula);
- p.setForLaundryPoly();
- if (p.inError || !p.tokenStack.size()) {
- printf("in error\n");
- calculatedTokens = defaultStack;
- inError = true;
- }
- else {
- calculatedTokens = p.tokenStack;
- inError = false;
- printf("no error\n");
- }
- }
- else {
- calculatedTokens = defaultStack;
- inError = false;
- printf("default stack\n");
- }
- printf("calculated tokez:\n");
- printTokenVector(calculatedTokens);
- for (int i = 0; i < 16; i++ ) {
+ for (int i = 0; i < 16; i++ ) {
newFormula = formula;
+ replaceAll(newFormula, "2^#", "<" + std::to_string(static_cast<long long>(1 << i)) + ">");
replaceAll(newFormula, "#", "<" + std::to_string(static_cast<long long>(i + 1)) + ">");
-
- lss[i] = LaundrySoupSequence(calculatedTokens);
+ lss[i] = LaundrySoupSequence(newFormula);
}
}
LaundryPoly::LaundryPoly() {
@@ -489,8 +463,8 @@ void LaundrySoupSequence::Setup(std::vector<Token> tokens) {
void LaundrySoupSequence::print() {
printf(" LaundrySoupSequence inError:%d, tokenStack:\n",inError);
printTokenVector(tokenStack);
- printf(" Laundry pulseSequence:\n");
- printVector(pulseSequence);
+ //printf(" Laundry pulseSequence:\n");
+ //printVector(pulseSequence);
}
std::vector<int> LaundrySoupSequence::makePulseSequence(std::vector<Token> tokens) {
std::vector<int> output = {};