pub struct SyntaxError {
pub code: u16,
pub message: String,
pub offset: TextSize,
}Expand description
A single syntax error record. Spec §4.3 + §10.
cyrs-syntax does not depend on cyrs-diag (§3.1), so this is a
local stand-in carrying just the minimum a later pass needs to lift it
into a full Diagnostic: a stable numeric code (matching the
DiagCode discriminants in cyrs-diag), a human-readable message,
and the byte offset at which it was emitted.
Embedders should not match on the raw u16 code field — names
survive renumbering, magic numbers do not (cy-emb3). When
cyrs-diag is on the dependency graph (typically via cyrs-db),
lift the numeric to the typed enum:
use cyrs_diag::DiagCode;
match DiagCode::from(err) {
DiagCode::E0007 => { /* expected statement */ }
_ => { /* other syntax codes */ }
}Fields§
§code: u16Numeric value of the DiagCode discriminant (e.g. 3 for E0003).
message: StringHuman-readable message (rustc-style lower-case initial, no trailing period).
offset: TextSizeByte offset at which the error was emitted. Typically the position of the offending token.
Trait Implementations§
Source§impl Clone for SyntaxError
impl Clone for SyntaxError
Source§fn clone(&self) -> SyntaxError
fn clone(&self) -> SyntaxError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SyntaxError
impl Debug for SyntaxError
Source§impl Display for SyntaxError
impl Display for SyntaxError
Source§impl Error for SyntaxError
impl Error for SyntaxError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()