diff --git a/CHANGELOG.md b/CHANGELOG.md index e2b0303..06fdf77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## [Unreleased](https://github.com/dalance/sv-parser/compare/v0.9.0...Unreleased) - ReleaseDate +* [Changed] update nom to 6.0.0 + ## [v0.9.0](https://github.com/dalance/sv-parser/compare/v0.8.3...v0.9.0) - 2020-11-11 * [Added] define option to parse_sv diff --git a/sv-parser-parser/Cargo.toml b/sv-parser-parser/Cargo.toml index abcfa36..268864e 100644 --- a/sv-parser-parser/Cargo.toml +++ b/sv-parser-parser/Cargo.toml @@ -18,12 +18,12 @@ default = [] trace = ["nom-tracable/trace"] [dependencies] -nom = "5" -nom_locate = "2" -nom-greedyerror = "0.2" -nom-packrat = "0.4" -nom-recursive = {version = "0.2", features = ["tracer128"]} -nom-tracable = "0.6" +nom = "6" +nom_locate = "3" +nom-greedyerror = "0.3" +nom-packrat = "0.5" +nom-recursive = {version = "0.3", features = ["tracer128"]} +nom-tracable = "0.7" str-concat = "0.2" sv-parser-macros = {version = "^0.9.0", path = "../sv-parser-macros"} sv-parser-syntaxtree = {version = "^0.9.0", path = "../sv-parser-syntaxtree"} diff --git a/sv-parser-parser/src/lib.rs b/sv-parser-parser/src/lib.rs index 66949ba..aae0169 100644 --- a/sv-parser-parser/src/lib.rs +++ b/sv-parser-parser/src/lib.rs @@ -55,7 +55,7 @@ pub struct SpanInfo { } pub type Span<'a> = nom_locate::LocatedSpan<&'a str, SpanInfo>; -pub type IResult = nom::IResult>; +pub type IResult = nom::IResult>; impl HasRecursiveInfo for SpanInfo { fn get_recursive_info(&self) -> RecursiveInfo { diff --git a/sv-parser-parser/src/utils.rs b/sv-parser-parser/src/utils.rs index 1e2cbab..997a270 100644 --- a/sv-parser-parser/src/utils.rs +++ b/sv-parser-parser/src/utils.rs @@ -2,9 +2,11 @@ use crate::*; // ----------------------------------------------------------------------------- -pub(crate) fn ws<'a, O, F>(f: F) -> impl Fn(Span<'a>) -> IResult, (O, Vec)> +pub(crate) fn ws<'a, O, F>( + mut f: F, +) -> impl FnMut(Span<'a>) -> IResult, (O, Vec)> where - F: Fn(Span<'a>) -> IResult, O>, + F: FnMut(Span<'a>) -> IResult, O>, { move |s: Span<'a>| { let (s, x) = f(s)?; @@ -13,9 +15,11 @@ where } } -pub(crate) fn no_ws<'a, O, F>(f: F) -> impl Fn(Span<'a>) -> IResult, (O, Vec)> +pub(crate) fn no_ws<'a, O, F>( + mut f: F, +) -> impl FnMut(Span<'a>) -> IResult, (O, Vec)> where - F: Fn(Span<'a>) -> IResult, O>, + F: FnMut(Span<'a>) -> IResult, O>, { move |s: Span<'a>| { let (s, x) = f(s)?; @@ -24,7 +28,7 @@ where } #[cfg(not(feature = "trace"))] -pub(crate) fn symbol<'a>(t: &'a str) -> impl Fn(Span<'a>) -> IResult, Symbol> { +pub(crate) fn symbol<'a>(t: &'a str) -> impl FnMut(Span<'a>) -> IResult, Symbol> { move |s: Span<'a>| { let (s, x) = map(ws(map(tag(t), into_locate)), |x| Symbol { nodes: x })(s)?; Ok((s, x)) @@ -32,7 +36,7 @@ pub(crate) fn symbol<'a>(t: &'a str) -> impl Fn(Span<'a>) -> IResult, S } #[cfg(feature = "trace")] -pub(crate) fn symbol<'a>(t: &'a str) -> impl Fn(Span<'a>) -> IResult, Symbol> { +pub(crate) fn symbol<'a>(t: &'a str) -> impl FnMut(Span<'a>) -> IResult, Symbol> { move |s: Span<'a>| { let (depth, s) = nom_tracable::forward_trace(s, &format!("symbol(\"{}\")", t)); let body = || { @@ -45,7 +49,7 @@ pub(crate) fn symbol<'a>(t: &'a str) -> impl Fn(Span<'a>) -> IResult, S } #[cfg(not(feature = "trace"))] -pub(crate) fn symbol_exact<'a>(t: &'a str) -> impl Fn(Span<'a>) -> IResult, Symbol> { +pub(crate) fn symbol_exact<'a>(t: &'a str) -> impl FnMut(Span<'a>) -> IResult, Symbol> { move |s: Span<'a>| { let (s, x) = map(no_ws(map(tag(t), into_locate)), |x| Symbol { nodes: x })(s)?; Ok((s, x)) @@ -53,7 +57,7 @@ pub(crate) fn symbol_exact<'a>(t: &'a str) -> impl Fn(Span<'a>) -> IResult(t: &'a str) -> impl Fn(Span<'a>) -> IResult, Symbol> { +pub(crate) fn symbol_exact<'a>(t: &'a str) -> impl FnMut(Span<'a>) -> IResult, Symbol> { move |s: Span<'a>| { let (depth, s) = nom_tracable::forward_trace(s, &format!("symbol(\"{}\")", t)); let body = || { @@ -66,7 +70,7 @@ pub(crate) fn symbol_exact<'a>(t: &'a str) -> impl Fn(Span<'a>) -> IResult(t: &'a str) -> impl Fn(Span<'a>) -> IResult, Keyword> { +pub(crate) fn keyword<'a>(t: &'a str) -> impl FnMut(Span<'a>) -> IResult, Keyword> { move |s: Span<'a>| { let (s, x) = map( ws(alt(( @@ -80,7 +84,7 @@ pub(crate) fn keyword<'a>(t: &'a str) -> impl Fn(Span<'a>) -> IResult, } #[cfg(feature = "trace")] -pub(crate) fn keyword<'a>(t: &'a str) -> impl Fn(Span<'a>) -> IResult, Keyword> { +pub(crate) fn keyword<'a>(t: &'a str) -> impl FnMut(Span<'a>) -> IResult, Keyword> { move |s: Span<'a>| { let (depth, s) = nom_tracable::forward_trace(s, &format!("keyword(\"{}\")", t)); let body = || { @@ -99,9 +103,9 @@ pub(crate) fn keyword<'a>(t: &'a str) -> impl Fn(Span<'a>) -> IResult, } #[cfg(not(feature = "trace"))] -pub(crate) fn paren<'a, O, F>(f: F) -> impl Fn(Span<'a>) -> IResult, Paren> +pub(crate) fn paren<'a, O, F>(mut f: F) -> impl FnMut(Span<'a>) -> IResult, Paren> where - F: Fn(Span<'a>) -> IResult, O>, + F: FnMut(Span<'a>) -> IResult, O>, { move |s: Span<'a>| { let (s, a) = symbol("(")(s)?; @@ -112,13 +116,13 @@ where } #[cfg(feature = "trace")] -pub(crate) fn paren<'a, O, F>(f: F) -> impl Fn(Span<'a>) -> IResult, Paren> +pub(crate) fn paren<'a, O, F>(mut f: F) -> impl FnMut(Span<'a>) -> IResult, Paren> where - F: Fn(Span<'a>) -> IResult, O>, + F: FnMut(Span<'a>) -> IResult, O>, { move |s: Span<'a>| { let (depth, s) = nom_tracable::forward_trace(s, "paren"); - let body = || { + let mut body = || { let (s, a) = symbol("(")(s)?; let (s, b) = f(s)?; let (s, c) = symbol(")")(s)?; @@ -130,9 +134,9 @@ where } #[cfg(not(feature = "trace"))] -pub(crate) fn paren_exact<'a, O, F>(f: F) -> impl Fn(Span<'a>) -> IResult, Paren> +pub(crate) fn paren_exact<'a, O, F>(mut f: F) -> impl FnMut(Span<'a>) -> IResult, Paren> where - F: Fn(Span<'a>) -> IResult, O>, + F: FnMut(Span<'a>) -> IResult, O>, { move |s: Span<'a>| { let (s, a) = symbol("(")(s)?; @@ -143,13 +147,13 @@ where } #[cfg(feature = "trace")] -pub(crate) fn paren_exact<'a, O, F>(f: F) -> impl Fn(Span<'a>) -> IResult, Paren> +pub(crate) fn paren_exact<'a, O, F>(mut f: F) -> impl FnMut(Span<'a>) -> IResult, Paren> where - F: Fn(Span<'a>) -> IResult, O>, + F: FnMut(Span<'a>) -> IResult, O>, { move |s: Span<'a>| { let (depth, s) = nom_tracable::forward_trace(s, "paren"); - let body = || { + let mut body = || { let (s, a) = symbol("(")(s)?; let (s, b) = f(s)?; let (s, c) = symbol_exact(")")(s)?; @@ -161,9 +165,9 @@ where } #[cfg(not(feature = "trace"))] -pub(crate) fn bracket<'a, O, F>(f: F) -> impl Fn(Span<'a>) -> IResult, Bracket> +pub(crate) fn bracket<'a, O, F>(mut f: F) -> impl FnMut(Span<'a>) -> IResult, Bracket> where - F: Fn(Span<'a>) -> IResult, O>, + F: FnMut(Span<'a>) -> IResult, O>, { move |s: Span<'a>| { let (s, a) = symbol("[")(s)?; @@ -174,13 +178,13 @@ where } #[cfg(feature = "trace")] -pub(crate) fn bracket<'a, O, F>(f: F) -> impl Fn(Span<'a>) -> IResult, Bracket> +pub(crate) fn bracket<'a, O, F>(mut f: F) -> impl FnMut(Span<'a>) -> IResult, Bracket> where - F: Fn(Span<'a>) -> IResult, O>, + F: FnMut(Span<'a>) -> IResult, O>, { move |s: Span<'a>| { let (depth, s) = nom_tracable::forward_trace(s, "bracket"); - let body = || { + let mut body = || { let (s, a) = symbol("[")(s)?; let (s, b) = f(s)?; let (s, c) = symbol("]")(s)?; @@ -192,9 +196,9 @@ where } #[cfg(not(feature = "trace"))] -pub(crate) fn brace<'a, O, F>(f: F) -> impl Fn(Span<'a>) -> IResult, Brace> +pub(crate) fn brace<'a, O, F>(mut f: F) -> impl FnMut(Span<'a>) -> IResult, Brace> where - F: Fn(Span<'a>) -> IResult, O>, + F: FnMut(Span<'a>) -> IResult, O>, { move |s: Span<'a>| { let (s, a) = symbol("{")(s)?; @@ -205,13 +209,13 @@ where } #[cfg(feature = "trace")] -pub(crate) fn brace<'a, O, F>(f: F) -> impl Fn(Span<'a>) -> IResult, Brace> +pub(crate) fn brace<'a, O, F>(mut f: F) -> impl FnMut(Span<'a>) -> IResult, Brace> where - F: Fn(Span<'a>) -> IResult, O>, + F: FnMut(Span<'a>) -> IResult, O>, { move |s: Span<'a>| { let (depth, s) = nom_tracable::forward_trace(s, "brace"); - let body = || { + let mut body = || { let (s, a) = symbol("{")(s)?; let (s, b) = f(s)?; let (s, c) = symbol("}")(s)?; @@ -224,10 +228,10 @@ where #[cfg(not(feature = "trace"))] pub(crate) fn apostrophe_brace<'a, O, F>( - f: F, -) -> impl Fn(Span<'a>) -> IResult, ApostropheBrace> + mut f: F, +) -> impl FnMut(Span<'a>) -> IResult, ApostropheBrace> where - F: Fn(Span<'a>) -> IResult, O>, + F: FnMut(Span<'a>) -> IResult, O>, { move |s: Span<'a>| { let (s, a) = symbol("'{")(s)?; @@ -239,14 +243,14 @@ where #[cfg(feature = "trace")] pub(crate) fn apostrophe_brace<'a, O, F>( - f: F, -) -> impl Fn(Span<'a>) -> IResult, ApostropheBrace> + mut f: F, +) -> impl FnMut(Span<'a>) -> IResult, ApostropheBrace> where - F: Fn(Span<'a>) -> IResult, O>, + F: FnMut(Span<'a>) -> IResult, O>, { move |s: Span<'a>| { let (depth, s) = nom_tracable::forward_trace(s, "apostrophe_brace"); - let body = || { + let mut body = || { let (s, a) = symbol("'{")(s)?; let (s, b) = f(s)?; let (s, c) = symbol("}")(s)?; @@ -258,12 +262,12 @@ where } pub(crate) fn list<'a, O1, O2, F, G>( - f: F, - g: G, -) -> impl Fn(Span<'a>) -> IResult, List> + mut f: F, + mut g: G, +) -> impl FnMut(Span<'a>) -> IResult, List> where - F: Fn(Span<'a>) -> IResult, O1>, - G: Fn(Span<'a>) -> IResult, O2>, + F: FnMut(Span<'a>) -> IResult, O1>, + G: FnMut(Span<'a>) -> IResult, O2>, { move |s: Span<'a>| { let (s, a) = g(s)?; @@ -282,14 +286,14 @@ where } pub(crate) fn triple<'a, O1, O2, O3, F, G, H>( - f: F, - g: G, - h: H, -) -> impl Fn(Span<'a>) -> IResult, (O1, O2, O3)> + mut f: F, + mut g: G, + mut h: H, +) -> impl FnMut(Span<'a>) -> IResult, (O1, O2, O3)> where - F: Fn(Span<'a>) -> IResult, O1>, - G: Fn(Span<'a>) -> IResult, O2>, - H: Fn(Span<'a>) -> IResult, O3>, + F: FnMut(Span<'a>) -> IResult, O1>, + G: FnMut(Span<'a>) -> IResult, O2>, + H: FnMut(Span<'a>) -> IResult, O3>, { move |s: Span<'a>| { let (s, x) = f(s)?; diff --git a/sv-parser-pp/Cargo.toml b/sv-parser-pp/Cargo.toml index 480916f..2d7d4b4 100644 --- a/sv-parser-pp/Cargo.toml +++ b/sv-parser-pp/Cargo.toml @@ -18,8 +18,8 @@ default = [] trace = ["sv-parser-parser/trace"] [dependencies] -nom = "5" -nom-greedyerror = "0.2" +nom = "6" +nom-greedyerror = "0.3" sv-parser-error = {version = "^0.9.0", path = "../sv-parser-error"} sv-parser-parser = {version = "^0.9.0", path = "../sv-parser-parser"} sv-parser-syntaxtree = {version = "^0.9.0", path = "../sv-parser-syntaxtree"} diff --git a/sv-parser/Cargo.toml b/sv-parser/Cargo.toml index 488cd6d..cadb770 100644 --- a/sv-parser/Cargo.toml +++ b/sv-parser/Cargo.toml @@ -23,8 +23,8 @@ default = [] trace = ["sv-parser-parser/trace"] [dependencies] -nom = "5" -nom-greedyerror = "0.2" +nom = "6" +nom-greedyerror = "0.3" sv-parser-error = {version = "^0.9.0", path = "../sv-parser-error"} sv-parser-parser = {version = "^0.9.0", path = "../sv-parser-parser"} sv-parser-pp = {version = "^0.9.0", path = "../sv-parser-pp"} diff --git a/sv-parser/benches/parse_sv_bench.rs b/sv-parser/benches/parse_sv_bench.rs index 4689f3e..d2afd51 100644 --- a/sv-parser/benches/parse_sv_bench.rs +++ b/sv-parser/benches/parse_sv_bench.rs @@ -22,7 +22,7 @@ fn test1(b: &mut Bencher) { let includes: Vec = Vec::new(); let path = get_path("test1.sv"); b.iter(|| { - let _ = parse_sv(&path, &defines, &includes, false); + let _ = parse_sv(&path, &defines, &includes, false, false); }); } @@ -32,6 +32,6 @@ fn test2(b: &mut Bencher) { let includes: Vec = Vec::new(); let path = get_path("test2.sv"); b.iter(|| { - let _ = parse_sv(&path, &defines, &includes, false); + let _ = parse_sv(&path, &defines, &includes, false, false); }); } diff --git a/sv-parser/benches/parse_sv_criterion.rs b/sv-parser/benches/parse_sv_criterion.rs index e64c4c7..4141fd8 100644 --- a/sv-parser/benches/parse_sv_criterion.rs +++ b/sv-parser/benches/parse_sv_criterion.rs @@ -26,7 +26,7 @@ fn gen_benchmark_group(c: &mut Criterion, s: &str) { let mut group = c.benchmark_group(s); group.throughput(Throughput::Bytes(size)); group.bench_function(s, |b| { - b.iter_with_large_drop(|| parse_sv(&path, &defines, &includes, false)) + b.iter_with_large_drop(|| parse_sv(&path, &defines, &includes, false, false)) }); group.finish(); }