parser-developer
БесплатноЗапускает вложенные скриптыНе проверенGuides AILANG parser development with conventions and patterns. Use when user wants to modify parser, understand parser architecture, or debug parser issues…
от sunholo-data★ 39 звёзд на GitHubОб этом скилле
Parser Developer
Master AILANG parser development with critical conventions that prevent common bugs.
Quick Start
⚠️ READ THIS BEFORE WRITING PARSER CODE
This skill documents critical parser conventions that prevent token position bugs (the #1 time sink in parser development).
Time savings: ~30% by avoiding common pitfalls
Key conventions:
- Parser leaves cursor AT last token (not after)
- Lexer never generates NEWLINE tokens
- Use
DEBUG_PARSER=1for token tracing - Use
make doc PKG=<package>for API discovery
When to Use This Skill
Invoke this skill when:
- User wants to modify the AILANG parser
- User asks about parser architecture or conventions
- User is debugging parser issues
- User needs to understand token positioning
- User wants to add new syntax to AILANG
- User asks "how do I parse...?"
Critical Convention: Token Position
CRITICAL: AILANG parser functions follow this convention:
- Input: Parser is AT the first token to parse
- Output: Parser is AT the last token of what was parsed (NOT after it)
Example:
// To parse "42" followed by a comma:
p.nextToken() // move to 42
expr := p.parseExpression(LOWEST) // parses "42", leaves cur=42 (NOT comma!)
p.nextToken() // NOW we're at comma ✓
Functions following this convention:
parseExpression()- Leaves parser AT the last token of the expressionparseType()- Leaves parser AT the last token of the typeparsePattern()- Leaves parser AT the last token of the pattern- Most parser functions follow this pattern
When writing new parser functions:
- ✅ ALWAYS call
p.nextToken()AFTER calling these functions - ❌ DON'T call
p.nextToken()BEFORE - the caller handles positioning - ✅ Document your function if it deviates from this convention
See: resources/token_positioning.md for detailed examples
Available Scripts
scripts/trace_parser.sh <file.ail>
Run parser with DEBUG_PARSER=1 to trace token positions.
Usage:
.claude/skills/parser-developer/scripts/trace_parser.sh test.ail
Output:
[ENTER parseExpression] cur=INT(42) peek=COMMA
[EXIT parseExpression] cur=INT(42) peek=COMMA
scripts/check_ast_types.sh
List all AST node types in the codebase.
Usage:
.claude/skills/parser-developer/scripts/check_ast_types.sh
scripts/find_api.sh <package> <symbol>
Quick API discovery using make doc.
Usage:
.claude/skills/parser-developer/scripts/find_api.sh internal/parser New
Common AST Types
Quick type lookup:
grep "^type.*struct" internal/ast/ast.go | head -20
Expression types:
- Literals:
ast.LiteralwithKindfield- ⚠️ GOTCHA: Lexer returns
int64, notintfor IntLit - ✅ Access:
lit.Value.(int64) - ❌ Wrong:
lit.Value.(int)(will panic!)
- ⚠️ GOTCHA: Lexer returns
- Lists:
ast.ListwithElements []Expr - Variables:
ast.VariablewithName string - Function calls:
ast.FuncCallwithFunc Expr, Args []Expr - Lambdas:
ast.LambdawithParams []*ast.Param, Body Expr - Blocks:
ast.BlockwithExprs []Expr
Type types:
- Simple types:
ast.SimpleTypewithName string - List types:
ast.ListTypewithElement Type - Function types:
ast.FuncTypewithParams []Type, Return Type, Effects *ast.EffectRow - Type applications:
ast.TypeAppwithCon string, Args []Type
Pattern types:
- Variable pattern:
ast.VarPatternwithName string - Constructor pattern:
ast.ConstructorPatternwithName string, Args []Pattern - Literal pattern:
ast.LiteralPatternwithValue Literal - Wildcard pattern:
ast.WildcardPattern(matches anything)
See: resources/ast_quick_reference.md for complete listing
Quick Token Lookup
Check if a keyword exists:
grep -i "forall" internal/lexer/token.go
# Output: FORALL token exists!
Common testing keywords (already in lexer):
FORALL,EXISTS- QuantifiersTEST,TESTS- Test blocksPROPERTY,PROPERTIES- Property-based testsASSERT- Assertions
If you see an identifier instead of a keyword:
- ✅ Use
lexer.FORALL, notlexer.IDENT + literal check - ❌ Wrong:
p.curTokenIs(lexer.IDENT) && p.curToken.Literal == "forall" - ✅ Right:
p.curTokenIs(lexer.FORALL)
Debug Mode
Enable token position tracing:
DEBUG_PARSER=1 ailang run test.ail
Output example:
[ENTER parseType] cur=IDENT(int) peek=,
[EXIT parseType] cur=IDENT(int) peek=,
[ENTER parseExpression] cur=IDENT(x) peek=+
[EXIT parseExpression] cur=IDENT(x) peek=+
How it works:
- Shows ENTER/EXIT for key parser functions
- Displays current (
cur) and next (peek) tokens - Only logs when
DEBUG_PARSER=1is set (zero overhead otherwise) - Output goes to stderr
See: resources/debug_mode.md for troubleshooting guide
Common
Установить parser-developer в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл parser-developer?
Guides AILANG parser development with conventions and patterns. Use when user wants to modify parser, understand parser architecture, or debug parser issues. Saves 30% of development time by preventing token position bugs.
Как установить скилл parser-developer?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл parser-developer запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
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