summaryrefslogtreecommitdiffstats
path: root/lldb/source/Utility
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2014-11-14 22:58:11 +0000
committerEnrico Granata <egranata@apple.com>2014-11-14 22:58:11 +0000
commite65a28f36fcd9e3391ccfe4e81d6a807c986fa08 (patch)
tree1bd88ccd626c2e5c62a7ca60331ef1ef55b6c233 /lldb/source/Utility
parent603d316517c75ced68ca29a234cfd17c12826f1b (diff)
downloadbcm5719-llvm-e65a28f36fcd9e3391ccfe4e81d6a807c986fa08.tar.gz
bcm5719-llvm-e65a28f36fcd9e3391ccfe4e81d6a807c986fa08.zip
Removed a couple of static helpers in the data formatters, replaced with new general logic in StringLexer
llvm-svn: 222058
Diffstat (limited to 'lldb/source/Utility')
-rw-r--r--lldb/source/Utility/StringLexer.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/lldb/source/Utility/StringLexer.cpp b/lldb/source/Utility/StringLexer.cpp
index 4da40995e19..2f62d2cedb4 100644
--- a/lldb/source/Utility/StringLexer.cpp
+++ b/lldb/source/Utility/StringLexer.cpp
@@ -42,6 +42,42 @@ StringLexer::NextIf (Character c)
return false;
}
+std::pair<bool, StringLexer::Character>
+StringLexer::NextIf (std::initializer_list<Character> cs)
+{
+ auto val = Peek();
+ for (auto c : cs)
+ {
+ if (val == c)
+ {
+ Next();
+ return {true,c};
+ }
+ }
+ return {false,0};
+}
+
+bool
+StringLexer::AdvanceIf (const std::string& token)
+{
+ auto pos = m_position;
+ bool matches = true;
+ for (auto c : token)
+ {
+ if (!NextIf(c))
+ {
+ matches = false;
+ break;
+ }
+ }
+ if (!matches)
+ {
+ m_position = pos;
+ return false;
+ }
+ return true;
+}
+
StringLexer::Character
StringLexer::Next ()
{
@@ -69,6 +105,12 @@ StringLexer::HasAny (Character c)
return m_data.find(c, m_position) != std::string::npos;
}
+std::string
+StringLexer::GetUnlexed ()
+{
+ return std::string(m_data, m_position);
+}
+
void
StringLexer::Consume()
{
OpenPOWER on IntegriCloud