diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e119a9..4a96f04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## [Unreleased](https://github.com/dalance/sv-parser/compare/v0.2.1...Unreleased) - ReleaseDate +* [Added] unwrap_locate macro + ## [v0.2.1](https://github.com/dalance/sv-parser/compare/v0.2.0...v0.2.1) - 2019-10-28 * [Added] get_origin to SyntaxTree diff --git a/sv-parser/src/lib.rs b/sv-parser/src/lib.rs index 4b880c7..06babb7 100644 --- a/sv-parser/src/lib.rs +++ b/sv-parser/src/lib.rs @@ -155,3 +155,19 @@ macro_rules! unwrap_node { unwrap() }}; } + +#[macro_export] +macro_rules! unwrap_locate { + ($n:expr) => {{ + let unwrap = || { + for x in $n { + match x { + sv_parser::RefNode::Locate(x) => return Some(x), + _ => (), + } + } + None + }; + unwrap() + }}; +}