Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:58

0001 //===-- StringLexer.h -------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_UTILITY_STRINGLEXER_H
0010 #define LLDB_UTILITY_STRINGLEXER_H
0011 
0012 #include <initializer_list>
0013 #include <string>
0014 #include <utility>
0015 
0016 namespace lldb_private {
0017 
0018 class StringLexer {
0019 public:
0020   typedef std::string::size_type Position;
0021   typedef std::string::size_type Size;
0022 
0023   typedef std::string::value_type Character;
0024 
0025   StringLexer(std::string s);
0026 
0027   // These APIs are not bounds-checked.  Use HasAtLeast() if you're not sure.
0028   Character Peek();
0029 
0030   bool NextIf(Character c);
0031 
0032   std::pair<bool, Character> NextIf(std::initializer_list<Character> cs);
0033 
0034   bool AdvanceIf(const std::string &token);
0035 
0036   Character Next();
0037 
0038   bool HasAtLeast(Size s);
0039 
0040   std::string GetUnlexed();
0041 
0042   // This will assert if there are less than s characters preceding the cursor.
0043   void PutBack(Size s);
0044 
0045   StringLexer &operator=(const StringLexer &rhs);
0046 
0047 private:
0048   std::string m_data;
0049   Position m_position;
0050 
0051   void Consume();
0052 };
0053 
0054 } // namespace lldb_private
0055 
0056 #endif // LLDB_UTILITY_STRINGLEXER_H