diff --git a/Parsers/PascalABCParserNewSaushkin/SemanticRules.cs b/Parsers/PascalABCParserNewSaushkin/SemanticRules.cs index c2b344d98..f0250a1e0 100644 --- a/Parsers/PascalABCParserNewSaushkin/SemanticRules.cs +++ b/Parsers/PascalABCParserNewSaushkin/SemanticRules.cs @@ -414,8 +414,9 @@ namespace GPPGParserScanner mc.parameters = new expression_list(); //string[] arr = Regex.Split(str.Value, @"\{[\w\d._]+\}"); //Match match = Regex.Match(str.Value, @"\{[\w\d._]+\}"); - string[] arr = Regex.Split(str.Value, @"\{[^\}]+\}"); - Match match = Regex.Match(str.Value, @"\{[^\}]+\}"); + string val = str.Value.Replace("{{","![&").Replace("}}}","}&]!").Replace("}}", "&]!"); + string[] arr = Regex.Split(val, @"\{[^\}]+\}"); + Match match = Regex.Match(val, @"\{[^\}]+\}"); List vars = new List(); //Dictionary var_offsets = new Dictionary(); List var_offsets = new List(); @@ -435,7 +436,7 @@ namespace GPPGParserScanner StringBuilder sb = new StringBuilder(); for (int i = 0; i < arr.Length; i++) { - sb.Append(arr[i]); + sb.Append(arr[i].Replace("![&", "{{").Replace("&]!", "}}")); if (i < arr.Length - 1) sb.Append("{" + i + "}"); } diff --git a/TestSuite/formatstring3.pas b/TestSuite/formatstring3.pas new file mode 100644 index 000000000..4efe70f29 --- /dev/null +++ b/TestSuite/formatstring3.pas @@ -0,0 +1,11 @@ +begin + var a := 2; + var b := 3; + var c := 4; + var s := $'Hello {{{{{a}}}}}'; + assert(s = 'Hello {{2}}'); + s := $'{{{a}}},{b},{c}'; + assert(s = '{2},3,4'); + s := $'{a+1},{b+1},{c+1}'; + assert(s = '3,4,5'); +end. \ No newline at end of file