Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

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от 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:

  1. Parser leaves cursor AT last token (not after)
  2. Lexer never generates NEWLINE tokens
  3. Use DEBUG_PARSER=1 for token tracing
  4. 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 expression
  • parseType() - Leaves parser AT the last token of the type
  • parsePattern() - 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.Literal with Kind field
    • ⚠️ GOTCHA: Lexer returns int64, not int for IntLit
    • ✅ Access: lit.Value.(int64)
    • ❌ Wrong: lit.Value.(int) (will panic!)
  • Lists: ast.List with Elements []Expr
  • Variables: ast.Variable with Name string
  • Function calls: ast.FuncCall with Func Expr, Args []Expr
  • Lambdas: ast.Lambda with Params []*ast.Param, Body Expr
  • Blocks: ast.Block with Exprs []Expr

Type types:

  • Simple types: ast.SimpleType with Name string
  • List types: ast.ListType with Element Type
  • Function types: ast.FuncType with Params []Type, Return Type, Effects *ast.EffectRow
  • Type applications: ast.TypeApp with Con string, Args []Type

Pattern types:

  • Variable pattern: ast.VarPattern with Name string
  • Constructor pattern: ast.ConstructorPattern with Name string, Args []Pattern
  • Literal pattern: ast.LiteralPattern with Value 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 - Quantifiers
  • TEST, TESTS - Test blocks
  • PROPERTY, PROPERTIES - Property-based tests
  • ASSERT - Assertions

If you see an identifier instead of a keyword:

  • ✅ Use lexer.FORALL, not lexer.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=1 is set (zero overhead otherwise)
  • Output goes to stderr

See: resources/debug_mode.md for troubleshooting guide

Common

Полный SKILL.md на GitHub

Установить parser-developer в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

resources/reference.mdscripts/check_ast_types.shscripts/example_script.shscripts/find_api.shscripts/trace_parser.sh

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 запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить parser-developer с