mirror of
https://github.com/github/codeql.git
synced 2026-04-30 03:05:15 +02:00
Convert snake case predicates to camel case
This commit is contained in:
@@ -601,8 +601,8 @@ class RegExpCharacterClass extends RegExpTerm, TRegExpCharacterClass {
|
||||
result.getRegex() = re and
|
||||
exists(int itemStart, int itemEnd |
|
||||
result.getStart() = itemStart and
|
||||
re.char_set_start(start, itemStart) and
|
||||
re.char_set_child(start, itemStart, itemEnd) and
|
||||
re.charSetStart(start, itemStart) and
|
||||
re.charSetChild(start, itemStart, itemEnd) and
|
||||
result.getEnd() = itemEnd
|
||||
)
|
||||
or
|
||||
@@ -610,7 +610,7 @@ class RegExpCharacterClass extends RegExpTerm, TRegExpCharacterClass {
|
||||
result.getRegex() = re and
|
||||
exists(int itemStart | itemStart = this.getChild(i - 1).getEnd() |
|
||||
result.getStart() = itemStart and
|
||||
re.char_set_child(start, itemStart, result.getEnd())
|
||||
re.charSetChild(start, itemStart, result.getEnd())
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -7,42 +7,42 @@ private import RegexFlowConfigs
|
||||
*/
|
||||
abstract class RegexString extends StringLiteral {
|
||||
/** Holds if a character set starts between `start` and `end`, including any negation character (`^`). */
|
||||
private predicate char_set_start0(int start, int end) {
|
||||
private predicate charSetStart0(int start, int end) {
|
||||
this.nonEscapedCharAt(start) = "[" and
|
||||
(if this.getChar(start + 1) = "^" then end = start + 2 else end = start + 1)
|
||||
}
|
||||
|
||||
/** Holds if the character at `pos` marks the end of a character class. */
|
||||
private predicate char_set_end0(int pos) {
|
||||
private predicate charSetEnd0(int pos) {
|
||||
this.nonEscapedCharAt(pos) = "]" and
|
||||
/* special case: `[]]` and `[^]]` are valid char classes. */
|
||||
not this.char_set_start0(_, pos)
|
||||
not this.charSetStart0(_, pos)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the nesting depth of character classes at position `pos`
|
||||
*/
|
||||
private int char_set_depth(int pos) {
|
||||
private int charSetDepth(int pos) {
|
||||
exists(this.getChar(pos)) and
|
||||
result =
|
||||
max(int j |
|
||||
j = 0 or
|
||||
j =
|
||||
count(int i | i < pos and this.char_set_start0(i, _)) -
|
||||
count(int i | i < pos and this.char_set_end0(i))
|
||||
count(int i | i < pos and this.charSetStart0(i, _)) -
|
||||
count(int i | i < pos and this.charSetEnd0(i))
|
||||
)
|
||||
}
|
||||
|
||||
/** Hold if a top-level character set starts between `start` and `end`. */
|
||||
predicate char_set_start(int start, int end) {
|
||||
this.char_set_start0(start, end) and
|
||||
this.char_set_depth(start) = 0
|
||||
predicate charSetStart(int start, int end) {
|
||||
this.charSetStart0(start, end) and
|
||||
this.charSetDepth(start) = 0
|
||||
}
|
||||
|
||||
/** Holds if a top-level character set ends at `pos`. */
|
||||
predicate char_set_end(int pos) {
|
||||
this.char_set_end0(pos) and
|
||||
this.char_set_depth(pos) = 1
|
||||
predicate charSetEnd(int pos) {
|
||||
this.charSetEnd0(pos) and
|
||||
this.charSetDepth(pos) = 1
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,26 +53,26 @@ abstract class RegexString extends StringLiteral {
|
||||
*/
|
||||
predicate charSet(int start, int end) {
|
||||
exists(int inner_start, int inner_end |
|
||||
this.char_set_start(start, inner_start) and
|
||||
not this.char_set_start(_, start)
|
||||
this.charSetStart(start, inner_start) and
|
||||
not this.charSetStart(_, start)
|
||||
|
|
||||
end = inner_end + 1 and
|
||||
inner_end > inner_start and
|
||||
this.char_set_end(inner_end) and
|
||||
not exists(int mid | this.char_set_end(mid) | mid > inner_start and mid < inner_end)
|
||||
this.charSetEnd(inner_end) and
|
||||
not exists(int mid | this.charSetEnd(mid) | mid > inner_start and mid < inner_end)
|
||||
)
|
||||
}
|
||||
|
||||
/** An indexed version of `char_set_token/3` */
|
||||
private predicate char_set_token(int charset_start, int index, int token_start, int token_end) {
|
||||
/** An indexed version of `charSetToken/3` */
|
||||
private predicate charSetToken(int charset_start, int index, int token_start, int token_end) {
|
||||
token_start =
|
||||
rank[index](int start, int end | this.char_set_token(charset_start, start, end) | start) and
|
||||
this.char_set_token(charset_start, token_start, token_end)
|
||||
rank[index](int start, int end | this.charSetToken(charset_start, start, end) | start) and
|
||||
this.charSetToken(charset_start, token_start, token_end)
|
||||
}
|
||||
|
||||
/** Either a char or a - */
|
||||
private predicate char_set_token(int charset_start, int start, int end) {
|
||||
this.char_set_start(charset_start, start) and
|
||||
private predicate charSetToken(int charset_start, int start, int end) {
|
||||
this.charSetStart(charset_start, start) and
|
||||
(
|
||||
this.escapedCharacter(start, end)
|
||||
or
|
||||
@@ -81,13 +81,13 @@ abstract class RegexString extends StringLiteral {
|
||||
this.quote(start, end)
|
||||
)
|
||||
or
|
||||
this.char_set_token(charset_start, _, start) and
|
||||
this.charSetToken(charset_start, _, start) and
|
||||
(
|
||||
this.escapedCharacter(start, end)
|
||||
or
|
||||
exists(this.nonEscapedCharAt(start)) and
|
||||
end = start + 1 and
|
||||
not this.char_set_end(start)
|
||||
not this.charSetEnd(start)
|
||||
or
|
||||
this.quote(start, end)
|
||||
)
|
||||
@@ -97,8 +97,8 @@ abstract class RegexString extends StringLiteral {
|
||||
* Holds if the character set starting at `charset_start` contains either
|
||||
* a character or a range found between `start` and `end`.
|
||||
*/
|
||||
predicate char_set_child(int charset_start, int start, int end) {
|
||||
this.char_set_token(charset_start, start, end) and
|
||||
predicate charSetChild(int charset_start, int start, int end) {
|
||||
this.charSetToken(charset_start, start, end) and
|
||||
not exists(int range_start, int range_end |
|
||||
this.charRange(charset_start, range_start, _, _, range_end) and
|
||||
range_start <= start and
|
||||
@@ -116,8 +116,8 @@ abstract class RegexString extends StringLiteral {
|
||||
predicate charRange(int charset_start, int start, int lower_end, int upper_start, int end) {
|
||||
exists(int index |
|
||||
this.charRangeEnd(charset_start, index) = true and
|
||||
this.char_set_token(charset_start, index - 2, start, lower_end) and
|
||||
this.char_set_token(charset_start, index, upper_start, end)
|
||||
this.charSetToken(charset_start, index - 2, start, lower_end) and
|
||||
this.charSetToken(charset_start, index, upper_start, end)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -129,13 +129,13 @@ abstract class RegexString extends StringLiteral {
|
||||
* the helper for `escapingChar`, for a clean use of this pattern.
|
||||
*/
|
||||
private boolean charRangeEnd(int charset_start, int index) {
|
||||
this.char_set_token(charset_start, index, _, _) and
|
||||
this.charSetToken(charset_start, index, _, _) and
|
||||
(
|
||||
index in [1, 2] and result = false
|
||||
or
|
||||
index > 2 and
|
||||
exists(int connector_start |
|
||||
this.char_set_token(charset_start, index - 1, connector_start, _) and
|
||||
this.charSetToken(charset_start, index - 1, connector_start, _) and
|
||||
this.nonEscapedCharAt(connector_start) = "-" and
|
||||
result =
|
||||
this.charRangeEnd(charset_start, index - 2)
|
||||
@@ -144,7 +144,7 @@ abstract class RegexString extends StringLiteral {
|
||||
)
|
||||
or
|
||||
not exists(int connector_start |
|
||||
this.char_set_token(charset_start, index - 1, connector_start, _) and
|
||||
this.charSetToken(charset_start, index - 1, connector_start, _) and
|
||||
this.nonEscapedCharAt(connector_start) = "-"
|
||||
) and
|
||||
result = false
|
||||
@@ -182,7 +182,7 @@ abstract class RegexString extends StringLiteral {
|
||||
* Holds if the char at `pos` could be the beginning of a quote delimiter, i.e. `\Q` (non-escaped) or `\E` (escaping not checked, as quote sequences turn off escapes).
|
||||
* Result is `true` for `\Q` and `false` for `\E`.
|
||||
*/
|
||||
private boolean quote_delimiter(int pos) {
|
||||
private boolean quoteDelimiter(int pos) {
|
||||
result = true and
|
||||
this.escaping(pos) = true and
|
||||
this.getChar(pos + 1) = "Q"
|
||||
@@ -197,9 +197,9 @@ abstract class RegexString extends StringLiteral {
|
||||
* Holds if the char at `pos` is the one-based `index`th occourence of a quote delimiter (`\Q` or `\E`)
|
||||
* Result is `true` for `\Q` and `false` for `\E`.
|
||||
*/
|
||||
private boolean quote_delimiter(int index, int pos) {
|
||||
result = this.quote_delimiter(pos) and
|
||||
pos = rank[index](int p | this.quote_delimiter(p) = [true, false])
|
||||
private boolean quoteDelimiter(int index, int pos) {
|
||||
result = this.quoteDelimiter(pos) and
|
||||
pos = rank[index](int p | this.quoteDelimiter(p) = [true, false])
|
||||
}
|
||||
|
||||
/** Holds if a quoted sequence is found between `start` and `end` */
|
||||
@@ -208,18 +208,18 @@ abstract class RegexString extends StringLiteral {
|
||||
/** Holds if a quoted sequence is fund between `start` and `end`, with ontent found between `inner_start` and `inner_end`. */
|
||||
predicate quote(int start, int end, int inner_start, int inner_end) {
|
||||
exists(int index |
|
||||
this.quote_delimiter(index, start) = true and
|
||||
this.quoteDelimiter(index, start) = true and
|
||||
(
|
||||
index = 1
|
||||
or
|
||||
this.quote_delimiter(index - 1, _) = false
|
||||
this.quoteDelimiter(index - 1, _) = false
|
||||
) and
|
||||
inner_start = start + 2 and
|
||||
inner_end = end - 2 and
|
||||
inner_end > inner_start and
|
||||
this.quote_delimiter(inner_end) = false and
|
||||
this.quoteDelimiter(inner_end) = false and
|
||||
not exists(int mid |
|
||||
this.quote_delimiter(mid) = false and mid in [inner_start .. inner_end - 1]
|
||||
this.quoteDelimiter(mid) = false and mid in [inner_start .. inner_end - 1]
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -255,7 +255,7 @@ abstract class RegexString extends StringLiteral {
|
||||
predicate failedToParse(int i) {
|
||||
exists(this.getChar(i)) and
|
||||
not exists(int start, int end |
|
||||
this.top_level(start, end) and
|
||||
this.topLevel(start, end) and
|
||||
start <= i and
|
||||
end > i
|
||||
)
|
||||
@@ -336,7 +336,7 @@ abstract class RegexString extends StringLiteral {
|
||||
exists(string c | c = this.getChar(start) |
|
||||
exists(int x, int y, int z |
|
||||
this.charSet(x, z) and
|
||||
this.char_set_start(x, y)
|
||||
this.charSetStart(x, y)
|
||||
|
|
||||
start = y
|
||||
or
|
||||
@@ -362,7 +362,7 @@ abstract class RegexString extends StringLiteral {
|
||||
or
|
||||
this.escapedCharacter(start, end)
|
||||
) and
|
||||
not exists(int x, int y | this.group_start(x, y) and x <= start and y >= end) and
|
||||
not exists(int x, int y | this.groupStart(x, y) and x <= start and y >= end) and
|
||||
not exists(int x, int y | this.backreference(x, y) and x <= start and y >= end)
|
||||
}
|
||||
|
||||
@@ -390,14 +390,14 @@ abstract class RegexString extends StringLiteral {
|
||||
int getGroupNumber(int start, int end) {
|
||||
this.group(start, end) and
|
||||
result =
|
||||
count(int i | this.group(i, _) and i < start and not this.non_capturing_group_start(i, _)) + 1
|
||||
count(int i | this.group(i, _) and i < start and not this.nonCapturingGroupStart(i, _)) + 1
|
||||
}
|
||||
|
||||
/** Gets the name, if it has one, of the group in start,end */
|
||||
string getGroupName(int start, int end) {
|
||||
this.group(start, end) and
|
||||
exists(int name_end |
|
||||
this.named_group_start(start, name_end) and
|
||||
this.namedGroupStart(start, name_end) and
|
||||
result = this.getText().substring(start + 3, name_end - 1)
|
||||
)
|
||||
}
|
||||
@@ -416,7 +416,7 @@ abstract class RegexString extends StringLiteral {
|
||||
/** Holds if an empty group is found between `start` and `end`. */
|
||||
predicate emptyGroup(int start, int end) {
|
||||
exists(int endm1 | end = endm1 + 1 |
|
||||
this.group_start(start, endm1) and
|
||||
this.groupStart(start, endm1) and
|
||||
this.isGroupEnd(endm1)
|
||||
)
|
||||
}
|
||||
@@ -439,9 +439,9 @@ abstract class RegexString extends StringLiteral {
|
||||
|
||||
private predicate negativeAssertionGroup(int start, int end) {
|
||||
exists(int in_start |
|
||||
this.negative_lookahead_assertion_start(start, in_start)
|
||||
this.negativeLookaheadAssertionStart(start, in_start)
|
||||
or
|
||||
this.negative_lookbehind_assertion_start(start, in_start)
|
||||
this.negativeLookbehindAssertionStart(start, in_start)
|
||||
|
|
||||
this.groupContents(start, end, in_start, _)
|
||||
)
|
||||
@@ -449,66 +449,66 @@ abstract class RegexString extends StringLiteral {
|
||||
|
||||
/** Holds if a negative lookahead is found between `start` and `end` */
|
||||
predicate negativeLookaheadAssertionGroup(int start, int end) {
|
||||
exists(int in_start | this.negative_lookahead_assertion_start(start, in_start) |
|
||||
exists(int in_start | this.negativeLookaheadAssertionStart(start, in_start) |
|
||||
this.groupContents(start, end, in_start, _)
|
||||
)
|
||||
}
|
||||
|
||||
/** Holds if a negative lookbehind is found between `start` and `end` */
|
||||
predicate negativeLookbehindAssertionGroup(int start, int end) {
|
||||
exists(int in_start | this.negative_lookbehind_assertion_start(start, in_start) |
|
||||
exists(int in_start | this.negativeLookbehindAssertionStart(start, in_start) |
|
||||
this.groupContents(start, end, in_start, _)
|
||||
)
|
||||
}
|
||||
|
||||
/** Holds if a positive lookahead is found between `start` and `end` */
|
||||
predicate positiveLookaheadAssertionGroup(int start, int end) {
|
||||
exists(int in_start | this.lookahead_assertion_start(start, in_start) |
|
||||
exists(int in_start | this.lookaheadAssertionStart(start, in_start) |
|
||||
this.groupContents(start, end, in_start, _)
|
||||
)
|
||||
}
|
||||
|
||||
/** Holds if a positive lookbehind is found between `start` and `end` */
|
||||
predicate positiveLookbehindAssertionGroup(int start, int end) {
|
||||
exists(int in_start | this.lookbehind_assertion_start(start, in_start) |
|
||||
exists(int in_start | this.lookbehindAssertionStart(start, in_start) |
|
||||
this.groupContents(start, end, in_start, _)
|
||||
)
|
||||
}
|
||||
|
||||
private predicate group_start(int start, int end) {
|
||||
this.non_capturing_group_start(start, end)
|
||||
private predicate groupStart(int start, int end) {
|
||||
this.nonCapturingGroupStart(start, end)
|
||||
or
|
||||
this.flag_group_start(start, end, _)
|
||||
this.flagGroupStart(start, end, _)
|
||||
or
|
||||
this.named_group_start(start, end)
|
||||
this.namedGroupStart(start, end)
|
||||
or
|
||||
this.lookahead_assertion_start(start, end)
|
||||
this.lookaheadAssertionStart(start, end)
|
||||
or
|
||||
this.negative_lookahead_assertion_start(start, end)
|
||||
this.negativeLookaheadAssertionStart(start, end)
|
||||
or
|
||||
this.lookbehind_assertion_start(start, end)
|
||||
this.lookbehindAssertionStart(start, end)
|
||||
or
|
||||
this.negative_lookbehind_assertion_start(start, end)
|
||||
this.negativeLookbehindAssertionStart(start, end)
|
||||
or
|
||||
this.atomic_group_start(start, end)
|
||||
this.atomicGroupStart(start, end)
|
||||
or
|
||||
this.simple_group_start(start, end)
|
||||
this.simpleGroupStart(start, end)
|
||||
}
|
||||
|
||||
private predicate non_capturing_group_start(int start, int end) {
|
||||
private predicate nonCapturingGroupStart(int start, int end) {
|
||||
this.isGroupStart(start) and
|
||||
this.getChar(start + 1) = "?" and
|
||||
this.getChar(start + 2) = ":" and
|
||||
end = start + 3
|
||||
}
|
||||
|
||||
private predicate simple_group_start(int start, int end) {
|
||||
private predicate simpleGroupStart(int start, int end) {
|
||||
this.isGroupStart(start) and
|
||||
this.getChar(start + 1) != "?" and
|
||||
end = start + 1
|
||||
}
|
||||
|
||||
private predicate named_group_start(int start, int end) {
|
||||
private predicate namedGroupStart(int start, int end) {
|
||||
this.isGroupStart(start) and
|
||||
this.getChar(start + 1) = "?" and
|
||||
this.getChar(start + 2) = "<" and
|
||||
@@ -520,7 +520,7 @@ abstract class RegexString extends StringLiteral {
|
||||
)
|
||||
}
|
||||
|
||||
private predicate flag_group_start(int start, int end, string c) {
|
||||
private predicate flagGroupStart(int start, int end, string c) {
|
||||
this.isGroupStart(start) and
|
||||
this.getChar(start + 1) = "?" and
|
||||
end = start + 3 and
|
||||
@@ -533,7 +533,7 @@ abstract class RegexString extends StringLiteral {
|
||||
* it is defined by a prefix.
|
||||
*/
|
||||
string getModeFromPrefix() {
|
||||
exists(string c | this.flag_group_start(_, _, c) |
|
||||
exists(string c | this.flagGroupStart(_, _, c) |
|
||||
c = "i" and result = "IGNORECASE"
|
||||
or
|
||||
c = "m" and result = "MULTILINE"
|
||||
@@ -548,21 +548,21 @@ abstract class RegexString extends StringLiteral {
|
||||
)
|
||||
}
|
||||
|
||||
private predicate lookahead_assertion_start(int start, int end) {
|
||||
private predicate lookaheadAssertionStart(int start, int end) {
|
||||
this.isGroupStart(start) and
|
||||
this.getChar(start + 1) = "?" and
|
||||
this.getChar(start + 2) = "=" and
|
||||
end = start + 3
|
||||
}
|
||||
|
||||
private predicate negative_lookahead_assertion_start(int start, int end) {
|
||||
private predicate negativeLookaheadAssertionStart(int start, int end) {
|
||||
this.isGroupStart(start) and
|
||||
this.getChar(start + 1) = "?" and
|
||||
this.getChar(start + 2) = "!" and
|
||||
end = start + 3
|
||||
}
|
||||
|
||||
private predicate lookbehind_assertion_start(int start, int end) {
|
||||
private predicate lookbehindAssertionStart(int start, int end) {
|
||||
this.isGroupStart(start) and
|
||||
this.getChar(start + 1) = "?" and
|
||||
this.getChar(start + 2) = "<" and
|
||||
@@ -570,7 +570,7 @@ abstract class RegexString extends StringLiteral {
|
||||
end = start + 4
|
||||
}
|
||||
|
||||
private predicate negative_lookbehind_assertion_start(int start, int end) {
|
||||
private predicate negativeLookbehindAssertionStart(int start, int end) {
|
||||
this.isGroupStart(start) and
|
||||
this.getChar(start + 1) = "?" and
|
||||
this.getChar(start + 2) = "<" and
|
||||
@@ -578,7 +578,7 @@ abstract class RegexString extends StringLiteral {
|
||||
end = start + 4
|
||||
}
|
||||
|
||||
private predicate atomic_group_start(int start, int end) {
|
||||
private predicate atomicGroupStart(int start, int end) {
|
||||
this.isGroupStart(start) and
|
||||
this.getChar(start + 1) = "?" and
|
||||
this.getChar(start + 2) = ">" and
|
||||
@@ -586,13 +586,13 @@ abstract class RegexString extends StringLiteral {
|
||||
}
|
||||
|
||||
predicate groupContents(int start, int end, int in_start, int in_end) {
|
||||
this.group_start(start, in_start) and
|
||||
this.groupStart(start, in_start) and
|
||||
end = in_end + 1 and
|
||||
this.top_level(in_start, in_end) and
|
||||
this.topLevel(in_start, in_end) and
|
||||
this.isGroupEnd(in_end)
|
||||
}
|
||||
|
||||
private predicate named_backreference(int start, int end, string name) {
|
||||
private predicate namedBackreference(int start, int end, string name) {
|
||||
this.escapingChar(start) and
|
||||
this.getChar(start + 1) = "k" and
|
||||
this.getChar(start + 2) = "<" and
|
||||
@@ -600,7 +600,7 @@ abstract class RegexString extends StringLiteral {
|
||||
name = this.getText().substring(start + 3, end - 2)
|
||||
}
|
||||
|
||||
private predicate numbered_backreference(int start, int end, int value) {
|
||||
private predicate numberedBackreference(int start, int end, int value) {
|
||||
this.escapingChar(start) and
|
||||
// starting with 0 makes it an octal escape
|
||||
not this.getChar(start + 1) = "0" and
|
||||
@@ -626,16 +626,16 @@ abstract class RegexString extends StringLiteral {
|
||||
|
||||
/** Holds if the text in the range start,end is a back reference */
|
||||
predicate backreference(int start, int end) {
|
||||
this.numbered_backreference(start, end, _)
|
||||
this.numberedBackreference(start, end, _)
|
||||
or
|
||||
this.named_backreference(start, end, _)
|
||||
this.namedBackreference(start, end, _)
|
||||
}
|
||||
|
||||
/** Gets the number of the back reference in start,end */
|
||||
int getBackrefNumber(int start, int end) { this.numbered_backreference(start, end, result) }
|
||||
int getBackrefNumber(int start, int end) { this.numberedBackreference(start, end, result) }
|
||||
|
||||
/** Gets the name, if it has one, of the back reference in start,end */
|
||||
string getBackrefName(int start, int end) { this.named_backreference(start, end, result) }
|
||||
string getBackrefName(int start, int end) { this.namedBackreference(start, end, result) }
|
||||
|
||||
private predicate baseItem(int start, int end) {
|
||||
this.character(start, end) and
|
||||
@@ -651,17 +651,17 @@ abstract class RegexString extends StringLiteral {
|
||||
}
|
||||
|
||||
private predicate quantifier(int start, int end, boolean maybe_empty, boolean may_repeat_forever) {
|
||||
this.short_quantifier(start, end, maybe_empty, may_repeat_forever) and
|
||||
this.shortQuantifier(start, end, maybe_empty, may_repeat_forever) and
|
||||
not this.getChar(end) = ["?", "+"]
|
||||
or
|
||||
exists(int short_end |
|
||||
this.short_quantifier(start, short_end, maybe_empty, may_repeat_forever)
|
||||
this.shortQuantifier(start, short_end, maybe_empty, may_repeat_forever)
|
||||
|
|
||||
if this.getChar(short_end) = ["?", "+"] then end = short_end + 1 else end = short_end
|
||||
)
|
||||
}
|
||||
|
||||
private predicate short_quantifier(
|
||||
private predicate shortQuantifier(
|
||||
int start, int end, boolean maybe_empty, boolean may_repeat_forever
|
||||
) {
|
||||
(
|
||||
@@ -736,7 +736,7 @@ abstract class RegexString extends StringLiteral {
|
||||
private predicate subsequence(int start, int end) {
|
||||
(
|
||||
start = 0 or
|
||||
this.group_start(_, start) or
|
||||
this.groupStart(_, start) or
|
||||
this.isOptionDivider(start - 1)
|
||||
) and
|
||||
this.item(start, end)
|
||||
@@ -758,10 +758,10 @@ abstract class RegexString extends StringLiteral {
|
||||
|
||||
private predicate sequenceOrquantified(int start, int end) {
|
||||
this.subsequence(start, end) and
|
||||
not this.item_start(end)
|
||||
not this.itemStart(end)
|
||||
}
|
||||
|
||||
private predicate item_start(int start) {
|
||||
private predicate itemStart(int start) {
|
||||
this.character(start, _) or
|
||||
this.isGroupStart(start) or
|
||||
this.charSet(start, _) or
|
||||
@@ -769,7 +769,7 @@ abstract class RegexString extends StringLiteral {
|
||||
this.quote(start, _)
|
||||
}
|
||||
|
||||
private predicate item_end(int end) {
|
||||
private predicate itemEnd(int end) {
|
||||
this.character(_, end)
|
||||
or
|
||||
exists(int endm1 | this.isGroupEnd(endm1) and end = endm1 + 1)
|
||||
@@ -781,29 +781,29 @@ abstract class RegexString extends StringLiteral {
|
||||
this.quote(_, end)
|
||||
}
|
||||
|
||||
private predicate top_level(int start, int end) {
|
||||
private predicate topLevel(int start, int end) {
|
||||
this.subalternation(start, end, _) and
|
||||
not this.isOptionDivider(end)
|
||||
}
|
||||
|
||||
private predicate subalternation(int start, int end, int item_start) {
|
||||
private predicate subalternation(int start, int end, int itemStart) {
|
||||
this.sequenceOrquantified(start, end) and
|
||||
not this.isOptionDivider(start - 1) and
|
||||
item_start = start
|
||||
itemStart = start
|
||||
or
|
||||
start = end and
|
||||
not this.item_end(start) and
|
||||
not this.itemEnd(start) and
|
||||
this.isOptionDivider(end) and
|
||||
item_start = start
|
||||
itemStart = start
|
||||
or
|
||||
exists(int mid |
|
||||
this.subalternation(start, mid, _) and
|
||||
this.isOptionDivider(mid) and
|
||||
item_start = mid + 1
|
||||
itemStart = mid + 1
|
||||
|
|
||||
this.sequenceOrquantified(item_start, end)
|
||||
this.sequenceOrquantified(itemStart, end)
|
||||
or
|
||||
not this.item_start(end) and end = item_start
|
||||
not this.itemStart(end) and end = itemStart
|
||||
)
|
||||
}
|
||||
|
||||
@@ -811,7 +811,7 @@ abstract class RegexString extends StringLiteral {
|
||||
* Holds if the text in the range start,end is an alternation
|
||||
*/
|
||||
predicate alternation(int start, int end) {
|
||||
this.top_level(start, end) and
|
||||
this.topLevel(start, end) and
|
||||
exists(int less | this.subalternation(start, less, _) and less < end)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user