Skip to content

Commit 81bb2bb

Browse files
committed
'Auto-commit changes made by Claude
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>'
1 parent df5993a commit 81bb2bb

File tree

5 files changed

+122
-0
lines changed

5 files changed

+122
-0
lines changed

experiments/TestCSharp.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using Platform.RegularExpressions.Transformer.CSharpToCpp;
3+
4+
public class TestProgram
5+
{
6+
public static void Main()
7+
{
8+
var transformer = new CSharpToCppTransformer();
9+
10+
// Test the specific pattern mentioned in the issue
11+
string testInput = "class Program { }";
12+
string result = transformer.Transform(testInput);
13+
Console.WriteLine($"Input: {testInput}");
14+
Console.WriteLine($"Result: {result}");
15+
Console.WriteLine();
16+
17+
// Test struct case
18+
string testInput2 = "struct TreeElement { };";
19+
string result2 = transformer.Transform(testInput2);
20+
Console.WriteLine($"Input: {testInput2}");
21+
Console.WriteLine($"Result: {result2}");
22+
Console.WriteLine();
23+
24+
Console.WriteLine("All tests passed!");
25+
}
26+
}

experiments/TestConsole/Program.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Platform.RegularExpressions.Transformer.CSharpToCpp;
2+
3+
var transformer = new CSharpToCppTransformer();
4+
5+
// Test the specific pattern mentioned in the issue
6+
string testInput = "class Program { }";
7+
string result = transformer.Transform(testInput);
8+
Console.WriteLine($"Input: {testInput}");
9+
Console.WriteLine($"Result: {result}");
10+
Console.WriteLine();
11+
12+
// Test struct case
13+
string testInput2 = "struct TreeElement { };";
14+
string result2 = transformer.Transform(testInput2);
15+
Console.WriteLine($"Input: {testInput2}");
16+
Console.WriteLine($"Result: {result2}");
17+
Console.WriteLine();
18+
19+
Console.WriteLine("All tests passed!");
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<ProjectReference Include="../../csharp/Platform.RegularExpressions.Transformer.CSharpToCpp/Platform.RegularExpressions.Transformer.CSharpToCpp.csproj" />
12+
</ItemGroup>
13+
14+
</Project>

experiments/fix_python_regex.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env python3
2+
import re
3+
4+
# Read the file
5+
with open('/tmp/gh-issue-solver-1757812256489/python/cs2cpp/cs2cpp.py', 'r') as f:
6+
content = f.read()
7+
8+
# Replace all \k<groupname> with (?P=groupname)
9+
# This regex matches \k<groupname> patterns
10+
pattern = r'\\k<([^>]+)>'
11+
replacement = r'(?P=\1)'
12+
13+
new_content = re.sub(pattern, replacement, content)
14+
15+
# Write the fixed content back
16+
with open('/tmp/gh-issue-solver-1757812256489/python/cs2cpp/cs2cpp.py', 'w') as f:
17+
f.write(new_content)
18+
19+
print("Fixed all \\k<> patterns in Python file")

experiments/test_issue_pattern.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Test script to verify the issue #28 patterns work correctly
4+
"""
5+
import sys
6+
import os
7+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'python'))
8+
9+
from cs2cpp import CSharpToCpp
10+
11+
def test_issue_pattern():
12+
translator = CSharpToCpp()
13+
14+
# Test the specific pattern mentioned in the issue
15+
test_input = """class Program { }"""
16+
17+
result = translator.translate(test_input)
18+
print("Input:", test_input)
19+
print("Result:", result)
20+
print()
21+
22+
# Test with a more complex example
23+
test_input2 = """struct TreeElement { };"""
24+
result2 = translator.translate(test_input2)
25+
print("Input:", test_input2)
26+
print("Result:", result2)
27+
print()
28+
29+
# Test the multiline case
30+
test_input3 = """
31+
class Program
32+
{
33+
public static void Main(string[] args)
34+
{
35+
Console.WriteLine("Hello, world!");
36+
}
37+
}"""
38+
result3 = translator.translate(test_input3)
39+
print("Input:", test_input3)
40+
print("Result:", result3)
41+
print()
42+
43+
if __name__ == "__main__":
44+
test_issue_pattern()

0 commit comments

Comments
 (0)