//===----------------------------------------------------------------------===//
class Pattern {
//===----------------------------------------------------------------------===//
class Pattern {
+ SourceMgr *SM;
+ SMLoc PatternLoc;
+
/// FixedStr - If non-empty, this pattern is a fixed string match with the
/// specified fixed string.
StringRef FixedStr;
/// FixedStr - If non-empty, this pattern is a fixed string match with the
/// specified fixed string.
StringRef FixedStr;
};
bool Pattern::ParsePattern(StringRef PatternStr, SourceMgr &SM) {
};
bool Pattern::ParsePattern(StringRef PatternStr, SourceMgr &SM) {
+ this->SM = &SM;
+ PatternLoc = SMLoc::getFromPointer(PatternStr.data());
+
// Ignore trailing whitespace.
while (!PatternStr.empty() &&
(PatternStr.back() == ' ' || PatternStr.back() == '\t'))
// Ignore trailing whitespace.
while (!PatternStr.empty() &&
(PatternStr.back() == ' ' || PatternStr.back() == '\t'))
// Check that there is something on the line.
if (PatternStr.empty()) {
// Check that there is something on the line.
if (PatternStr.empty()) {
- SM.PrintMessage(SMLoc::getFromPointer(PatternStr.data()),
- "found empty check string with prefix '"+CheckPrefix+":'",
- "error");
+ SM.PrintMessage(PatternLoc, "found empty check string with prefix '" +
+ CheckPrefix+":'", "error");
assert(!MatchInfo.empty() && "Didn't get any match");
StringRef FullMatch = MatchInfo[0];
assert(!MatchInfo.empty() && "Didn't get any match");
StringRef FullMatch = MatchInfo[0];
+
+ if (MatchInfo.size() != 1) {
+ SM->PrintMessage(PatternLoc, "regex cannot use grouping parens", "error");
+ exit(1);
+ }
+
+
MatchLen = FullMatch.size();
return FullMatch.data()-Buffer.data();
}
MatchLen = FullMatch.size();
return FullMatch.data()-Buffer.data();
}