Skip to content

Commit

Permalink
saved
Browse files Browse the repository at this point in the history
  • Loading branch information
andygrove committed May 24, 2022
1 parent 72d3ffd commit 4063aaf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ class CudfRegexTranspiler(mode: RegexMode) {
// println("everything is fine")
}

def foo(regex: RegexAST): Unit = {
def checkEndAnchorNearNewline(regex: RegexAST): Unit = {
regex match {
case RegexSequence(parts) =>
parts.indices.foreach { i =>
Expand All @@ -779,16 +779,16 @@ class CudfRegexTranspiler(mode: RegexMode) {
}
}
case RegexChoice(l, r) =>
foo(l)
foo(r)
case RegexGroup(_, term) => foo(term)
case RegexRepetition(ast, _) => foo(ast)
checkEndAnchorNearNewline(l)
checkEndAnchorNearNewline(r)
case RegexGroup(_, term) => checkEndAnchorNearNewline(term)
case RegexRepetition(ast, _) => checkEndAnchorNearNewline(ast)
case _ =>
// ignore
}
}

foo(regex)
checkEndAnchorNearNewline(regex)

rewrite(regex, replacement, previous)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,11 @@ class RegularExpressionTranspilerSuite extends FunSuite with Arm {
}

test("fall back to CPU for newline next to line or string anchor") {
// these patterns were discovered during fuzz testing and resulted in different
// results between CPU and GPU
val patterns = Seq(raw"\w[\r,B]\Z", raw"\s\Z\Z", "^$\\s", "$x*\\r", "$\\r")
for (mode <- Seq(RegexFindMode, RegexReplaceMode)) {
patterns.foreach(pattern => {
println(pattern)
assertUnsupported(pattern, mode,
"End of line/string anchor is not supported in this context")
})
Expand Down

0 comments on commit 4063aaf

Please sign in to comment.