Skip to content
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

Update Lexical Version #1100

Closed
Alexhuszagh opened this issue Jan 7, 2020 · 0 comments
Closed

Update Lexical Version #1100

Alexhuszagh opened this issue Jan 7, 2020 · 0 comments

Comments

@Alexhuszagh
Copy link
Contributor

Alexhuszagh commented Jan 7, 2020

Hi, and thanks for all the hard work on Nom.

Prerequisites

Nom uses a dependency I maintain, lexical-core, which used to define a C-API and Rust API within a single crate. Due to symbol issues and to remove unnecessary functionality from lexical-core, the C-API was separated into a new crate. Other bug fixes have since been implemented, for example, in ensuring full standard compliance in parsing weird edge-cases like ". ", among others.

Issues

Other uses have reported issues with older versions of lexical:

Undefined Symbols when building on Windows
Symbol Issues when used in a proc macro
Undefined Symbols when building on Windows
Incorrect result with parsing ". "

Versions

To support Rustc versions 1.31+, as Nom currently does, please use lexical-core = "0.6" in Cargo.toml, which supports any version of Rustc >= 1.24.0.

F64 Complete

The patch for the complete, f64 parser would be:

#[cfg(feature = "lexical")]
pub fn double<T, E:ParseError<T>>(input: T) -> IResult<T, f64, E>
where
  T: crate::traits::AsBytes + InputLength + Slice<RangeFrom<usize>>,
{
  match ::lexical_core::parse_partial(input.as_bytes()) {
    Ok((value, processed)) => Ok((input.slice(processed..), value)),
    Err(_) => Err(Err::Error(E::from_error_kind(input, ErrorKind::Float)))
  }
}

F64 Streaming

The patch for the streaming, f64 parser would be:

#[cfg(feature = "lexical")]
pub fn double<T, E:ParseError<T>>(input: T) -> IResult<T, f64, E>
where
  T: crate::traits::AsBytes + InputLength + Slice<RangeFrom<usize>>,
{
  match ::lexical_core::parse_partial(input.as_bytes()) {
    Ok((value, processed)) => {
      if (processed == input.input_len()) {
        Err(Err::Incomplete(Needed::Unknown))
      } else {
        Ok((input.slice(processed..), value))
      }
    },
    Err(_) => Err(Err::Error(E::from_error_kind(input, ErrorKind::Float)))
  }
}
Alexhuszagh added a commit to Alexhuszagh/nom that referenced this issue Jan 7, 2020
Geal pushed a commit that referenced this issue Feb 24, 2020
Patches:
- #1100
- #1080
- #1066
- And a few upstream issues.
@Geal Geal closed this as completed Feb 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants