Debian Codegraph @

third_party/rust/fluent-syntax/src/lib.rs

raw
1 //! Fluent is a modern localization system designed to improve how software is translated.
2 //!
3 //! `fluent-syntax` is the lowest level component of the [Fluent Localization
4 //! System](https://www.projectfluent.org).
5 //!
6 //! It exposes components necessary for parsing and tooling operations on Fluent Translation Lists ("FTL").
7 //!
8 //! The crate provides a [`parser`] module which allows for parsing of an
9 //! input string to an Abstract Syntax Tree defined in the [`ast`] module.
10 //!
11 //! The [`unicode`] module exposes a set of helper functions used to decode
12 //! escaped unicode literals according to Fluent specification.
13 //!
14 //! # Example
15 //!
16 //! ```
17 //! use fluent_syntax::parser;
18 //! use fluent_syntax::ast;
19 //!
20 //! let ftl = r#"
21 //!
22 //! hello-world = Hello World!
23 //!
24 //! "#;
25 //!
26 //! let resource = parser::parse(ftl)
27 //! .expect("Failed to parse an FTL resource.");
28 //!
29 //! assert_eq!(
30 //! resource.body[0],
31 //! ast::Entry::Message(
32 //! ast::Message {
33 //! id: ast::Identifier {
34 //! name: "hello-world"
35 //! },
36 //! value: Some(ast::Pattern {
37 //! elements: vec![
38 //! ast::PatternElement::TextElement {
39 //! value: "Hello World!"
40 //! },
41 //! ]
42 //! }),
43 //! attributes: vec![],
44 //! comment: None,
45 //! }
46 //! ),
47 //! );
48 //! ```
49 pub mod ast;
50 pub mod parser;
51 pub mod unicode;