From 99b28d8f6e2106fcd0ef8c2c5955982afc6f8b05 Mon Sep 17 00:00:00 2001 From: dalance Date: Wed, 1 Apr 2020 15:34:48 +0900 Subject: [PATCH] Update nom_locate to 2.0.0 --- CHANGELOG.md | 1 + sv-parser-parser/Cargo.toml | 14 +++++++------- sv-parser-parser/src/lib.rs | 2 +- sv-parser-parser/src/utils.rs | 20 +++++++++----------- sv-parser-pp/Cargo.toml | 4 ++-- sv-parser/Cargo.toml | 4 ++-- 6 files changed, 22 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 813f653..9a6af1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## [Unreleased](https://github.com/dalance/sv-parser/compare/v0.6.4...Unreleased) - ReleaseDate * [Fixed] casting parse error [#8](https://github.com/dalance/sv-parser/issues/8) +* [Changed] update nom_locate to 2.0.0 ## [v0.6.4](https://github.com/dalance/sv-parser/compare/v0.6.3...v0.6.4) - 2020-03-12 diff --git a/sv-parser-parser/Cargo.toml b/sv-parser-parser/Cargo.toml index fec31d1..abb0a02 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.0.0" -nom_locate = "1.0.0" -nom-greedyerror = "0.1.0" -nom-packrat = "0.3.0" -nom-recursive = {version = "0.1.1", features = ["tracer128"]} -nom-tracable = "0.4.1" -str-concat = "0.2.0" +nom = "5" +nom_locate = "2" +nom-greedyerror = "0.2" +nom-packrat = "0.4" +nom-recursive = {version = "0.2", features = ["tracer128"]} +nom-tracable = "0.5" +str-concat = "0.2" sv-parser-macros = {version = "^0.6.4", path = "../sv-parser-macros"} sv-parser-syntaxtree = {version = "^0.6.4", path = "../sv-parser-syntaxtree"} diff --git a/sv-parser-parser/src/lib.rs b/sv-parser-parser/src/lib.rs index b50ff79..66949ba 100644 --- a/sv-parser-parser/src/lib.rs +++ b/sv-parser-parser/src/lib.rs @@ -54,7 +54,7 @@ pub struct SpanInfo { pub recursive_info: RecursiveInfo, } -pub type Span<'a> = nom_locate::LocatedSpanEx<&'a str, SpanInfo>; +pub type Span<'a> = nom_locate::LocatedSpan<&'a str, SpanInfo>; pub type IResult = nom::IResult>; impl HasRecursiveInfo for SpanInfo { diff --git a/sv-parser-parser/src/utils.rs b/sv-parser-parser/src/utils.rs index 850f09c..7918a8a 100644 --- a/sv-parser-parser/src/utils.rs +++ b/sv-parser-parser/src/utils.rs @@ -427,14 +427,12 @@ pub(crate) fn current_version() -> Option { // ----------------------------------------------------------------------------- pub(crate) fn concat<'a>(a: Span<'a>, b: Span<'a>) -> Option> { - let c = unsafe { str_concat::concat(a.fragment, b.fragment) }; + let c = unsafe { str_concat::concat(a.fragment(), b.fragment()) }; if let Ok(c) = c { - Some(Span { - offset: a.offset, - line: a.line, - fragment: c, - extra: a.extra, - }) + let ret = unsafe { + Span::new_from_raw_offset(a.location_offset(), a.location_line(), c, a.extra) + }; + Some(ret) } else { None } @@ -454,7 +452,7 @@ pub(crate) fn is_keyword(s: &Span) -> bool { None => KEYWORDS_1800_2017, }; for k in keywords { - if &s.fragment == k { + if s.fragment() == k { return true; } } @@ -463,8 +461,8 @@ pub(crate) fn is_keyword(s: &Span) -> bool { pub(crate) fn into_locate(s: Span) -> Locate { Locate { - offset: s.offset, - line: s.line, - len: s.fragment.len(), + offset: s.location_offset(), + line: s.location_line(), + len: s.fragment().len(), } } diff --git a/sv-parser-pp/Cargo.toml b/sv-parser-pp/Cargo.toml index 23c03ba..4c2cc0c 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.0.0" -nom-greedyerror = "0.1.0" +nom = "5" +nom-greedyerror = "0.2" sv-parser-error = {version = "^0.6.4", path = "../sv-parser-error"} sv-parser-parser = {version = "^0.6.4", path = "../sv-parser-parser"} sv-parser-syntaxtree = {version = "^0.6.4", path = "../sv-parser-syntaxtree"} diff --git a/sv-parser/Cargo.toml b/sv-parser/Cargo.toml index 484384c..491c850 100644 --- a/sv-parser/Cargo.toml +++ b/sv-parser/Cargo.toml @@ -23,8 +23,8 @@ default = [] trace = ["sv-parser-parser/trace"] [dependencies] -nom = "5.0.0" -nom-greedyerror = "0.1.0" +nom = "5" +nom-greedyerror = "0.2" sv-parser-error = {version = "^0.6.4", path = "../sv-parser-error"} sv-parser-parser = {version = "^0.6.4", path = "../sv-parser-parser"} sv-parser-pp = {version = "^0.6.4", path = "../sv-parser-pp"}