jpskill.com
📦 その他 コミュニティ

cs-compilers

Compilers: lexing, parsing LL/LR/PEG, AST, semantic analysis, code gen LLVM, optimization, tree-sitter

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o cs-compilers.zip https://jpskill.com/download/22160.zip && unzip -o cs-compilers.zip && rm cs-compilers.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/22160.zip -OutFile "$d\cs-compilers.zip"; Expand-Archive "$d\cs-compilers.zip" -DestinationPath $d -Force; ri "$d\cs-compilers.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して cs-compilers.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → cs-compilers フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1
📖 Claude が読む原文 SKILL.md(中身を展開)

この本文は AI(Claude)が読むための原文(英語または中国語)です。日本語訳は順次追加中。

cs-compilers

Purpose

This skill equips the AI to handle compiler-related tasks, including lexing, parsing (LL/LR/PEG), building ASTs, semantic analysis, code generation with LLVM, optimizations, and integration with Tree-sitter for real-time parsing.

When to Use

Use this skill when developing compilers, analyzing source code, debugging parsers, generating optimized machine code, or integrating parsing into tools like IDEs. Apply it for tasks involving code transformation, such as transpiling or static analysis in programming languages.

Key Capabilities

  • Lexing: Tokenize input using regex; e.g., define patterns like r'\b(int|float)\b' for keywords in a lexer.
  • Parsing: Implement LL(1) with recursive descent or LR(1) via tools like yacc; use PEG with libraries like packrat; integrate Tree-sitter for efficient parsing, e.g., load a language grammar with tree_sitter.Language.build('path/to/tree-sitter-javascript.wasm').
  • AST Handling: Build and manipulate ASTs; traverse nodes for analysis, e.g., use Tree-sitter's cursor: cursor = tree.walk(); while cursor.goto_first_child(): process_node(cursor).
  • Semantic Analysis: Perform type checking and scope resolution; e.g., check variable declarations against usage in a symbol table.
  • Code Generation: Generate LLVM IR; use the LLVM C++ API to create modules, e.g., LLVMModuleCreateWithName("MyModule") then add functions.
  • Optimization: Apply passes like constant propagation or dead code elimination; e.g., run LLVM's opt tool with flags like -O3 for aggressive optimization.
  • Tree-sitter Integration: Parse code in real-time; supports languages like C, Python via pre-built grammars.

Usage Patterns

Invoke this skill via OpenClaw CLI for direct commands or SDK for programmatic access. Always specify the action and parameters as JSON. For CLI, use: openclaw invoke cs-compilers --action <action> --params '<JSON string>'. In code, import the SDK and call: from openclaw import Client; client = Client(api_key=os.environ['OPENCLAW_API_KEY']); response = client.invoke('cs-compilers', {'action': 'parse', 'params': {'language': 'c', 'code': 'int main(){}'}}). Structure params as a dictionary with keys like "language" and "code". If using external tools, ensure dependencies (e.g., LLVM) are installed and pathed correctly.

Common Commands/API

  • Parse Code: CLI: openclaw invoke cs-compilers --action parse --params '{"language": "python", "code": "def foo(x): return x+1"}'; returns AST as JSON. API: POST /api/skills/cs-compilers with body { "action": "parse", "params": { "language": "python", "code": "def foo(x): return x+1" } }.
  • Generate LLVM IR: CLI: openclaw invoke cs-compilers --action generate-llvm --params '{"language": "c", "code": "int add(int a, int b) { return a+b; }", "optimize": true}'; uses flags like --optimize for passes. API: POST /api/skills/cs-compilers with body { "action": "generate-llvm", "params": { "language": "c", "code": "int add(int a, int b) { return a+b; }" } }.
  • Lex Input: CLI: openclaw invoke cs-compilers --action lex --params '{"input": "int x = 5;", "patterns": ["\\bint\\b"]}'; outputs tokens array. API: POST /api/skills/cs-compilers with body { "action": "lex", "params": { "input": "int x = 5;", "patterns": ["\bint\b"] } }.
  • Config Format: Use JSON for params, e.g., { "grammar": "path/to/grammar.json", "options": { "debug": true } }. Authentication: Set env var $OPENCLAW_API_KEY for all API calls.

Integration Notes

Integrate by installing OpenClaw SDK via pip install openclaw and importing it in your project. For LLVM, ensure clang is installed and link via llvm-config --cxxflags. Tree-sitter requires compiling grammars; e.g., clone a repo and build with make. Handle dependencies in your environment; e.g., set PATH for LLVM tools. For custom parsers, provide a config JSON like { "parserType": "LR", "grammarRules": [{ "rule": "E -> T + E" }] }. Test integrations in a sandbox to verify responses.

Error Handling

Always check the response object for an 'error' key; if present, it contains a code and message. For CLI, parse output JSON: if response['error'], exit with code response['error']['code']. In SDK: try: response = client.invoke(...); except OpenClawError as e: log(e.code, e.message). Common errors: 400 for invalid params (e.g., malformed JSON), 401 for auth issues (check $OPENCLAW_API_KEY), 500 for internal failures like parser crashes. Retry transient errors (e.g., 503) with exponential backoff, and validate inputs before invoking, e.g., ensure 'language' is a supported string like 'c' or 'python'.

Concrete Usage Examples

  1. Parsing a C Function: To parse and extract an AST for a simple C function, run: openclaw invoke cs-compilers --action parse --params '{"language": "c", "code": "int main() { return 0; }"}'. This returns a JSON AST like { "type": "function_definition", "name": "main", "body": [...] }. Use the AST to analyze structure, e.g., count nodes.
  2. Generating Optimized LLVM IR: To generate and optimize LLVM IR from C code, execute: openclaw invoke cs-compilers --action generate-llvm --params '{"language": "c", "code": "int add(int a, int b) { return a + b; }", "optimize": true}'. Output might be: "define i32 @add(i32 %a, i32 %b) { %1 = add i32 %a, %b; ret i32 %1 }". Pipe this to LLVM tools for further compilation.

Graph Relationships

  • Related to: programming-languages (shares parsing and AST techniques for language design)
  • Related to: software-engineering (connects via code optimization and integration with build tools)
  • Related to: algorithms (overlaps on efficient parsing algorithms like LL and LR)