rustixml
A pure Rust implementation of the Invisible XML (iXML) specification with WebAssembly support.
Turn any text into XML using simple grammar rules. Works natively in Rust and in the browser via WebAssembly.
โจ Features
- ๐ Fast native recursive descent parser - Direct interpretation of iXML grammars
- โ 83.7% spec conformance - 41 out of 49 correctness tests passing (details)
- ๐ WebAssembly support - 50KB gzipped, runs in any modern browser
- ๐ฆ Single dependency - Only
unicode-general-categoryfor native builds - ๐ Pure safe Rust - No unsafe code
- ๐ฏ Zero-copy parsing - Efficient memory usage
๐ Quick Start
Rust
Add to your Cargo.toml:
[]
= "0.2"
Example usage:
use ;
WebAssembly (Browser)
iXML Parser Demo
๐ฎ Live Demo
Try it online: Demo Website (coming soon)
Or run locally:
# Clone the repository
# Build WASM
# Serve the demo
# Open http://localhost:8080/www/ in your browser
Three demo versions available:
www/index.html- Standard demo (recommended for most users)www/htmz-standalone.html- HTMZ pattern demo (form-driven, no backend)www/wasmz.html- WASMZ pattern demo โญ (native speed with wasm:// routing!)
See www/HTMZ-README.md for comparison of all three versions.
WASMZ Pattern: The wasmz.html demo showcases true wasm:// routing where HTML forms directly call compiled Rust functions that return HTML templates. This is a reference implementation of the WASMZ pattern (WebAssembly + htmz) offering ~10x performance improvement over JavaScript. See www/WASMZ-PATTERN.md for technical details.
๐ What is Invisible XML?
Invisible XML (iXML) is a specification for describing text formats as grammars and automatically converting text that matches those grammars into XML. It's like regular expressions on steroids!
Example: Parse CSV into XML:
csv: row+.
row: field+separator, field, newline.
field: char*.
@separator: ",".
-char: ~[","; #0A].
-newline: #0A.
Input:
name,age,city
Alice,30,NYC
Bob,25,LA
Output:
nameagecity
Alice30NYC
Bob25LA
๐๏ธ Architecture
rustixml uses a native recursive descent parser that directly interprets iXML grammar ASTs. Unlike other implementations that use parser generators, this approach:
- โ Eliminates intermediate compilation steps
- โ Produces smaller WASM binaries (50KB vs 500KB+)
- โ Handles insertion/suppression semantics natively
- โ Provides better error messages
See docs/ARCHITECTURE.md for details.
๐ Conformance
Overall: 45/65 tests (69.2%)
Correct tests: 41/49 tests (83.7%)
See docs/NATIVE_PARSER_STATUS.md for detailed test results.
๐ง Building
Native
WebAssembly
# Install wasm-pack if you haven't already
|
# Build for web
# Build for Node.js
# Build for bundlers (webpack, rollup, etc.)
๐งช Testing
# Run unit tests
# Run conformance tests
๐ฆ Publishing
Crates.io
npm
๐ค Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Areas where help is especially appreciated:
- ๐ Fixing failing test cases (see KNOWN_ISSUES.md)
- ๐ Improving documentation
- โจ Adding examples
- ๐งช Writing more tests
๐ License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
๐ Acknowledgments
- iXML Specification by the Invisible XML Community Group
- iXML Test Suite for comprehensive conformance testing
- Rust and WebAssembly communities for excellent tooling
๐ Resources
Made with โค๏ธ and ๐ฆ by Alex Everitt