-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from tmr232/release-0.0.10
Prep for release 0.0.10
- Loading branch information
Showing
7 changed files
with
92 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
Capturer::Capturer( StringRef macroName, | ||
SourceLineInfo const& lineInfo, | ||
ResultWas::OfType resultType, | ||
StringRef names ): | ||
m_resultCapture( getResultCapture() ) { | ||
auto trimmed = [&] (size_t start, size_t end) { | ||
while (names[start] == ',' || isspace(static_cast<unsigned char>(names[start]))) { | ||
++start; | ||
} | ||
while (names[end] == ',' || isspace(static_cast<unsigned char>(names[end]))) { | ||
--end; | ||
} | ||
return names.substr(start, end - start + 1); | ||
}; | ||
auto skipq = [&] (size_t start, char quote) { | ||
for (auto i = start + 1; i < names.size() ; ++i) { | ||
if (names[i] == quote) | ||
return i; | ||
if (names[i] == '\\') | ||
++i; | ||
} | ||
CATCH_INTERNAL_ERROR("CAPTURE parsing encountered unmatched quote"); | ||
}; | ||
|
||
size_t start = 0; | ||
std::stack<char> openings; | ||
for (size_t pos = 0; pos < names.size(); ++pos) { | ||
char c = names[pos]; | ||
switch (c) { | ||
case '[': | ||
case '{': | ||
case '(': | ||
// It is basically impossible to disambiguate between | ||
// comparison and start of template args in this context | ||
// case '<': | ||
openings.push(c); | ||
break; | ||
case ']': | ||
case '}': | ||
case ')': | ||
// case '>': | ||
openings.pop(); | ||
break; | ||
case '"': | ||
case '\'': | ||
pos = skipq(pos, c); | ||
break; | ||
case ',': | ||
if (start != pos && openings.empty()) { | ||
m_messages.emplace_back(macroName, lineInfo, resultType); | ||
m_messages.back().message = static_cast<std::string>(trimmed(start, pos)); | ||
m_messages.back().message += " := "; | ||
start = pos; | ||
} | ||
break; | ||
default:; // noop | ||
} | ||
} | ||
assert(openings.empty() && "Mismatched openings"); | ||
m_messages.emplace_back(macroName, lineInfo, resultType); | ||
m_messages.back().message = static_cast<std::string>(trimmed(start, names.size() - 1)); | ||
m_messages.back().message += " := "; | ||
} |