From c7f6c6a5339e0a1e7c18fb5414b907946ae6d01e Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Thu, 22 Dec 2016 12:03:58 +0100 Subject: [PATCH] Changed to newest nom version --- Cargo.lock | 8 +++---- Cargo.toml | 6 ++--- src/lib.rs | 2 -- src/parser.rs | 62 +++++++++++++++++++++++++++------------------------ 4 files changed, 40 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0581630c..32425a7e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,13 +1,13 @@ [root] name = "git-journal" -version = "1.1.0" +version = "1.3.0" dependencies = [ "chrono 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.18.0 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "nom 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "nom 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)", @@ -200,7 +200,7 @@ dependencies = [ [[package]] name = "nom" -version = "1.2.4" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -456,7 +456,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ab83497bf8bf4ed2a74259c1c802351fcd67a65baa86394b6ba73c36f4838054" "checksum matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efd7622e3022e1a6eaa602c4cea8912254e5582c9c692e9167714182244801b1" "checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" -"checksum nom 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b8c256fd9471521bcb84c3cdba98921497f1a331cbc15b8030fc63b82050ce" +"checksum nom 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ffc564b2727f758993db55d4ffed0d84bbd7f387a66509516768c8f786bb0b10" "checksum num 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "bde7c03b09e7c6a301ee81f6ddf66d7a28ec305699e3d3b056d2fc56470e3120" "checksum num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "fb24d9bfb3f222010df27995441ded1e954f8f69cd35021f6bef02ca9552fb92" "checksum num-iter 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "287a1c9969a847055e1122ec0ea7a5c5d6f72aad97934e131c83d5c08ab4e45c" diff --git a/Cargo.toml b/Cargo.toml index afc47b17..891e06cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,13 +1,13 @@ [package] name = "git-journal" -version = "1.2.0" +version = "1.3.0" license = "MIT" readme = "README.md" keywords = ["parser", "git", "log", "changelog", "journal"] authors = ["Sascha Grunert "] repository = "https://github.com/saschagrunert/git-journal" homepage = "https://github.com/saschagrunert/git-journal" -documentation = "https://saschagrunert.github.io/git-journal" +documentation = "https://docs.rs/git-journal" description = "The Git Commit Message and Changelog Generation Framework" [lib] @@ -19,7 +19,7 @@ clap = { version = "2", features = ["yaml"] } git2 = "0" lazy_static = "0" log = "0" -nom = { version = "1", features = ["regexp_macros"] } +nom = { version = "2", features = ["regexp_macros"] } regex = "0" rayon = "0" rustc-serialize = "0" diff --git a/src/lib.rs b/src/lib.rs index 0b295ecf..d7d5fd0b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,4 @@ -#![doc(html_root_url = "https://saschagrunert.github.io/git-journal/")] #![deny(missing_docs)] - //! # The Git Commit Message and Changelog Generation Framework //! //! This crate contains the library for the diff --git a/src/parser.rs b/src/parser.rs index e8a448a0..8126c339 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -739,49 +739,53 @@ pub struct Parser { impl Parser { method!(parse_category, self, - chain!( - tag!(self.config.category_delimiters.0.as_str())? ~ + do_parse!( + opt!(tag!(self.config.category_delimiters.0.as_str())) >> p_category: map_res!( re_bytes_find!(&self.config.categories.join("|")), str::from_utf8 - ) ~ - tag!(self.config.category_delimiters.1.as_str())? , - || p_category + ) >> + opt!(tag!(self.config.category_delimiters.1.as_str())) >> + + (p_category) )); method!(parse_list_item, mut self, - chain!( - many0!(space) ~ - tag!("-") ~ - space? ~ - p_category: call_m!(self.parse_category)? ~ - space? ~ - p_tags_rest: map!(rest, Self::parse_and_consume_tags), - || ListElement { + do_parse!( + many0!(space) >> + tag!("-") >> + opt!(space) >> + p_category: opt!(call_m!(self.parse_category)) >> + opt!(space) >> + p_tags_rest: map!(rest, Self::parse_and_consume_tags) >> + + (ListElement { oid: None, category: p_category.unwrap_or("").to_owned(), tags: p_tags_rest.0.clone(), text: p_tags_rest.1.clone(), - } + }) ) ); method!(parse_summary, mut self, - chain!( - p_prefix: separated_pair!(alpha, char!('-'), digit)? ~ - space? ~ - p_category: call_m!(self.parse_category) ~ - space ~ - p_tags_rest: map!(rest, Self::parse_and_consume_tags), - || SummaryElement { - oid: None, - prefix: p_prefix.map_or("".to_owned(), |p| { - format!("{}-{}", str::from_utf8(p.0).unwrap_or(""), str::from_utf8(p.1).unwrap_or("")) - }), - category: p_category.to_owned(), - tags: p_tags_rest.0.clone(), - text: p_tags_rest.1.clone(), - }) + do_parse!( + p_prefix: opt!(separated_pair!(alpha, char!('-'), digit)) >> + opt!(space) >> + p_category: call_m!(self.parse_category) >> + space >> + p_tags_rest: map!(rest, Self::parse_and_consume_tags) >> + + (SummaryElement { + oid: None, + prefix: p_prefix.map_or("".to_owned(), |p| { + format!("{}-{}", str::from_utf8(p.0).unwrap_or(""), str::from_utf8(p.1).unwrap_or("")) + }), + category: p_category.to_owned(), + tags: p_tags_rest.0.clone(), + text: p_tags_rest.1.clone(), + }) + ) ); fn parse_and_consume_tags(input: &[u8]) -> (Vec, String) {