|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +Dada is an experimental programming language that explores what a Rust-like language would look like if designed to feel more like Java/JavaScript rather than C++. It's async-first, uses a permission-based ownership system, and compiles to WebAssembly. |
| 8 | + |
| 9 | +## Development Commands |
| 10 | + |
| 11 | +### Basic Commands |
| 12 | +- `cargo run -- compile <file.dada>` - Compile a Dada source file |
| 13 | +- `cargo run -- run <file.dada>` - Compile and execute a Dada program |
| 14 | +- `cargo run -- test [files]` - Run test suite on specific Dada files |
| 15 | +- `cargo run -- debug <file.dada>` - Compile with debug server for introspection |
| 16 | + |
| 17 | +### Testing |
| 18 | +- `just test` - Run all tests across the workspace (equivalent to `cargo test --all --workspace --all-targets`) |
| 19 | +- `cargo test` - Run Rust unit tests |
| 20 | +- Test files are in `tests/` directory with `.dada` extension |
| 21 | + |
| 22 | +### Build Tools |
| 23 | +- `cargo xtask build` - Custom build tasks |
| 24 | +- `cargo xtask deploy` - Deployment automation |
| 25 | + |
| 26 | +## Architecture |
| 27 | + |
| 28 | +The compiler is built as a Cargo workspace with these key components: |
| 29 | + |
| 30 | +### Core Pipeline (in compilation order) |
| 31 | +1. **`dada-parser`** - Lexing/parsing source to AST |
| 32 | +2. **`dada-ir-ast`** - AST representation and diagnostics |
| 33 | +3. **`dada-ir-sym`** - Symbolic IR (type-checked, high-level representation) |
| 34 | +4. **`dada-check`** - Type checking and semantic analysis |
| 35 | +5. **`dada-codegen`** - WebAssembly code generation (currently incomplete) |
| 36 | + |
| 37 | +### Supporting Components |
| 38 | +- **`dada-lang`** - Main CLI entry point |
| 39 | +- **`dada-compiler`** - Compilation orchestration and VFS |
| 40 | +- **`dada-debug`** - Debug server for compiler introspection |
| 41 | +- **`dada-lsp-server`** - Language Server Protocol implementation |
| 42 | +- **`dada-util`** - Shared utilities (arena allocation, logging, etc.) |
| 43 | + |
| 44 | +### Key Design Patterns |
| 45 | +- **Salsa-based**: Uses incremental, memoized computation framework |
| 46 | +- **Database pattern**: Central `Db` trait for accessing compiler state |
| 47 | +- **Async architecture**: Built around async/await throughout |
| 48 | + |
| 49 | +## Current Status & Constraints |
| 50 | + |
| 51 | +- **Early development**: Core language features implemented but not production-ready |
| 52 | +- **Codegen limitations**: Most test files have `#:skip_codegen` as WASM generation is incomplete |
| 53 | +- **Active experimentation**: Language design still evolving (see `tests/spikes/` for experimental features) |
| 54 | + |
| 55 | +## Language Characteristics |
| 56 | + |
| 57 | +- **Async-first**: Functions are async by default |
| 58 | +- **Permission system**: Uses ownership annotations (`my`, `our`, `mut`) for memory management |
| 59 | +- **Classes and structs**: Both reference types (classes) and value types (structs) |
| 60 | +- **Rust-inspired**: Similar memory safety guarantees with more accessible syntax |
| 61 | +- **Comments**: Use `#` not `//` |
| 62 | + |
| 63 | +## Test File Structure |
| 64 | + |
| 65 | +- `tests/parser/` - Parser tests |
| 66 | +- `tests/symbols/` - Symbol resolution tests |
| 67 | +- `tests/type_check/` - Type checking tests |
| 68 | +- `tests/spikes/` - Experimental language features |
| 69 | +- `tests/default_perms/` - Default permission inference tests |
| 70 | + |
| 71 | +Test files use `.dada` extension and often include `#:skip_codegen` directives. |
| 72 | + |
| 73 | +## Documentation |
| 74 | + |
| 75 | +The compiler uses rustdoc for comprehensive documentation. Major documentation files: |
| 76 | + |
| 77 | +### Generation Commands |
| 78 | +- `just doc` - Generate docs for all crates (recommended) |
| 79 | +- `just doc-open` - Generate and open docs in browser |
| 80 | +- `just doc-serve` - Generate docs and serve locally at http://localhost:8000 |
| 81 | +- `cargo doc --workspace --no-deps --document-private-items` - Manual command equivalent to `just doc` |
| 82 | + |
| 83 | +### Documentation Structure |
| 84 | +- **`dada-lang`** - Main landing page and compiler overview |
| 85 | +- **`dada-ir-sym`** - Core type system and symbolic IR documentation |
| 86 | +- **`dada-check`** - Type checking orchestration |
| 87 | +- **Individual modules** - Detailed documentation embedded in source |
| 88 | + |
| 89 | +### Documentation Files |
| 90 | +- `components/*/docs/*.md` - Extended documentation included via `include_str!` |
| 91 | +- Inline module docs using `//!` comments |
| 92 | +- Cross-references using `[`item`]` syntax for automatic linking |
| 93 | + |
| 94 | +Major documentation sections: |
| 95 | +- **Type Checking Pipeline** - Overview of the checking process |
| 96 | +- **Permission System** - Detailed guide to Dada's ownership model |
| 97 | +- **Type Inference** - How Hindley-Milner inference works in Dada |
| 98 | +- **Subtyping** - Type relationships and conversions |
| 99 | + |
| 100 | +### Documentation Guidelines |
| 101 | + |
| 102 | +#### Cross-Crate Links |
| 103 | +- Use `[text](../crate_name)` format for linking to sibling crates (regular markdown links) |
| 104 | +- Avoid bare `[crate_name]` links that rely on implicit resolution |
| 105 | + |
| 106 | +#### Intra-Crate Links |
| 107 | +- Use `[item](`path::to::item`)` format with backticks around the path (rustdoc links) |
| 108 | +- For private items, use `pub(crate)` visibility when the item needs to be documented |
| 109 | +- Prefer concrete method names over non-existent placeholder methods |
| 110 | +- Examples: `[MyStruct](`crate::module::MyStruct`)`, `[method](`Self::method_name`)` |
| 111 | + |
| 112 | +#### Code Blocks |
| 113 | +- Always specify language: ```rust, ```text, ```bash, etc. |
| 114 | +- Use ```text for error messages, command output, or mixed syntax |
| 115 | +- Use ```rust only for valid Rust code |
| 116 | +- Avoid bare ``` without language specification |
| 117 | + |
| 118 | +#### Link Style |
| 119 | +- **Intra-crate**: `[item](`path::to::item`)` (with backticks for rustdoc resolution) |
| 120 | +- **Cross-crate**: `[crate](../crate_name)` (without backticks for markdown links) |
| 121 | +- Keep link text descriptive but concise |
| 122 | + |
| 123 | +#### Writing Style |
| 124 | +- Use factual, objective tone |
| 125 | +- Avoid subjective adjectives like "powerful", "innovative", "elegant", "robust" |
| 126 | +- Focus on describing what the code does, not evaluating its quality |
| 127 | +- Let readers draw their own conclusions about the design |
| 128 | +- Prefer "implements X" over "provides powerful X functionality" |
| 129 | + |
| 130 | +#### Error Prevention |
| 131 | +- Verify referenced types/methods actually exist before documenting them |
| 132 | +- Use `--document-private-items` compatible linking for internal docs |
| 133 | +- Test documentation builds regularly with `just doc` |
0 commit comments