Skip to content

Commit

Permalink
Changed to newest nom version
Browse files Browse the repository at this point in the history
  • Loading branch information
Sascha Grunert authored and Sascha Grunert committed Dec 22, 2016
1 parent 3c6b638 commit c7f6c6a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 38 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <mail@saschagruenrt.de>"]
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]
Expand All @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
62 changes: 33 additions & 29 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,49 +739,53 @@ pub struct Parser {

impl Parser {
method!(parse_category<Self, &[u8], &str>, 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<Self, &[u8], ListElement>, 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<Self, &[u8], SummaryElement>, 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>, String) {
Expand Down

0 comments on commit c7f6c6a

Please sign in to comment.