| 1 | //! The `resolver` module contains the definitions and implementations for the internal | 
| 2 | //! `ResolveValue` and `WriteValue` traits. The former converts AST nodes to a | 
|---|
| 3 | //! [`FluentValue`], and the latter converts them to a string that is written to an | 
|---|
| 4 | //! implementor of the [`std::fmt::Write`] trait. | 
|---|
| 5 |  | 
|---|
| 6 | pub mod errors; | 
|---|
| 7 | mod expression; | 
|---|
| 8 | mod inline_expression; | 
|---|
| 9 | mod pattern; | 
|---|
| 10 | mod scope; | 
|---|
| 11 |  | 
|---|
| 12 | pub use errors::ResolverError; | 
|---|
| 13 | pub use scope::Scope; | 
|---|
| 14 |  | 
|---|
| 15 | use std::borrow::Borrow; | 
|---|
| 16 | use std::fmt; | 
|---|
| 17 |  | 
|---|
| 18 | use crate::memoizer::MemoizerKind; | 
|---|
| 19 | use crate::resource::FluentResource; | 
|---|
| 20 | use crate::types::FluentValue; | 
|---|
| 21 |  | 
|---|
| 22 | /// Resolves an AST node to a [`FluentValue`]. | 
|---|
| 23 | pub(crate) trait ResolveValue<'bundle> { | 
|---|
| 24 | /// Resolves an AST node to a [`FluentValue`]. | 
|---|
| 25 | fn resolve<'ast, 'args, 'errors, R, M>( | 
|---|
| 26 | &'ast self, | 
|---|
| 27 | scope: &mut Scope<'bundle, 'ast, 'args, 'errors, R, M>, | 
|---|
| 28 | ) -> FluentValue<'bundle> | 
|---|
| 29 | where | 
|---|
| 30 | R: Borrow<FluentResource>, | 
|---|
| 31 | M: MemoizerKind; | 
|---|
| 32 | } | 
|---|
| 33 |  | 
|---|
| 34 | /// Resolves an AST node to a string that is written to source `W`. | 
|---|
| 35 | pub(crate) trait WriteValue<'bundle> { | 
|---|
| 36 | /// Resolves an AST node to a string that is written to source `W`. | 
|---|
| 37 | fn write<'ast, 'args, 'errors, W, R, M>( | 
|---|
| 38 | &'ast self, | 
|---|
| 39 | w: &mut W, | 
|---|
| 40 | scope: &mut Scope<'bundle, 'ast, 'args, 'errors, R, M>, | 
|---|
| 41 | ) -> fmt::Result | 
|---|
| 42 | where | 
|---|
| 43 | W: fmt::Write, | 
|---|
| 44 | R: Borrow<FluentResource>, | 
|---|
| 45 | M: MemoizerKind; | 
|---|
| 46 |  | 
|---|
| 47 | /// Writes error information to `W`. This can be used to add FTL errors inline | 
|---|
| 48 | /// to a message. | 
|---|
| 49 | fn write_error<W>(&self, _w: &mut W) -> fmt::Result | 
|---|
| 50 | where | 
|---|
| 51 | W: fmt::Write; | 
|---|
| 52 | } | 
|---|
| 53 |  | 
|---|