-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds support for floats to the LazyRawTextReader
#612
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #612 +/- ##
==========================================
- Coverage 81.72% 81.64% -0.08%
==========================================
Files 118 118
Lines 20969 21147 +178
Branches 20969 21147 +178
==========================================
+ Hits 17137 17266 +129
- Misses 2193 2225 +32
- Partials 1639 1656 +17
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗺️ PR tour
|(matched_float, length)| { | ||
EncodedTextValue::new(MatchedValue::Float(matched_float), self.offset(), length) | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗺️ When we match a float
, record information about the match (offset, length, what kind of float) in case we eventually parse it.
fn match_float(self) -> IonParseResult<'data, MatchedFloat> { | ||
alt(( | ||
Self::match_float_special_value, | ||
Self::match_float_numeric_value, | ||
))(self) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗺️ This is the entry point for parsingfloat
s, which have two kinds of syntax: keyword special values (+inf
, -inf
, nan
), and numeric values. Numeric values come in a big variety of shapes.
/// A partially parsed Ion float. | ||
#[derive(Copy, Clone, Debug, PartialEq)] | ||
pub(crate) enum MatchedFloat { | ||
/// `+inf` | ||
PositiveInfinity, | ||
/// `-inf` | ||
NegativeInfinity, | ||
/// `nan` | ||
NotANumber, | ||
/// Any numeric float value | ||
Numeric, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗺️ PR #609 introduced an EncodedValue
struct that stores information like offset and length, but which also has a MatchedValue
enum field. This is one of the variants of MatchedValue
, and remembers the kind of float
we encountered in case we read it later. The offset and length will be available in the parent data structure.
src/lazy/text/parse_result.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗺️ Changes in this file are reorganizing how various error types are converted into one another for easier bubbling up. No real logic changes.
This PR builds on #609. Adds support for matching/reading
float
values in theLazyRawTextReader
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.