Merge pull request #2468 from max-schaefer/js/regexp-predecessor

Approved by asgerf
This commit is contained in:
semmle-qlci
2019-11-28 16:57:31 +00:00
committed by GitHub
5 changed files with 14 additions and 12 deletions

View File

@@ -73,21 +73,21 @@ class RegExpTerm extends Locatable, @regexpterm {
/** Holds if this regular expression term can match the empty string. */
predicate isNullable() { none() } // Overridden in subclasses.
/** Gets the regular expression term that is matched before this one, if any. */
/** Gets the regular expression term that is matched (textually) before this one, if any. */
RegExpTerm getPredecessor() {
exists(RegExpSequence seq, int i |
seq.getChild(i) = this and
seq.getChild(i - getDirection()) = result
seq.getChild(i - 1) = result
)
or
result = getParent().(RegExpTerm).getPredecessor()
}
/** Gets the regular expression term that is matched after this one, if any. */
/** Gets the regular expression term that is matched (textually) after this one, if any. */
RegExpTerm getSuccessor() {
exists(RegExpSequence seq, int i |
seq.getChild(i) = this and
seq.getChild(i + getDirection()) = result
seq.getChild(i + 1) = result
)
or
exists(RegExpTerm parent |
@@ -98,12 +98,6 @@ class RegExpTerm extends Locatable, @regexpterm {
)
}
/**
* Gets the matching direction of this term: `1` if it is in a forward-matching
* context, `-1` if it is in a backward-matching context.
*/
private int getDirection() { if isInBackwardMatchingContext() then result = -1 else result = 1 }
/**
* Holds if this regular term is in a forward-matching context, that is,
* it has no enclosing lookbehind assertions.