1 //===-- Regex.h - Regular Expression matcher implementation -*- 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 a POSIX regular expression matcher.
12 //===----------------------------------------------------------------------===//
20 template<typename T> class SmallVectorImpl;
26 /// Compile for matching that ignores upper/lower case distinctions.
28 /// Compile for newline-sensitive matching. With this flag '[^' bracket
29 /// expressions and '.' never match newline. A ^ anchor matches the
30 /// null string after any newline in the string in addition to its normal
31 /// function, and the $ anchor matches the null string before any
32 /// newline in the string in addition to its normal function.
36 /// Compiles the given POSIX Extended Regular Expression \arg Regex.
37 /// This implementation supports regexes and matching strings with embedded
39 Regex(const StringRef &Regex, unsigned Flags = NoFlags);
42 /// isValid - returns the error encountered during regex compilation, or
44 bool isValid(std::string &Error);
46 /// getNumMatches - In a valid regex, return the number of parenthesized
47 /// matches it contains. The number filled in by match will include this
48 /// many entries plus one for the whole regex (as element 0).
49 unsigned getNumMatches() const;
51 /// matches - Match the regex against a given \arg String.
53 /// \param Matches - If given, on a succesful match this will be filled in
54 /// with references to the matched group expressions (inside \arg String),
55 /// the first group is always the entire pattern.
57 /// This returns true on a successful match.
58 bool match(const StringRef &String, SmallVectorImpl<StringRef> *Matches=0);
60 struct llvm_regex *preg;