How rust-bakery/nom works
Main Components
a) Core Parser Engine
• Main parsing traits and types from src/traits.rs
• To the error handling system (src/error.rs)
b) Parser Combinators Groups (organize as modules radiating from the core):
• Bytes (src/bytes/) - For byte-level parsing
• Characters (src/character/) - For character/string parsing
• Numbers (src/number/) - For numeric parsing
• Bits (src/bits/) - For bit-level parsing
• Sequences (src/sequence/) - For combining parsers
• Branches (src/branch/) - For alternative parsing paths
• Multi (src/multi/) - For repetition and collection
• Combinators (src/combinator/) - For parser transformations
Data Flow Architecture
Following flows:
Input Data → Parser Combinators → Parsing Result
• ↓
• Error Handling
Component Relationships
• How each parser module connects to the core engine
• Two main parsing modes: "complete" and "streaming"
• Demonstrate error propagation paths
• How combinators can be composed
Special Features Layer
• Zero-copy parsing capabilities
• Streaming support
• Custom error handling
• Bit-level parsing
• Debug/trace capabilities
Implementation Details
Technical aspects:
• Input type abstraction (showing support for &[u8], &str, custom types)
• Error type system
• Parser trait implementation flow
• Memory management model (zero-copy architecture)
Integration Points
Integration capabilities with:
• Custom input types
• External error handling
• Streaming parsers
• Test frameworks