Skip to content

Commit

Permalink
adapt to nom 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tedil committed Feb 12, 2025
1 parent b0dc58b commit 78facb4
Show file tree
Hide file tree
Showing 4 changed files with 178 additions and 146 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ flate2 = "1.0"
log = "0.4"
md-5 = "0.10"
nom = "8.0"
nom-language = "0.1.0"
postgres = { version = "0.19", features = ["with-chrono-0_4"] }
quick_cache = "0.6"
regex = "1.7"
Expand Down
16 changes: 8 additions & 8 deletions src/mapper/cigar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use std::fmt::Display;

use crate::mapper::Error;
use nom::{combinator::all_consuming, multi::many0};
use nom::{combinator::all_consuming, multi::many0, Parser};

/// CIGAR operation as parsed from UTA.
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)]
Expand Down Expand Up @@ -141,12 +141,10 @@ impl Display for CigarString {

pub mod parse {
use nom::{
bytes::complete::take_while_m_n,
character::complete::digit0,
error::{context, VerboseError},
sequence::pair,
IResult,
bytes::complete::take_while_m_n, character::complete::digit0, error::context,
sequence::pair, IResult, Parser,
};
use nom_language::error::VerboseError;

type Res<T, U> = IResult<T, U, VerboseError<T>>;

Expand All @@ -160,7 +158,8 @@ pub mod parse {
context(
"cigar_element",
pair(digit0, take_while_m_n(1, 1, is_cigar_op_char)),
)(input)
)
.parse(input)
.map(|(rest, (count, op))| {
(
rest,
Expand All @@ -173,7 +172,8 @@ pub mod parse {
/// Parse a CIGAR `str` into a real one.
pub fn parse_cigar_string(input: &str) -> Result<CigarString, Error> {
Ok(CigarString::from(
all_consuming(many0(parse::cigar_element))(input)
all_consuming(many0(parse::cigar_element))
.parse(input)
.map_err(|e| Error::InvalidCigarString(e.to_string()))?
.1,
))
Expand Down
Loading

0 comments on commit 78facb4

Please # to comment.