| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
#ifndef LLVM_TABLEGEN_STRINGMATCHER_H |
| 14 |
#define LLVM_TABLEGEN_STRINGMATCHER_H |
| 15 |
|
| 16 |
#include "llvm/ADT/StringRef.h" |
| 17 |
#include <string> |
| 18 |
#include <utility> |
| 19 |
#include <vector> |
| 20 |
|
| 21 |
namespace llvm { |
| 22 |
|
| 23 |
class raw_ostream; |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
class StringMatcher { |
| 31 |
public: |
| 32 |
using StringPair = std::pair<std::string, std::string>; |
| 33 |
|
| 34 |
private: |
| 35 |
StringRef StrVariableName; |
| 36 |
const std::vector<StringPair> &Matches; |
| 37 |
raw_ostream &OS; |
| 38 |
|
| 39 |
public: |
| 40 |
StringMatcher(StringRef strVariableName, |
| 41 |
const std::vector<StringPair> &matches, raw_ostream &os) |
| 42 |
: StrVariableName(strVariableName), Matches(matches), OS(os) {} |
| 43 |
|
| 44 |
void Emit(unsigned Indent = 0, bool IgnoreDuplicates = false) const; |
| 45 |
|
| 46 |
private: |
| 47 |
bool EmitStringMatcherForChar(const std::vector<const StringPair *> &Matches, |
| 48 |
unsigned CharNo, unsigned IndentCount, |
| 49 |
bool IgnoreDuplicates) const; |
| 50 |
}; |
| 51 |
|
| 52 |
} |
| 53 |
|
| 54 |
#endif |