Skip to content

Commit

Permalink
refactor(parser): refactor number parsing to support generic number t…
Browse files Browse the repository at this point in the history
…ypes
  • Loading branch information
zkat committed Nov 30, 2024
1 parent 0940bb1 commit 05a4c4f
Show file tree
Hide file tree
Showing 2 changed files with 207 additions and 87 deletions.
7 changes: 6 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub struct KdlDiagnostic {
pub kind: KdlErrorKind,
}

/// A type reprenting additional information specific to the type of error being returned.
/// A type representing additional information specific to the type of error being returned.
#[derive(Debug, Diagnostic, Clone, Eq, PartialEq, Error)]
pub enum KdlErrorKind {
/// An error occurred while parsing an integer.
Expand All @@ -91,6 +91,11 @@ pub enum KdlErrorKind {
#[diagnostic(code(kdl::parse_float))]
ParseFloatError(ParseFloatError),

/// Tried to parse a negative number as an unsigned integer.
#[error("Tried to parse a negative number as an unsigned integer.")]
#[diagnostic(code(kdl::negative_unsigned))]
NegativeUnsignedError,

/// Generic parsing error. The given context string denotes the component
/// that failed to parse.
#[error("Expected {0}.")]
Expand Down
Loading

0 comments on commit 05a4c4f

Please sign in to comment.