Implementation & Reflection
Part 9: Implementation Considerations
9.1 Parser Architecture
- Lexer: Stream of tokens (block markers, inline markers, text)
- Block Parser: Resolves block structure before any inline parsing, as in Djot. (Djot's spec does not use the term "two-pass"; it guarantees that block structure is determined first and that reference resolution is order-independent. See Design Principles 1–2.)
- Inline Parser: Parses inline content within blocks
- AST Builder: Constructs typed AST nodes
- Renderer: Transforms AST to output format
9.2 Reference Implementations
JavaScript/TypeScript, Rust, and PHP implementations exist (carve-js, carve-rs, carve-php) and use the shared conformance corpus. See the Ecosystem for current bindings and integrations.
9.3 Editor Support Essentials
- Syntax highlighting rules (TextMate grammars)
- LSP server for validation and completion
- Tree-sitter grammar for structural editing
- Preview rendering (HTML output)
Part 12: Conclusion
12.1 Carve's Key Innovations
- Visual Mnemonics:
/slant/for italic,*heavy*for bold - Simpler Tables:
|=headers, no separator rows needed - Optional Mentions: configured templates can resolve
@userand#tag - Extension System:
:type[content]{attrs}for custom elements - Distinct Markers: Prefer different notation for different constructs
- Djot Foundation: Inherits rigorous parsing and attributes
12.2 Design Goals
The goals were:
- Non-technical users can write without consulting docs
- Technical users can access full power when needed
- Documents remain readable as plain text
- Parsing is deterministic and fast
- Migration from Markdown has a documented path
12.3 Next Steps (as written at the time)
- Formalize EBNF grammar
- Build reference parser in TypeScript
- User testing with non-technical writers
- Iterate on problem areas
- Editor integration (VS Code, Obsidian, etc.)
- Documentation and tutorials
The formal grammar, implementations, and documentation are available. The implementations use a shared conformance corpus. See the Ecosystem for current editor support and bindings. These notes present no results from the proposed user testing.
This case study is a historical record of early design notes. The normative definition of the language is the formal grammar and the conformance corpus.
Feedback and contributions welcome at https://github.com/markup-carve.