Skip to content

Commit 194cc96

Browse files
committed
Refactor: renamed RxTerm.isEffectivelyEmpty to isUnsatisfiable
1 parent 7291f0b commit 194cc96

6 files changed

Lines changed: 20 additions & 20 deletions

File tree

core/src/main/kotlin/org/evomaster/core/parser/GeneRegexJavaVisitor.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ class GeneRegexJavaVisitor : RegexJavaBaseVisitor<VisitResult>(){
8888
val res = ctx.accept(this)
8989
val validDisjunctions = res.genes.map { it as DisjunctionRxGene }
9090

91-
val nonEmptyDisj = validDisjunctions.filter{ !it.isEffectivelyEmpty() }
91+
val satisfiableDisjunctions = validDisjunctions.filter{ !it.isUnsatisfiable() }
9292

93-
if(nonEmptyDisj.isEmpty()){
93+
if(satisfiableDisjunctions.isEmpty()){
9494
// As DisjunctionListRxGene extends CompositeFixedGene, its disjunctions list cannot be empty.
9595
// In this case we return null to represent an unsatisfiable DisjunctionListRxGene.
9696
return null
9797
}
9898

99-
val disjList = DisjunctionListRxGene(nonEmptyDisj)
99+
val disjList = DisjunctionListRxGene(satisfiableDisjunctions)
100100

101101
//TODO tmp hack until full handling of ^$. Assume full match when nested disjunctions
102102
for (gene in disjList.disjunctions) {
@@ -114,15 +114,15 @@ class GeneRegexJavaVisitor : RegexJavaBaseVisitor<VisitResult>(){
114114

115115
val text = RegexUtils.getRegexExpByParserRuleContext(ctx)
116116

117-
val nonEmptyDisj = res.genes
117+
val satisfiableDisjunctions = res.genes
118118
.map { it as DisjunctionRxGene }
119-
.filter{ !it.isEffectivelyEmpty() }
119+
.filter{ !it.isUnsatisfiable() }
120120

121-
if (nonEmptyDisj.isEmpty()) {
121+
if (satisfiableDisjunctions.isEmpty()) {
122122
throw IllegalStateException("Regex is unsatisfiable.")
123123
}
124124

125-
val disjList = DisjunctionListRxGene(nonEmptyDisj)
125+
val disjList = DisjunctionListRxGene(satisfiableDisjunctions)
126126

127127
// we remove the <EOF> token from end of the string to store as sourceRegex
128128
val gene = RegexGene(
@@ -265,7 +265,7 @@ class GeneRegexJavaVisitor : RegexJavaBaseVisitor<VisitResult>(){
265265

266266
// if quantified atom is unsatisfiable we must then check the limits
267267
if (atom == null ||
268-
((atom as? RxTerm)?.isEffectivelyEmpty() == true) && resAtom.genes.size == 1) {
268+
((atom as? RxTerm)?.isUnsatisfiable() == true) && resAtom.genes.size == 1) {
269269
return if (limits.first == 0) {
270270
// if 0 appearances is allowed then the regex is satisfiable only with empty string
271271
VisitResult(PatternCharacterBlockGene("0_QuantifierOnEmptyRegex", ""))

core/src/main/kotlin/org/evomaster/core/search/gene/regex/BackReferenceRxGene.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class BackReferenceRxGene(
2222
val captureGroup: DisjunctionListRxGene?
2323
) : RxAtom, SimpleGene("\\$groupIndex") {
2424

25-
override fun isEffectivelyEmpty(): Boolean {
26-
return captureGroup == null || captureGroup.isEffectivelyEmpty()
25+
override fun isUnsatisfiable(): Boolean {
26+
return captureGroup == null || captureGroup.isUnsatisfiable()
2727
}
2828

2929
override fun checkForLocallyValidIgnoringChildren(): Boolean = true

core/src/main/kotlin/org/evomaster/core/search/gene/regex/CharacterClassEscapeRxGene.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ class CharacterClassEscapeRxGene(
132132
}
133133
}
134134

135-
override fun isEffectivelyEmpty(): Boolean = multiCharRange.isEmpty
135+
override fun isUnsatisfiable(): Boolean = multiCharRange.isEmpty
136136

137137
override fun isMutable(): Boolean {
138-
return !isEffectivelyEmpty()
138+
return !isUnsatisfiable()
139139
}
140140

141141
override fun checkForLocallyValidIgnoringChildren() : Boolean{
@@ -199,7 +199,7 @@ class CharacterClassEscapeRxGene(
199199
}
200200

201201
override fun getValueAsPrintableString(previousGenes: List<Gene>, mode: GeneUtils.EscapeMode?, targetFormat: OutputFormat?, extraCheck: Boolean): String {
202-
if (isEffectivelyEmpty()) {
202+
if (isUnsatisfiable()) {
203203
throw IllegalStateException("Cannot get value from empty CharacterClassEscape")
204204
}
205205
return if (!flags.isCaseable(value[0])) {

core/src/main/kotlin/org/evomaster/core/search/gene/regex/CharacterRangeRxGene.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ class CharacterRangeRxGene(
3030
private val log = LoggerFactory.getLogger(CharacterRangeRxGene::class.java)
3131
}
3232

33-
var value : Char = if (isEffectivelyEmpty()) '\u0000' else validRanges[0].start
33+
var value : Char = if (isUnsatisfiable()) '\u0000' else validRanges[0].start
3434

3535
/**
3636
* Whether to output the character in uppercase.
3737
* Only meaningful when flags.caseInsensitive is true.
3838
*/
3939
var useUpperCase: Boolean = false
4040

41-
override fun isEffectivelyEmpty(): Boolean = validRanges.isEmpty
41+
override fun isUnsatisfiable(): Boolean = validRanges.isEmpty
4242

4343
override fun checkForLocallyValidIgnoringChildren() : Boolean{
4444
return validRanges.any {
@@ -51,7 +51,7 @@ class CharacterRangeRxGene(
5151
}
5252

5353
override fun isMutable(): Boolean {
54-
if (isEffectivelyEmpty()) {
54+
if (isUnsatisfiable()) {
5555
return false
5656
}
5757
// check if there is more than one character or if the character is caseable
@@ -139,7 +139,7 @@ class CharacterRangeRxGene(
139139
TODO should \ be handled specially?
140140
In any case, would have same handling as AnyCharacterRxGene
141141
*/
142-
if (isEffectivelyEmpty()) {
142+
if (isUnsatisfiable()) {
143143
throw IllegalStateException("Cannot get value from empty CharacterRange")
144144
}
145145
return if (!flags.isCaseable(value)) {

core/src/main/kotlin/org/evomaster/core/search/gene/regex/DisjunctionRxGene.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ class DisjunctionRxGene(
4747
private val log : Logger = LoggerFactory.getLogger(DisjunctionRxGene::class.java)
4848
}
4949

50-
override fun isEffectivelyEmpty(): Boolean =
51-
terms.isNotEmpty() && terms.any { (it as? RxTerm)?.isEffectivelyEmpty() == true }
50+
override fun isUnsatisfiable(): Boolean =
51+
terms.isNotEmpty() && terms.any { (it as? RxTerm)?.isUnsatisfiable() == true }
5252

5353
override fun checkForLocallyValidIgnoringChildren() : Boolean{
5454
return true

core/src/main/kotlin/org/evomaster/core/search/gene/regex/RxTerm.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ interface RxTerm {
1010
* for example an empty character class intersection like [a&&b].
1111
* Used at construction time to filter unsatisfiable branches from disjunctions.
1212
*/
13-
fun isEffectivelyEmpty(): Boolean = false
13+
fun isUnsatisfiable(): Boolean = false
1414
}

0 commit comments

Comments
 (0)