Skip to content

Commit

Permalink
bugfix for a bug with - in a regex (#539)
Browse files Browse the repository at this point in the history
bugfix for a bug with - in a regex
  • Loading branch information
konnov authored Feb 3, 2021
1 parent a1c30ac commit b3faa66
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@

* Boolean values are now supported in TLC config files, see #512
* Proper error on invalid type annotations, the parser is strengthened with Scalacheck, see #332
* Fixed a parsing bug for strings that contain '-', see #539
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ object TlcConfigLexer extends RegexParsers {
}

private def string: Parser[STRING] = {
""""[a-zA-Z0-9_~!@#\\$%^&*-+=|(){}\[\],:;`'<>.?/ ]*"""".r ^^ { name => STRING(name.substring(1, name.length - 1)) }
""""[a-zA-Z0-9_~!@#\\$%^&*\-+=|(){}\[\],:;`'<>.?/ ]*"""".r ^^ { name => STRING(name.substring(1, name.length - 1)) }
}

private def number: Parser[NUMBER] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,23 @@ class TestTlcConfigParserApalache extends FunSuite {
assert(config.constReplacements.isEmpty)
}

test("CONSTANTS bug with minus in [...]") {
// a regression test
val text =
"""
|CONSTANTS
|ChainIds = {"Chain-A", "Chain-B"}
|INIT Init
|NEXT Next
""".stripMargin

val config = TlcConfigParserApalache(text)
assert(
config.constAssignments ==
Map("ChainIds" -> ConfigSetValue(ConfigStrValue("Chain-A"), ConfigStrValue("Chain-B"))))
assert(config.constReplacements.isEmpty)
}

test("CONSTANT assignments and SYMMETRY") {
val text =
"""
Expand Down

0 comments on commit b3faa66

Please sign in to comment.