indexion-kgf
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseindexion kgf
indexion kgf
Inspect and debug KGF language specs by viewing tokens, parse events, and extracted edges.
通过查看 token、解析事件和提取的边,检查并调试 KGF 语言规范。
When to Use
使用场景
- User wants to debug how indexion processes a specific file
- User is developing or modifying a KGF spec
- User asks "how does indexion parse this file?"
- Verifying that tokenization/parsing works correctly for a language
- Debugging grep patterns: when a grep pattern doesn't match, use
to see the actual token kinds
kgf tokens
- 用户需要调试 indexion 处理特定文件的流程
- 用户正在开发或修改 KGF 规范
- 用户询问「indexion 是如何解析这个文件的?」
- 验证某门语言的分词/解析功能是否正常工作
- 调试 grep 模式:当 grep 模式无法匹配时,使用 查看实际的 token 类型
kgf tokens
Subcommands
子命令
indexion kgf inspect
— Full Inspection
indexion kgf inspectindexion kgf inspect
— 完整检查
indexion kgf inspectShow tokens, events, and edges all at once.
bash
indexion kgf inspect <file>
indexion kgf inspect --spec=typescript src/app.ts一次性展示 token、事件和边。
bash
indexion kgf inspect <file>
indexion kgf inspect --spec=typescript src/app.tsindexion kgf tokens
— Tokenization Only
indexion kgf tokensindexion kgf tokens
— 仅展示分词结果
indexion kgf tokensShow how a file is tokenized.
bash
indexion kgf tokens <file>
indexion kgf tokens --spec=go-mod go.mod展示文件的分词方式。
bash
indexion kgf tokens <file>
indexion kgf tokens --spec=go-mod go.modindexion kgf events
— Parse Events Only
indexion kgf eventsindexion kgf events
— 仅展示解析事件
indexion kgf eventsShow parse events generated from tokens.
bash
indexion kgf events <file>展示从 token 生成的解析事件。
bash
indexion kgf events <file>indexion kgf edges
— Extracted Edges Only
indexion kgf edgesindexion kgf edges
— 仅展示提取的边
indexion kgf edgesShow the dependency edges extracted from a file.
bash
indexion kgf edges <file>
indexion kgf edges fixtures/project/npm/package.json展示从文件中提取的依赖边。
bash
indexion kgf edges <file>
indexion kgf edges fixtures/project/npm/package.jsonOptions
选项
| Option | Default | Description |
|---|---|---|
| auto-detect | KGF spec name to use |
| kgfs | KGF specs directory |
| 选项 | 默认值 | 描述 |
|---|---|---|
| 自动检测 | 要使用的 KGF 规范名称 |
| kgfs | KGF 规范目录 |
Relationship to grep
与 grep 的关系
indexion greppubKW_pub=== lexWhen a grep pattern doesn't match as expected:
bash
undefinedindexion greppubKW_pub=== lex当 grep 模式未按预期匹配时:
bash
undefined1. See the actual tokens for a file
1. 查看文件的实际 token
indexion kgf tokens src/config/paths.mbt
indexion kgf tokens src/config/paths.mbt
2. Check which token kinds exist
2. 查看存在哪些 token 类型
indexion kgf tokens src/config/paths.mbt | head -20
indexion kgf tokens src/config/paths.mbt | head -20
3. Then adjust your grep pattern to match the actual token kinds
3. 调整 grep 模式匹配实际的 token 类型
indexion grep "KW_pub KW_fn Ident" src/config/paths.mbt
Common token kinds (MoonBit):
- `KW_pub`, `KW_fn`, `KW_struct`, `KW_enum`, `KW_type`, `KW_trait`, `KW_let`, `KW_for`
- `Ident` (lowercase identifiers), `TypeIdent` (PascalCase type names)
- `LPAREN`, `RPAREN`, `LBRACE`, `RBRACE`, `LBRACKET`, `RBRACKET`
- `NL` (newline), `SKIP` (whitespace — filtered from grep patterns)
- `DocComment`, `DocLine`, `DocSection`, `LineComment`, `BlockComment`
- `String`, `Number`, `Char`indexion grep "KW_pub KW_fn Ident" src/config/paths.mbt
常见 token 类型(MoonBit):
- `KW_pub`、`KW_fn`、`KW_struct`、`KW_enum`、`KW_type`、`KW_trait`、`KW_let`、`KW_for`
- `Ident`(小写标识符)、`TypeIdent`(PascalCase 类型名)
- `LPAREN`、`RPAREN`、`LBRACE`、`RBRACE`、`LBRACKET`、`RBRACKET`
- `NL`(换行符)、`SKIP`(空白符——会从 grep 模式中过滤)
- `DocComment`、`DocLine`、`DocSection`、`LineComment`、`BlockComment`
- `String`、`Number`、`Char`Workflow
工作流程
- Run to see the full processing pipeline
indexion kgf inspect <file> - If something looks wrong, drill down with ,
tokens, oreventsedges - Compare with the KGF spec file () to diagnose issues
kgfs/<lang>.kgf
- 运行 查看完整处理流程
indexion kgf inspect <file> - 如果发现异常,使用 、
tokens或events子命令深入排查edges - 与 KGF 规范文件()对比诊断问题
kgfs/<lang>.kgf