mf2_parser 0.1.1

Parser and AST definitions for MessageFormat 2
Documentation
  • Coverage
  • 5.07%
    17 out of 335 items documented4 out of 48 items with examples
  • Size
  • Source code size: 149.68 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 16.16 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 12s Average build duration of successful builds.
  • all releases: 12s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • lucacasonato/mf2-tools
    9 1 8
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • lucacasonato nicolo-ribaudo

mf2_parser

The mf2_parser crate provides a parser for the Message Format 2 syntax. It can parse any sequence of Unicode scalar values (valid UTF-8) into an AST representing the Message Format 2 syntax. The parser has very strong error recovery, so it can parse even very broken or incomplete input (like is common in editors).

Use the mf2_printer crate to pretty-print the AST back into the human-readable MessageFormat 2 syntax.

Usage

Add this to your Cargo.toml:

[dependencies]
mf2_parser = "0.1"

Then you can parse a string like this:

use mf2_parser::parse;

let (ast, diagnostics, source_text_info) = parse("Hello, {$name}!");
if !diagnostics.is_empty() {
  panic!("Failed to parse message: {:?}", diagnostics);
}

println!("AST: {:?}", ast);

License

This project is licensed under GPL-3.0-or-later.