This commit is contained in:
Бондарев Иван 2018-09-02 12:25:14 +02:00
parent e7bac00673
commit 96e1454511
2 changed files with 34 additions and 1 deletions

View file

@ -431,7 +431,12 @@ namespace GPPGParserScanner
while (match.Success)
{
string s = match.Value.Replace("{", "").Replace("}", "");
int colon_pos = s.IndexOf(':');
int colon_pos = s.LastIndexOf(':');
int comma_pos = s.LastIndexOf(',');
int bracket_pos = s.LastIndexOf(')');
int sqbracked_pos = s.LastIndexOf(']');
if (comma_pos != -1 && comma_pos > bracket_pos && comma_pos > sqbracked_pos)
colon_pos = comma_pos;
if (colon_pos != -1 && s.IndexOf('?') == -1)
{
var_formats.Add(ind, s.Substring(colon_pos));

View file

@ -0,0 +1,28 @@
begin
var a := 3.1;
var s := $'{a,6:F2}';
var s2 := string.Format('{0,6:F2}',a);
assert(s = s2);
s := $'{a,-10}';
s2 := string.Format('{0,-10}', a);
assert(s = s2);
s := $'a is {a,6:N2}';
s2 := string.Format('a is {0,6:N2}',a);
assert(s = s2);
s := $'{Min(2,3),-5:F2}';
s2 := string.Format('{0,-5:F2}', Min(2,3));
assert(s = s2);
s := $'{Min(2,3):F2}';
s2 := string.Format('{0:F2}', Min(2,3));
assert(s = s2);
var arr1 := Arr(1,2,3);
s := $'{arr1[2],-5:F2}';
s2 := string.Format('{0,-5:F2}', arr1[2]);
var arr2 := new integer[2,2];
s := $'{arr2[0,0],-5:F2}';
s2 := string.Format('{0,-5:F2}', arr2[0,0]);
assert(s = s2);
s := $'{arr2[0,0]}';
s2 := string.Format('{0}', arr2[0,0]);
assert(s = s2);
end.