-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate constant regex for match with a constant pattern.
For constraints like match(".*", X), where the pattern is a string constant, we can avoid using the regex cache. Avoiding the cache is going to perform better in all cases. I introduced the new node RegexConstant which only appears immediately below a MATCH or NOT_MATCH node. The behavior with regards to invalid regexes has not changed and bad regexes will not lead to program errors.
- Loading branch information
Showing
15 changed files
with
222 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
foobar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.decl A(x:symbol) | ||
.input A() | ||
|
||
.decl B(x:symbol) | ||
.output B() | ||
|
||
B(x) :- A(x),match("fo{2}b.*",x). | ||
B(x) :- A(x),!match("fo{x}b.*",x). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
warning: wrong pattern provided "fo{x}b.*" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
foobar | ||
fooobar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Souffle - A Datalog Compiler | ||
// Copyright (c) 2020, The Souffle Developers. All rights reserved | ||
// Licensed under the Universal Permissive License v 1.0 as shown at: | ||
// - https://opensource.org/licenses/UPL | ||
// - <souffle root>/licenses/SOUFFLE-UPL.txt | ||
|
||
// Check string matching from relations with mixed valid and invalid regex | ||
|
||
.type String <: symbol | ||
|
||
|
||
// Split into several forced strata to keep warnings deterministic | ||
// Note: we add a "dummy" check to prevent optimisation | ||
.decl dummy(x:String) | ||
dummy("dummy"). | ||
|
||
.decl inputDataStep1, inputDataStep2, inputDataStep3(x:String) | ||
inputDataStep1("a"). | ||
inputDataStep2("aaaa"). | ||
inputDataStep3("bdab"). | ||
|
||
.decl outputDataStep1(x:String) | ||
outputDataStep1(x) :- inputDataStep1(x), match("a.*", x). | ||
outputDataStep1(x) :- inputDataStep1(x), match("b.*", x). | ||
outputDataStep1(x) :- inputDataStep1(x), match("b.*[", x). | ||
outputDataStep1(x) :- inputDataStep1(x), match("a.*[a]", x). | ||
|
||
.decl outputDataStep2(x:String) | ||
outputDataStep2(x) :- dummy(x), !outputDataStep1(x), x != "dummy". | ||
outputDataStep2(x) :- inputDataStep2(x), match("a.*", x). | ||
outputDataStep2(x) :- inputDataStep2(x), match("b.*", x). | ||
outputDataStep2(x) :- inputDataStep2(x), match("b.*[", x). | ||
outputDataStep2(x) :- inputDataStep2(x), match("a.*[a]", x). | ||
|
||
.decl outputDataStep3(x:String) | ||
outputDataStep3(x) :- dummy(x), !outputDataStep2(x), x != "dummy". | ||
outputDataStep3(x) :- inputDataStep3(x), match("a.*", x). | ||
outputDataStep3(x) :- inputDataStep3(x), match("b.*", x). | ||
outputDataStep3(x) :- inputDataStep3(x), match("b.*[", x). | ||
outputDataStep3(x) :- inputDataStep3(x), match("a.*[a]", x). | ||
|
||
.decl outputData(x:String) | ||
.output outputData() | ||
outputData(x) :- outputDataStep1(x) ; outputDataStep2(x) ; outputDataStep3(x). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
warning: wrong pattern provided "b.*[" | ||
warning: wrong pattern provided "b.*[" | ||
warning: wrong pattern provided "b.*[" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
a | ||
aaaa | ||
bdab |