fml-syntax 0.2.0

Lossless parser and formatter for the FHIR Mapping Language (FML)
Documentation
  • Coverage
  • 54.41%
    148 out of 272 items documented1 out of 120 items with examples
  • Size
  • Source code size: 118.0 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.9 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 3s Average build duration of successful builds.
  • all releases: 3s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • octofhir/fml-rs
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • octoshikari

fml-syntax

Parser and formatter for the FHIR Mapping Language (FML), in Rust.

  • Lossless. The syntax tree keeps every byte of the input, comments and whitespace included: parse(text).syntax().to_string() == text for any input.
  • Error-tolerant. A mistake becomes a diagnostic and an error node; the rest of the file still parses, so one typo does not hide the next one. Positions are given in bytes, lines and UTF-16 columns.
  • A formatter that keeps comments. One statement per line, consistent spacing, comments where they were. It re-parses its own output and refuses to return text that would change the map.
  • The real-world grammar. The Mapping Language IG grammar, plus what maps written for FHIR R3–R5 use and the HL7 reference compiler accepts: map "url" = "name", unparenthesised where, embedded conceptmap with unmapped, <<type+>> groups.

All 1,659 public maps we test against parse without errors, and formatting each of them twice gives the same result as formatting it once.

let parse = fml_syntax::parse(source);
for diagnostic in parse.diagnostics() {
    eprintln!("{}", diagnostic.message);
}
for group in parse.tree().groups() {
    for rule in group.rules() {
        // sources, targets, transforms, dependent rules…
    }
}
let formatted = fml_syntax::format(source, &fml_syntax::FormatOptions::default())?;

Part of fml-rs. Licensed under MIT or Apache-2.0.