support TCEC non-standard PGN clock format

report-discarder
Thibault Duplessis 2017-10-14 09:55:28 -05:00
parent afd77a6a29
commit 79d9f04357
2 changed files with 7 additions and 0 deletions

View File

@ -12,6 +12,8 @@ private[study] object CommentParser {
private val arrowsRemoveRegex = """\[\%cal[\s\r\n]+((?:\w{5}[,\s]*)+)\]""".r
private val clockRegex = """(?s).*\[\%clk[\s\r\n]+([\d:\.]+)\].*""".r
private val clockRemoveRegex = """\[\%clk[\s\r\n]+[\d:\.]+\]""".r
private val tcecClockRegex = """(?s).*tl=([\d:\.]+).*""".r
private val tcecClockRemoveRegex = """tl=[\d:\.]+""".r
case class ParsedComment(
shapes: Shapes,
@ -45,6 +47,7 @@ private[study] object CommentParser {
private def parseClock(comment: String): ClockAndComment = comment match {
case clockRegex(str) => readCentis(str) -> clockRemoveRegex.replaceAllIn(comment, "").trim
case tcecClockRegex(str) => readCentis(str) -> tcecClockRemoveRegex.replaceAllIn(comment, "").trim
case _ => None -> comment
}

View File

@ -65,6 +65,10 @@ class CommentParserTest extends Specification {
"alt format" in {
C("Hello there [%clk 2:10.33] something else").clock must_== Some(Centis(783300))
}
"TCEC" in {
C("d=29, pd=Bb7, mt=00:01:01, tl=00:37:47, s=27938 kN/s, n=1701874274, pv=e4 Bb7 exf5 exf5 d5 Qf6 Rab1 Rae8 g3 Bc8 Kg2 Rxe1 Rxe1, tb=0, R50=49, wv=0.45,").clock must_==
Some(Centis(100 * 47 + 37 * 60 * 100))
}
}
"parse shapes" should {
"empty" in {