diff --git a/Parsers/PascalABCParserNewSaushkin/SemanticRules.cs b/Parsers/PascalABCParserNewSaushkin/SemanticRules.cs index b0661c413..2b48ab4ef 100644 --- a/Parsers/PascalABCParserNewSaushkin/SemanticRules.cs +++ b/Parsers/PascalABCParserNewSaushkin/SemanticRules.cs @@ -489,11 +489,21 @@ namespace GPPGParserScanner } } + string str2 = sb.ToString(); if (str2.Trim().EndsWith("{")) { - parsertools.errors.Add(new bad_format_string(parsertools.CurrentFileName, str.source_context, str)); - return str; + int cnt = 0; + string tmp = str2.Trim(); + for (var i = 0; i < tmp.Length; i++) + if (tmp[i] == '{') + cnt++; + if (cnt % 2 == 1) + { + parsertools.errors.Add(new bad_format_string(parsertools.CurrentFileName, str.source_context, str)); + return str; + } + } mc.parameters.Add(new string_const(str2, str.source_context), str.source_context); for (int i = 0; i < vars.Count; i++) diff --git a/TestSuite/errors/err0519_format_string.pas b/TestSuite/errors/err0519_format_string.pas new file mode 100644 index 000000000..0b89595c4 --- /dev/null +++ b/TestSuite/errors/err0519_format_string.pas @@ -0,0 +1,3 @@ +begin + var s := $'{{{'; +end. \ No newline at end of file diff --git a/TestSuite/formatstring9.pas b/TestSuite/formatstring9.pas new file mode 100644 index 000000000..a532d2f2d --- /dev/null +++ b/TestSuite/formatstring9.pas @@ -0,0 +1,6 @@ +begin + var s := $'{{'; + assert(s = '{'); + s := $'{{{{'; + assert(s = '{{'); +end. \ No newline at end of file