Merge pull request #6816 from Nirvikalpa108/fix-6802

Fixes parsing command args that include quotes but don't start with them
This commit is contained in:
eugene yokota 2022-02-04 14:42:22 -05:00 committed by GitHub
commit c7f2c046b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -202,7 +202,7 @@ trait Parsers {
* Parses a potentially quoted String value. The value may be verbatim quoted ([[StringVerbatim]]),
* quoted with interpreted escapes ([[StringEscapable]]), or unquoted ([[NotQuoted]]).
*/
lazy val StringBasic = StringVerbatim | StringEscapable | NotQuoted
lazy val StringBasic = StringVerbatim | StringEscapable | NotQuoted | NotQuotedThenQuoted
/**
* Parses a verbatim quoted String value, discarding the quotes in the result. This kind of quoted text starts with triple quotes `"""`
@ -270,6 +270,11 @@ trait Parsers {
/** Parses an unquoted, non-empty String value that cannot start with a double quote and cannot contain whitespace.*/
lazy val NotQuoted = (NotDQuoteSpaceClass ~ OptNotSpace) map { case (c, s) => c.toString + s }
/** Parses a non-empty String value that cannot start with a double quote, but includes double quotes.*/
lazy val NotQuotedThenQuoted = (NotQuoted ~ StringEscapable) map {
case (s1, s2) => s"""$s1\"$s2\""""
}
/**
* Applies `rep` zero or more times, separated by `sep`.
* The result is the (possibly empty) sequence of results from the multiple `rep` applications. The `sep` results are discarded.

View File

@ -119,6 +119,8 @@ object ParserTest extends Properties("Completing Parser") {
property("repeatDep requires at least one token") = !matches(repeat, "")
property("repeatDep accepts one token") = matches(repeat, colors.toSeq.head)
property("repeatDep accepts two tokens") = matches(repeat, colors.toSeq.take(2).mkString(" "))
property("parses string that doesn't start with quotes, but includes quotes within it") =
matches(StringBasic, "-Dsilicon:z3ConfigArgs=\"model=true model_validate=true\"")
}
object ParserExample {
val ws = charClass(_.isWhitespace, "whitespace").+