Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.6 KiB

  1. //===- StringMatcher.h - Generate a matcher for input strings ---*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This file implements the StringMatcher class.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_TABLEGEN_STRINGMATCHER_H
  14. #define LLVM_TABLEGEN_STRINGMATCHER_H
  15. #include "llvm/ADT/StringRef.h"
  16. #include <string>
  17. #include <utility>
  18. #include <vector>
  19. namespace llvm {
  20. class raw_ostream;
  21. /// StringMatcher - Given a list of strings and code to execute when they match,
  22. /// output a simple switch tree to classify the input string.
  23. ///
  24. /// If a match is found, the code in Vals[i].second is executed; control must
  25. /// not exit this code fragment. If nothing matches, execution falls through.
  26. ///
  27. class StringMatcher {
  28. public:
  29. typedef std::pair<std::string, std::string> StringPair;
  30. private:
  31. StringRef StrVariableName;
  32. const std::vector<StringPair> &Matches;
  33. raw_ostream &OS;
  34. public:
  35. StringMatcher(StringRef strVariableName,
  36. const std::vector<StringPair> &matches, raw_ostream &os)
  37. : StrVariableName(strVariableName), Matches(matches), OS(os) {}
  38. void Emit(unsigned Indent = 0) const;
  39. private:
  40. bool EmitStringMatcherForChar(const std::vector<const StringPair*> &Matches,
  41. unsigned CharNo, unsigned IndentCount) const;
  42. };
  43. } // end llvm namespace.
  44. #endif