Skip to content

Commit fa738c9

Browse files
refactoring
1 parent 2e6c8fd commit fa738c9

File tree

13 files changed

+597
-64
lines changed

13 files changed

+597
-64
lines changed

code2logic/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
>>> print(output)
1919
"""
2020

21-
__version__ = "1.0.25"
21+
__version__ = "1.0.27"
2222
__author__ = "Softreck"
2323
__email__ = "info@softreck.dev"
2424
__license__ = "MIT"

code2logic/analyzer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class ProjectAnalyzer:
5252
'.java': 'java',
5353
'.go': 'go',
5454
'.rs': 'rust',
55+
'.cs': 'csharp',
5556
'.c': 'cpp',
5657
'.cpp': 'cpp',
5758
'.cc': 'cpp',

code2logic/benchmarks/common.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -174,19 +174,16 @@ def get_async_reproduction_prompt(spec: str, fmt: str, file_name: str, with_test
174174
return prompt
175175

176176

177-
def get_token_reproduction_prompt(spec: str, fmt: str, file_name: str) -> str:
177+
def get_token_reproduction_prompt(spec: str, fmt: str, file_name: str, language: str = "python") -> str:
178178
format_hints = {
179179
"json": "Parse the JSON structure and implement all classes and functions.",
180180
"json_compact": "Parse the compact JSON and implement all elements.",
181181
"yaml": "Parse the YAML structure and implement all classes and functions with exact signatures.",
182-
"gherkin": "Implement scenarios as SIMPLE, MINIMAL Python code. NO extra error classes, NO over-engineering. Keep code short and direct.",
182+
"gherkin": "Implement scenarios as SIMPLE, MINIMAL code. NO over-engineering. Keep code short and direct.",
183183
"markdown": "Parse embedded Gherkin (behaviors) and YAML (structures).",
184-
"logicml": """Parse LogicML and generate VALID Python code:
185-
- 'sig: (params) -> Type' = def func(params) -> Type
186-
- 'sig: async (params)' = async def func(params)
187-
- 'sig: @property (self)' = @property decorator
188-
- 'bases: [BaseModel]' = class X(BaseModel) with Field()
189-
- 'type: re-export' = from .module import X
184+
"logicml": """Parse LogicML and generate VALID code:
185+
- 'sig:' lines describe function signatures (translate to the target language)
186+
- 'type: re-export' means this module primarily re-exports symbols
190187
CRITICAL: Ensure valid syntax - balanced brackets, proper indentation, no undefined variables.""",
191188
"toon": """Parse TOON (Token-Oriented Object Notation) format carefully:
192189
@@ -211,17 +208,30 @@ def get_token_reproduction_prompt(spec: str, fmt: str, file_name: str) -> str:
211208
max_spec = 5000
212209
spec_truncated = spec[:max_spec] if len(spec) > max_spec else spec
213210

214-
prompt = f"""Generate Python code from this {fmt.upper()} specification.
211+
language_norm = (language or "python").strip().lower()
212+
lang_label_map = {
213+
"python": "Python",
214+
"javascript": "JavaScript",
215+
"typescript": "TypeScript",
216+
"go": "Go",
217+
"rust": "Rust",
218+
"java": "Java",
219+
"csharp": "C#",
220+
"sql": "SQL",
221+
}
222+
lang_label = lang_label_map.get(language_norm, language_norm)
223+
224+
prompt = f"""Generate {lang_label} code from this {fmt.upper()} specification.
215225
{format_hints.get(fmt, '')}
216226
217227
{spec_truncated}
218228
219229
Requirements:
220-
- Complete, working Python code for {file_name}
230+
- Complete, working {lang_label} code for {file_name}
221231
- Include imports and type hints
222232
- Implement all functions with actual logic
223233
224-
```python
234+
```{language_norm}
225235
"""
226236
return prompt
227237

0 commit comments

Comments
 (0)