How_to_implment_PL_in_Antlr4: Skill for Claude Code

.claude/skills/compiler-dev/SKILL.md

compiler-dev is a skill for Claude Code from whtoo/How_to_implment_PL_in_Antlr4. It costs 27 tokens per session (1,592 once invoked), scanned A, original, BSD-3-Clause.

A specialist guide for developing compiler back ends, the part of a compiler that turns program structures into optimized lower-level instructions. It covers symbol tables, types, intermediate code, control-flow graphs, data-flow analysis, and optimization in a Java project.

In plain words
What is it for?
Use it when working on the compiler's type system, intermediate representation, control-flow analysis, static single assignment form, or optimization passes.
Why use it?
It gives an agent project-specific knowledge for navigating compiler code and implementing analysis or optimization changes.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

This is whtoo/How_to_implment_PL_in_Antlr4's own configuration. It tells Claude Code how to work on How_to_implment_PL_in_Antlr4 itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything How_to_implment_PL_in_Antlr4 configures →

Reuse

Borrowing it

Nothing to install: this file belongs to whtoo/How_to_implment_PL_in_Antlr4. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/whtoo/How_to_implment_PL_in_Antlr4/main/.claude/skills/compiler-dev/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/whtoo/How_to_implment_PL_in_Antlr4

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for compiler-dev

README.md
[![agentmods](https://agentmods.dev/badge/skills/whtoo/how_to_implment_pl_in_antlr4/compiler-dev.svg)](https://agentmods.dev/skills/whtoo/how_to_implment_pl_in_antlr4/compiler-dev)
Your own site
<a href="https://agentmods.dev/skills/whtoo/how_to_implment_pl_in_antlr4/compiler-dev"><img src="https://agentmods.dev/badge/skills/whtoo/how_to_implment_pl_in_antlr4/compiler-dev.svg" alt="Measured on agentmods" height="20"></a>
Per session 27 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,592 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00027 $0.01592
Opus 5 $0.00014 $0.00796
Sonnet 5 $0.00005 $0.00318
Haiku 4.5 $0.00003 $0.00159

Measured yesterday against content hash 15410c76f7fe, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

compiler-dev scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/compiler-dev/SKILL.md · 160 lines

How it starts

The opening of the file, as written. The whole thing — 160 lines — stays where its author put it; the contents beside it link to each section on GitHub.

编译器后端开发

🎯 垂直职责

单一职责: 编译器中后端技术 - 符号表、类型系统、IR、CFG、SSA、优化

📦 核心能力

1. 符号表与类型系统 (EP6-EP10)

  • 位置: ep20/src/main/java/org/teachfx/antlr4/ep20/symtab/
  • 作用域: scope/GlobalScope, scope/LocalScope
  • 符号: symbol/VariableSymbol, symbol/MethodSymbol
  • 类型: type/Type, type/BuiltInType, type/StructType

2. 中间表示 (EP11-EP17)

  • 位置: ep20/src/main/java/org/teachfx/antlr4/ep20/ir/
  • 表达式: ir/expr/ (BinExpr, UnaryExpr, ConstVal)
  • 语句: ir/stmt/ (Assign, Jump, ConditionalJump)
  • 构建器: CymbolIRBuilder.java

3. 控制流图 (EP16-EP17)

  • 位置: ep20/src/main/java/org/teachfx/antlr4/ep20/pass/cfg/
  • 核心: ControlFlowAnalysis.java, CFG.java
  • 基本块: BasicBlock<IRNode>

4. SSA与优化 (EP21)

  • 位置: ep21/src/main/java/org/teachfx/antlr4/ep21/
  • SSA: analysis/ssa/SSAGraph.java
  • 数据流: analysis/dataflow/ (LiveVariableAnalysis, ReachingDefinitions)
  • 优化: pass/cfg/ (ConstantFolding, CSE, DCE)

🔗 关系图

ep-navigator (识别EP范围) → antlr4-dev (AST → IR转换) ← vm-dev (IR → 字节码)

🚀 快速开始

实现新的优化Pass

# 1. 创建优化器 (实现IFlowOptimizer<IRNode>)
vim ep21/src/main/java/.../pass/cfg/NewOptimizer.java

# 2. 标准模板
public class NewOptimizer implements IFlowOptimizer<IRNode> {
    @Override
    public void onHandle(CFG<IRNode> cfg) {
        // 遍历基本块
        for (BasicBlock<IRNode> block : cfg) {
            // 优化逻辑
        }
    }
}

# 3. 创建测试
vim ep21/src/test/java/.../pass/cfg/NewOptimizerTest.java

# 4. 运行测试
mvn test -pl ep21 -Dtest="*NewOptimizer*"

SSA转换流程

# 1. 构建支配树
cfg.computeDominanceFrontier();

# 2. 插入Φ函数
ssa.insertPhiFunctions();

# 3. 变量重命名
ssa.renameVariables();

# 4. 验证
mvn test -pl ep21 -Dtest="*SSATest"

📊 数据流分析模板

// 标准数据流分析框架
public class MyDataFlowAnalysis extends AbstractDataFlowAnalysis<Set<Var>, Set<Var>> {
    @Override
    public Set<Var> getBoundaryCondition() {
        return new HashSet<>(); // 初始状态
    }

    @Override
    public Set<Var> getInitialFlow() {
        return new HashSet<>(); // 默认状态
    }

    @Override
    public Set<Var> merge(List<Set<Var>> inputs) {
        Set<Var> result = new HashSet<>();
        for (Set<Var> input : inputs) {
            result.addAll(input); // 合并操作
        }
        return result;
    }

    @Override
    public Set<Var> flowFunction(BasicBlock<IRNode> block, Set<Var> input) {
        Set<Var> output = new HashSet<>(input);
        // 传递函数: 根据block内容修改output
        return output;
    }
}

Read the full file on GitHub · 160 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 160 lines · 27 tokens per session scan A 15410c76f7fe

Subscribe to this mod's changes

compiler-dev is a skill published in the GitHub repository whtoo/How_to_implment_PL_in_Antlr4 (34 stars, last pushed 3mo ago), licensed BSD-3-Clause. It adds 27 tokens to every session and 1,592 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-04.

Related

Other skills, from other repositories