fml_check/lib.rs
1//! Type checker for the FHIR Mapping Language.
2//!
3//! Follows every rule with the types of its variables and reports what cannot work: elements that
4//! do not exist on the type they are read from or written to, a type annotation that is not one of
5//! the element's types, unknown variables, writes into source variables, unknown or abstract types
6//! in `create`, transforms with the wrong number of arguments, and calls to groups that are not
7//! declared or take a different number of arguments.
8//!
9//! Groups without parameter types, such as the per-backbone groups of the cross-version maps, are
10//! checked with the types they are called with.
11//!
12//! ```
13//! # #[cfg(feature = "fhirschema")] {
14//! use fml_check::{CoreDefinitions, Release, check};
15//!
16//! let parse = fml_syntax::parse(r#"
17//! uses "http://hl7.org/fhir/StructureDefinition/Patient" as source
18//! uses "http://hl7.org/fhir/StructureDefinition/Patient" as target
19//!
20//! group Copy(source src : Patient, target tgt : Patient) {
21//! src.nmae -> tgt.name;
22//! }
23//! "#);
24//! let diagnostics = check(&parse.tree(), &CoreDefinitions::new(Release::R5));
25//! assert_eq!(diagnostics[0].message, "`Patient` has no element `nmae`");
26//! # }
27//! ```
28
29mod check;
30#[cfg(feature = "fhirschema")]
31mod core;
32pub mod definitions;
33#[cfg(feature = "fhirschema")]
34mod package;
35pub mod types;
36
37pub use check::check;
38#[cfg(feature = "fhirschema")]
39pub use core::{CoreDefinitions, Release};
40pub use definitions::{Definitions, Element, Kind, NoDefinitions, Structure};
41#[cfg(feature = "fhirschema")]
42pub use package::PackageDefinitions;
43pub use types::{ElementRef, Lookup, Type, Types};