@@ -120,7 +120,7 @@ public class CSharpToCppTransformer : TextTransformer
120120 ( new Regex ( @"(?<access>(private|protected|public): )?abstract (?<method>[^;\r\n]+);" ) , "${access}virtual ${method} = 0;" , 0 ) ,
121121 // TElement GetFirst();
122122 // virtual TElement GetFirst() = 0;
123- ( new Regex ( @"([\r\n]+[ ]+)((?!return)[a-zA-Z0-9]+ [a-zA-Z0-9]+\([^\)\r\n]*\))(;[ ]*[\r\n]+)" ) , "$1virtual $2 = 0$3 " , 1 ) ,
123+ ( new Regex ( @"(?<before> [\r\n]+[ ]+)(?<methodDeclaration> (?!return)[a-zA-Z0-9]+ [a-zA-Z0-9]+\([^\)\r\n]*\))(?<after> ;[ ]*[\r\n]+)" ) , "${before}virtual ${methodDeclaration} = 0${after} " , 1 ) ,
124124 // protected: readonly TreeElement[] _elements;
125125 // protected: TreeElement _elements[N];
126126 ( new Regex ( @"(?<access>(private|protected|public): )?readonly (?<type>[a-zA-Z<>0-9]+)([\[\]]+) (?<name>[_a-zA-Z0-9]+);" ) , "${access}${type} ${name}[N];" , 0 ) ,
@@ -186,7 +186,7 @@ public class CSharpToCppTransformer : TextTransformer
186186 ( new Regex ( @"(?<before>return\s*)\((?<values>[^\)\n]+)\)(?!\()(?<after>\W)" ) , "${before}{${values}}${after}" , 0 ) ,
187187 // string
188188 // std::string
189- ( new Regex ( @"(\W)(?<!::)string(\W)" ) , "$1std ::string$2 " , 0 ) ,
189+ ( new Regex ( @"(?<before> \W)(?<!::)string(?<after> \W)" ) , "${before}std ::string${after} " , 0 ) ,
190190 // System.ValueTuple
191191 // std::tuple
192192 ( new Regex ( @"(?<before>\W)(System\.)?ValueTuple(?!\s*=|\()(?<after>\W)" ) , "${before}std::tuple${after}" , 0 ) ,
@@ -234,7 +234,7 @@ public class CSharpToCppTransformer : TextTransformer
234234 ( new Regex ( @"(struct|class) ([a-zA-Z0-9]+)(\s+){([\sa-zA-Z0-9;:_]+?)}([^;])" ) , "$1 $2$3{$4};$5" , 0 ) ,
235235 // class Program { }
236236 // class Program { };
237- ( new Regex ( @"(struct|class) ([a-zA-Z0-9]+[^\r\n]*)([\r\n]+(?<indentLevel>[\t ]*)?)\{([\S\s]+?[\r\n]+\k<indentLevel>)\}([^;]|$)" ) , "$1 $2$3{$4};$5 " , 0 ) ,
237+ ( new Regex ( @"(?<type> struct|class) (?<name> [a-zA-Z0-9]+[^\r\n]*)(?<beforeBody> [\r\n]+(?<indentLevel>[\t ]*)?)\{(?<body> [\S\s]+?[\r\n]+\k<indentLevel>)\}(?<afterBody> [^;]|$)" ) , "${type} ${name}${beforeBody}{${body}};${afterBody} " , 0 ) ,
238238 // class SizedBinaryTreeMethodsBase : GenericCollectionMethodsBase
239239 // class SizedBinaryTreeMethodsBase : public GenericCollectionMethodsBase
240240 ( new Regex ( @"(struct|class) ([a-zA-Z0-9]+)(<[a-zA-Z0-9 ,]+>)? : ([a-zA-Z0-9]+)" ) , "$1 $2$3 : public $4" , 0 ) ,
@@ -282,7 +282,7 @@ public class CSharpToCppTransformer : TextTransformer
282282 ( new Regex ( @"class ([a-zA-Z0-9]+Tests)" ) , "TEST_CLASS($1)" , 0 ) ,
283283 // Assert.Equal
284284 // Assert::AreEqual
285- ( new Regex ( @"(Assert)\.((Not)?Equal)" ) , "$1 ::Are$2 " , 0 ) ,
285+ ( new Regex ( @"(?<type> Assert)\.(?<method> (Not)?Equal)" ) , "${type} ::Are${method} " , 0 ) ,
286286 // Assert.Throws
287287 // Assert::ExpectException
288288 ( new Regex ( @"(Assert)\.Throws" ) , "$1::ExpectException" , 0 ) ,
@@ -303,7 +303,7 @@ public class CSharpToCppTransformer : TextTransformer
303303 ( new Regex ( @"Console\.WriteLine\(""([^""\r\n]+)""\)" ) , "printf(\" $1\\ n\" )" , 0 ) ,
304304 // TElement Root;
305305 // TElement Root = 0;
306- ( new Regex ( @"(\r?\n[\t ]+)(private|protected|public)? (: )?( [a-zA-Z0-9:_]+(?<!return)) ([_a-zA-Z0-9]+);" ) , "$1$2$3$4 $5 = 0;" , 0 ) ,
306+ ( new Regex ( @"(?<before> \r?\n[\t ]+)(?<access>( private|protected|public)(: )?)?(?<type> [a-zA-Z0-9:_]+(?<!return)) (?<name> [_a-zA-Z0-9]+);" ) , "${before}${access}${type} ${name} = 0;" , 0 ) ,
307307 // TreeElement _elements[N];
308308 // TreeElement _elements[N] = { {0} };
309309 ( new Regex ( @"(\r?\n[\t ]+)(private|protected|public)?(: )?([a-zA-Z0-9]+) ([_a-zA-Z0-9]+)\[([_a-zA-Z0-9]+)\];" ) , "$1$2$3$4 $5[$6] = { {0} };" , 0 ) ,
0 commit comments