Skip to content

Commit fb7c92b

Browse files
committed
refactor(parser): refactor number parsing to support generic number types
1 parent 0940bb1 commit fb7c92b

File tree

3 files changed

+208
-87
lines changed

3 files changed

+208
-87
lines changed

Diff for: Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ span = []
1717

1818
[dependencies]
1919
miette = "7.2.0"
20+
num = "0.4.2"
2021
thiserror = "1.0.40"
2122
winnow = { version = "0.6.20", features = ["alloc", "unstable-recover"] }
2223

Diff for: src/error.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub struct KdlDiagnostic {
7878
pub kind: KdlErrorKind,
7979
}
8080

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

94+
/// Tried to parse a negative number as an unsigned integer.
95+
#[error("Tried to parse a negative number as an unsigned integer.")]
96+
#[diagnostic(code(kdl::negative_unsigned))]
97+
NegativeUnsignedError,
98+
9499
/// Generic parsing error. The given context string denotes the component
95100
/// that failed to parse.
96101
#[error("Expected {0}.")]

0 commit comments

Comments
 (0)