create-sysy-testcase
БесплатноЗапускает вложенные скриптыНе проверенConvert C/C++ code into Strict SysY testcases using Python automation scripts.
Об этом скилле
SysY Testcase Conversion Workflow
You are an expert compiler engineer. Your goal is to convert standard C/C++ competitive programming code into Strict SysY (a simplified C subset) and generate valid test data.
Non-Negotiable Grammar Rules
Adhere to these rules strictly. Read references/sysy_lang_grammar.md only if you encounter an obscure syntax edge case not covered here.
| Feature | Constraint | Fix / Refactor |
|---|---|---|
| Prototypes | Implicit | Do NOT write int getint(); or int printf(...);. |
| Memory / Size | Max 4MB Total (MARS Limit) | Scale Down Constants. 1e6 $\to$ 1e4. Total int elements < 500,000. |
| Preprocessor | BANNED (#include, #define, #ifdef) |
Use const int for constants. Delete imports. |
| Types | int, void ONLY |
No long long, float, double, char, bool. |
| Pointers | BANNED (int *p, &x, *ptr) |
Pass arrays as int a[]. Use return values for scalar outputs (no void f(int *res)). |
| Arrays | 1D Arrays ONLY | Flatten int a[N][M] $\to$ int a[N*M]. No VLAs. |
| Loops | for loops ONLY. No declarations inside () |
Move vars out: int i; for(i=0;...). No do-while. No while. turn while(1) into for(;;). |
| Returns | Non-void funcs MUST return | Add dummy return 0; at end of function, even after infinite loops. |
| Conditions As Values | Exp → AddExp (arithmetic only) |
Do NOT use relational / logical expressions as values, e.g. return a < b; or x = (a < b);. Rewrite: if (a < b) return 1; return 0; or x = 0; if (a < b) x = 1;. |
| Input | int getint() ONLY |
No scanf, cin, getchar. |
| Output | printf ONLY |
Format string is a SysY StringConst: only %d is allowed as a format placeholder, and the only escape sequence is \n (backslash may appear only in \n). No other format specifiers/modifiers (e.g. %c, %s, %%, %05d) and no other escapes (e.g. \\, \", \t, \r, \0). Ensure the number of , Exp arguments equals the number of %d. |
| Parentheses | PrimaryExp → '(' Exp ')' and Exp → AddExp |
(...) as an expression can wrap arithmetic only. Besides mandatory syntax like if (Cond) / for (...; Cond; ...), do NOT add extra parentheses around conditions (any `== != < > <= >= && |
| Operators | No Bitwise (<<, >>, &, ` |
, ^`) |
| Structs | BANNED | Split into parallel arrays (e.g., x[N], y[N]). |
| Globals | Encouraged for large arrays | Prevent stack overflow in SysY runtime, keep totol size < 4MB. |
| Input Data | Strictly 1 Integer Per Line (in.txt) |
No spaces (1 2). Must be 1\n2. Matches MIPS syscall. If testfile.txt uses a sentinel to stop reading (e.g., if (ch == 0) break;, while (x != 0), while (1) { x=getint(); if (x==0) break; }), then in.txt must explicitly include that sentinel value as the last integer. Do not rely on EOF behaving like 0: SysY MIPS getint() is implemented via syscall 5 and does not implement “EOF → 0”. |
Execution Protocol
Follow these steps sequentially.
Step 1: Initialize
Use the helper script to create the directory and placeholder files.
python3 .codex/skills/create-sysy-testcase/scripts/init_case.py <TARGET_DIR>
Step 2: Write Logic (The Intelligence Part)
Translate the source logic into Strict SysY. Focus your "thinking" here.
- Scale Down: If original code has
MAXN = 100000, change it smaller to fix up to MARS's address space limit(about 4MB). Ensure logic consistency. - Refactor logic to fit the constraints above (e.g., flatten 2D arrays).
- Write the code to
testfile.txt. - Write input data to
in.txt(newline-separated integers only) matching your scaled-down size. If the program reads until a sentinel (e.g.,0) rather than a known count, put that sentinel explicitly as the last integer; do not rely on EOF.
cat <<'EOF' > <TARGET_DIR>/testfile.txt
// ... your converted SysY code ...
EOF
cat <<'EOF' > <TARGET_DIR>/in.txt
// ... your input numbers ...
EOF
Step 3: Compile, Run & Verify
Use the runner script. It automatically wraps your code with C headers, compiles it (gcc/clang), runs it against in.txt, and generates ans.txt.
python3 .codex/skills/create-sysy-testcase/scripts/run_case.py <TARGET_DIR>
Step 4: Fix & Retry
If Step 3 reports a COMPILE ERROR or RUNTIME ERROR:
- Read the error output.
- Fix the logic in
testfile.txt. - Rerun Step 3.
Translation Strategy Tips
- SysY input (
in.txt) must be newline-separated integers. - If the original problem uses strings (e.g., "PUSH", "POP"
Установить create-sysy-testcase в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл create-sysy-testcase?
Convert C/C++ code into Strict SysY testcases using Python automation scripts.
Как установить скилл create-sysy-testcase?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл create-sysy-testcase запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic