Skip to content

Commit

Permalink
Merge pull request tensor-compiler#334 from roastduck/fix-parse
Browse files Browse the repository at this point in the history
Fix -s argument parsing in the command line tool
  • Loading branch information
stephenchouca authored Dec 15, 2020
2 parents dd62216 + 1b27e3c commit dcbfdc3
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions tools/taco.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,23 +814,19 @@ int main(int argc, char* argv[]) {
}
else if ("-s" == argName) {
setSchedule = true;
bool insideCall = false;
bool parsingExpr = false;
int parenthesesCnt = 0;

std::replace_if(argValue.begin(), argValue.end(), [&insideCall, &parsingExpr](char c) {
std::replace_if(argValue.begin(), argValue.end(), [&parenthesesCnt](char c) {
if (c == '(') {
if (insideCall) {
parsingExpr = true; // need to handle precompute case specially
} else {
insideCall = true;
return true;
if (parenthesesCnt++ == 0) { // '(' for a call
return true;
}
} else if (c == ',') {
return !parsingExpr;
return parenthesesCnt <= 1;
} else if (c == ')') {
bool previous = parsingExpr;
parsingExpr = false;
return !previous;
if (--parenthesesCnt == 0) { // ')' for a call
return true;
}
}
return false;
}, ' ');
Expand Down

0 comments on commit dcbfdc3

Please sign in to comment.