Skip to main content

flm_core/stdlib/features/annotations/
diagnostics.rs

1//! The condition the `annotations` feature reports, identified as
2//! `flm.annotations.<condition>`, with the recovery its documentation states
3//! ([recovery](crate::stdlib::backends::lowering::error)). A condition is the
4//! typed body of a diagnostic
5//! ([diagnostics](crate::guide::concepts_overview#diagnostics)).
6//!
7//! The parser of an annotator's argument
8//! ([`AnnotationParser`](super::AnnotationParser)) reports [`Unterminated`]
9//! while the document is parsed. Every other error in an annotation is
10//! reported by the language itself: an unknown command (a stray `\endphf`, or
11//! `\phf` with no annotator configured) and an unclosed group.
12
13use techy::error::DiagnosticInfo;
14
15/// Condition `flm.annotations.unterminated`, an Error: a passage opened by an
16/// annotator's command in its third form, `\phf …`, is not closed by the
17/// closing command `\endphf` before the input ends, or before the group or
18/// environment enclosing the annotation ends. Reported over the passage read.
19/// Recovery: the passage is what was read up to there, highlighted as if it
20/// had been closed.
21#[derive(Debug, Clone, PartialEq, Eq, DiagnosticInfo)]
22#[diagnostic(
23    id = "flm.annotations.unterminated",
24    message = "\\{command} must be closed by \\{end_command} within the same group or environment"
25)]
26pub struct Unterminated {
27    /// The name of the annotator's command, `phf`.
28    pub command: String,
29    /// The name of the closing command that was expected, `endphf`.
30    pub end_command: String,
31}