Skip to content

Commit

Permalink
Merge branch 'main' into feature/issues-1223
Browse files Browse the repository at this point in the history
  • Loading branch information
ikrivosheev committed Jan 5, 2023
2 parents 7fb5931 + dc5601d commit fdc7c68
Show file tree
Hide file tree
Showing 61 changed files with 2,401 additions and 1,031 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @Geal
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: CI
on: [push, pull_request]

env:
RUST_MINVERSION: 1.41.1
RUST_MINVERSION: 1.56.0
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10

Expand All @@ -18,7 +18,7 @@ jobs:
- stable
- beta
- nightly
- 1.48.0
- 1.56.0

features:
- ''
Expand Down
60 changes: 59 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,61 @@

### Changed

## 7.1.2 - 2023-01-01

### Thanks

- @joubs
- @Fyko
- @LoganDark
- @darnuria
- @jkugelman
- @barower
- @puzzlewolf
- @epage
- @cky
- @wolthom
- @w1ll-i-code

### Changed

- documentation fixes
- tests fixes
- limit the initial capacity of the result vector of `many_m_n` to 64kiB
- bits parser now accept `Parser` implementors instead of only functions

### Added

- implement `Tuple` parsing for the unit type as a special case
- implement `ErrorConvert` on the unit type to make it usable as error type for bits parsers
- bool parser for bits input

## 7.1.1 - 2022-03-14

### Thanks

- @ThomasdenH
- @@SphinxKnight
- @irevoire
- @doehyunbaek
- @pxeger
- @punkeel
- @max-sixty
- @Xiretza
- @5c077m4n
- @erihsu
- @TheNeikos
- @LoganDark
- @nickelc
- @chotchki
- @ctrlcctrlv


### Changed

- documentation fixes
- more examples

## 7.1.0 - 2021-11-04

### Thanks
Expand Down Expand Up @@ -1420,7 +1475,10 @@ Considering the number of changes since the last release, this version can conta

## Compare code

