Skip to content

Commit

Permalink
allow to change regex threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
MichZia committed Jul 25, 2019
1 parent bda2c71 commit 4717276
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion include/hobbes/eval/cc.H
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ public:
bool alwaysLowerPrimMatchTables() const;
void buildColumnwiseMatches(bool f);
bool buildColumnwiseMatches() const;
void regexMaxExprDFASize(size_t f);
size_t regexMaxExprDFASize() const;
void throwOnHugeRegexDFA(bool f);
bool throwOnHugeRegexDFA() const;
void regexDFAOverNFAMaxRatio(int f);
Expand Down Expand Up @@ -290,7 +292,7 @@ private:
bool checkMatchReachability;
bool lowerPrimMatchTables;
bool columnwiseMatches;

size_t maxExprDFASize={1000};
// abort compilation of regexes which translate into huge dfa transition states
bool shouldThrowOnHugeRegexDFA = false;
int dfaOverNfaMaxRatio = 4;
Expand Down
3 changes: 3 additions & 0 deletions lib/hobbes/eval/cc.C
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,9 @@ bool cc::alwaysLowerPrimMatchTables() const { return this->lowerPrimMatchTables;
void cc::buildColumnwiseMatches(bool f) { this->columnwiseMatches = f; }
bool cc::buildColumnwiseMatches() const { return this->columnwiseMatches; }

void cc::regexMaxExprDFASize(size_t f) { this->maxExprDFASize = f; }
size_t cc::regexMaxExprDFASize() const { return this->maxExprDFASize; }

void cc::throwOnHugeRegexDFA(bool f) { this->shouldThrowOnHugeRegexDFA = f; }
bool cc::throwOnHugeRegexDFA() const { return this-> shouldThrowOnHugeRegexDFA; }

Expand Down
2 changes: 1 addition & 1 deletion lib/hobbes/lang/pat/regex.C
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ void makeInterpDFAFunc(cc* c, const std::string& fname, const MonoTypePtr& captu
}

void makeDFAFunc(cc* c, const std::string& fname, const MonoTypePtr& captureTy, const DFA& dfa, const LexicalAnnotation& rootLA) {
if (dfa.size() < 1000 || !isUnit(captureTy)) {
if (dfa.size() < c->regexMaxExprDFASize() || !isUnit(captureTy)) {
makeExprDFAFunc(c, fname, captureTy, dfa, rootLA);
} else {
makeInterpDFAFunc(c, fname, captureTy, dfa, rootLA);
Expand Down

0 comments on commit 4717276

Please sign in to comment.