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