* [unreleased](https://github.com/Geal/nom/compare/7.0.0...HEAD)
* [unreleased](https://github.com/Geal/nom/compare/7.1.2...HEAD)
* [7.1.2](https://github.com/Geal/nom/compare/7.1.1...7.1.2)
* [7.1.1](https://github.com/Geal/nom/compare/7.1.0...7.1.1)
* [7.1.0](https://github.com/Geal/nom/compare/7.0.0...7.1.0)
* [7.0.0](https://github.com/Geal/nom/compare/6.2.1...7.0.0)
* [6.2.1](https://github.com/Geal/nom/compare/6.2.0...6.2.1)
* [6.2.0](https://github.com/Geal/nom/compare/6.1.2...6.2.0)
Expand Down
16 changes: 13 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

name = "nom"
version = "7.1.1"
version = "7.1.2"
authors = [ "contact@geoffroycouprie.com" ]
description = "A byte-oriented, zero-copy, parser combinators library"
license = "MIT"
Expand All @@ -10,11 +10,11 @@ readme = "README.md"
documentation = "https://docs.rs/nom"
keywords = ["parser", "parser-combinators", "parsing", "streaming", "bit"]
categories = ["parsing"]
edition = "2018"
edition = "2021"
autoexamples = false

# also update in README.md (badge and "Rust version requirements" section)
rust-version = "1.48"
rust-version = "1.56"

include = [
"CHANGELOG.md",
Expand Down Expand Up @@ -104,11 +104,21 @@ name = "reborrow_fold"
name = "fnmut"
required-features = ["alloc"]

[[example]]
name = "custom_error"
required-features = ["alloc"]
path = "examples/custom_error.rs"

[[example]]
name = "json"
required-features = ["alloc"]
path = "examples/json.rs"

[[example]]
name = "json_iterator"
required-features = ["alloc"]
path = "examples/json_iterator.rs"

[[example]]
name = "iterator"
path = "examples/iterator.rs"
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Build Status](https://github.com/Geal/nom/actions/workflows/ci.yml/badge.svg)](https://github.com/Geal/nom/actions/workflows/ci.yml)
[![Coverage Status](https://coveralls.io/repos/github/Geal/nom/badge.svg?branch=main)](https://coveralls.io/github/Geal/nom?branch=main)
[![Crates.io Version](https://img.shields.io/crates/v/nom.svg)](https://crates.io/crates/nom)
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.48.0+-lightgray.svg)](#rust-version-requirements-msrv)
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.56.0+-lightgray.svg)](#rust-version-requirements-msrv)

nom is a parser combinators library written in Rust. Its goal is to provide tools
to build safe parsers without compromising the speed or memory consumption. To
Expand Down Expand Up @@ -46,7 +46,7 @@ use nom::{
IResult,
bytes::complete::{tag, take_while_m_n},
combinator::map_res,
sequence::tuple
Parser,
};

#[derive(Debug,PartialEq)]
Expand All @@ -73,7 +73,7 @@ fn hex_primary(input: &str) -> IResult<&str, u8> {

fn hex_color(input: &str) -> IResult<&str, Color> {
let (input, _) = tag("#")(input)?;
let (input, (red, green, blue)) = tuple((hex_primary, hex_primary, hex_primary))(input)?;
let (input, (red, green, blue)) = (hex_primary, hex_primary, hex_primary).parse(input)?;

Ok((input, Color { red, green, blue }))
}
Expand Down Expand Up @@ -207,7 +207,7 @@ Some benchmarks are available on [Github](https://github.com/Geal/nom_benchmarks

## Rust version requirements (MSRV)

The 7.0 series of nom supports **Rustc version 1.48 or greater**. It is known to work properly on Rust 1.41.1 but there is no guarantee it will stay the case through this major release.
The 7.0 series of nom supports **Rustc version 1.56 or greater**.

The current policy is that this will only be updated in the next major nom release.

Expand Down
11 changes: 11 additions & 0 deletions benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ name = "http"
path = "benches/http.rs"
harness = false

[[bench]]
name = "http_streaming"
path = "benches/http_streaming.rs"
harness = false


[[bench]]
name = "ini"
path = "benches/ini.rs"
Expand All @@ -42,3 +48,8 @@ harness = false
name = "json"
path = "benches/json.rs"
harness = false

[[bench]]
name = "json_streaming"
path = "benches/json_streaming.rs"
harness = false
8 changes: 5 additions & 3 deletions benchmarks/benches/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use nom::{
branch::alt,
character::complete::{char, digit1, one_of, space0},
combinator::map_res,
multi::fold_many0,
multi::fold,
sequence::{delimited, pair},
IResult,
};
Expand Down Expand Up @@ -37,7 +37,8 @@ fn factor(input: &[u8]) -> IResult<&[u8], i64> {
// the math by folding everything
fn term(input: &[u8]) -> IResult<&[u8], i64> {
let (input, init) = factor(input)?;
fold_many0(
fold(
0..,
pair(one_of("*/"), factor),
move || init,
|acc, (op, val)| {
Expand All @@ -52,7 +53,8 @@ fn term(input: &[u8]) -> IResult<&[u8], i64> {

fn expr(input: &[u8]) -> IResult<&[u8], i64> {
let (input, init) = term(input)?;
fold_many0(
fold(
0..,
pair(one_of("+-"), term),
move || init,
|acc, (op, val)| {
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/benches/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

use criterion::*;
use nom::{IResult, bytes::complete::{tag, take_while1}, character::complete::{line_ending, char}, multi::many1};
use nom::{IResult, bytes::complete::{tag, take_while1}, character::complete::{line_ending, char}, multi::many};

#[cfg_attr(rustfmt, rustfmt_skip)]
#[derive(Debug)]
Expand Down Expand Up @@ -96,14 +96,14 @@ fn message_header_value(input: &[u8]) -> IResult<&[u8], &[u8]> {
fn message_header(input: &[u8]) -> IResult<&[u8], Header<'_>> {
let (input, name) = take_while1(is_token)(input)?;
let (input, _) = char(':')(input)?;
let (input, value) = many1(message_header_value)(input)?;
let (input, value) = many(1.., message_header_value)(input)?;

Ok((input, Header{ name, value }))
}

fn request(input: &[u8]) -> IResult<&[u8], (Request<'_>, Vec<Header<'_>>)> {
let (input, req) = request_line(input)?;
let (input, h) = many1(message_header)(input)?;
let (input, h) = many(1.., message_header)(input)?;
let (input, _) = line_ending(input)?;

Ok((input, (req, h)))
Expand Down

0 comments on commit fdc7c68

Please sign in to comment.