1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use Message;
use Parser;
pub use Diagnostic;
pub use ;
pub use ;
/// Parse a message and return the AST, diagnostics, and source text info.
///
/// The parser is able to successfully parse any string into an AST, even if the
/// string contains invalid syntax. The diagnostics will contain any errors that
/// were found during parsing. Some diagnostics are considered "fatal", because
/// they signal that the parser was unable to recover from the error and the AST
/// may be incomplete or incorrect. Other non-fatal diagnostics will result in
/// an AST that fully represents the input string, but may be invalid in some
/// other way (like escaping a character that can not be escaped).
///
/// The source text info contains the original source text and the line and
/// column information for each character in the source text. This is useful for
/// mapping locations in the AST or the diagnostics back to actual locations in
/// the source text.
///
/// ### Example
///
/// ```rust
/// 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);
/// ```
/// Check if a string is a syntactically valid name in MF2.