language-design

Designs Lexer, parser, AST, and interpreter patterns for language features in Lea.

4|Updated Dec 8, 2025
One-click install
npx skills add https://github.com/mcclowes/lea --skill language-design
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: language-design
Source: https://github.com/mcclowes/lea/tree/main/.claude/skills/language-design
Command: npx skills add https://github.com/mcclowes/lea --skill language-design

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

A guide to designing language features across lexer, parser, AST, and interpreter, enabling scalable language evolution.

Core Features & Use Cases

  • Lexer & Parser design: Tokenization and recursive descent parsing patterns
  • AST & Environment: Discriminated unions and scope management
  • Interoperability: Interfaces between parser and interpreter

Quick Start

Begin by sketching a new operator or syntax and map it through the pipeline.

Frequently Asked Questions about language-design

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I design a new language operator from lexer through interpreter?

Design operators end-to-end by defining token types in the lexer, adding parsing rules with precedence climbing, creating AST node types as discriminated unions, and implementing evaluation logic in the tree-walk interpreter with proper scope management.

What's the best way to structure a recursive-descent parser for a new syntax?

Recursive-descent parsing maps grammar rules to functions that consume tokens and build AST nodes. Each rule function handles its construct's precedence, delegates to lower-precedence functions, and returns structured nodes for the interpreter to evaluate.

How do I add new AST node types and ensure the interpreter handles them?

Define new nodes as discriminated union variants, update the parser to construct them, then add corresponding evaluation cases in the tree-walk interpreter with access to the environment for scope and variable lookup.

What's the relationship between tokenization, parsing, and AST construction?

Tokenization converts source text into a token stream, the parser consumes tokens and builds an abstract syntax tree following grammar rules, and the AST represents the syntactic structure the interpreter executes.

Can I extend an existing language without redesigning the entire pipeline?

Yes. Add token types to the lexer, extend parsing rules for the new syntax, define AST variants for semantic nodes, and integrate evaluation logic into the interpreter's existing environment and scope system.

How do environment and scope management work during interpretation?

The interpreter maintains environments that map names to values. Scope is managed by creating child environments for blocks and functions, allowing variable binding, lookup, and isolation across nested contexts.