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 now exist (carve-js, carve-rs, carve-php), tested against the shared corpus.
Still wanted:
- Python (data science, docs communities)
- Go (modern backend systems)
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 - Social Mentions:
@userand#tagwork as expected - Extension System:
:type[content]{attrs}for custom elements - Unambiguous Rules: One syntax, one meaning, always
- Djot Foundation: Inherits rigorous parsing and attributes
12.2 Success Metrics
Carve succeeds if:
- 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 is trivial
12.3 Next Steps
- 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
This case study captures Carve's original design exploration. Carve now has a normative grammar, a conformance corpus, and multiple implementations; real-world testing with diverse users continues to inform syntax decisions.
Feedback and contributions welcome at https://github.com/markup-carve.