diff --git a/CHANGELOG.md b/CHANGELOG.md index 5114602..479075f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## [Unreleased](https://github.com/dalance/sv-parser/compare/v0.3.2...Unreleased) - ReleaseDate * [Fixed] define arument +* [Fixed] text macro identifier ## [v0.3.2](https://github.com/dalance/sv-parser/compare/v0.2.1...v0.3.2) - 2019-10-29 diff --git a/sv-parser-parser/src/general/compiler_directives.rs b/sv-parser-parser/src/general/compiler_directives.rs index 6eb45ef..cd5ed41 100644 --- a/sv-parser-parser/src/general/compiler_directives.rs +++ b/sv-parser-parser/src/general/compiler_directives.rs @@ -239,7 +239,9 @@ pub(crate) fn default_text(s: Span) -> IResult { #[packrat_parser] pub(crate) fn text_macro_usage(s: Span) -> IResult { let (s, a) = symbol("`")(s)?; + begin_keywords("directive"); let (s, b) = text_macro_identifier(s)?; + end_keywords(); let (s, c) = opt(paren(list_of_actual_arguments))(s)?; Ok((s, TextMacroUsage { nodes: (a, b, c) })) } diff --git a/sv-parser-parser/src/keywords.rs b/sv-parser-parser/src/keywords.rs index 7f9f03d..36285c9 100644 --- a/sv-parser-parser/src/keywords.rs +++ b/sv-parser-parser/src/keywords.rs @@ -1444,3 +1444,28 @@ pub(crate) const KEYWORDS_1800_2017: &[&str] = &[ "xnor", "xor", ]; + +pub(crate) const KEYWORDS_DIRECTIVE: &[&str] = &[ + "__FILE__", + "__LINE__", + "begin_keywords", + "celldefine", + "default_nettype", + "define", + "else", + "elsif", + "end_keywords", + "endcelldefine", + "endif", + "ifdef", + "ifndef", + "include", + "line", + "nounconnected_drive", + "pragma", + "resetall", + "timescale", + "unconnected_drive", + "undef", + "undefineall", +]; diff --git a/sv-parser-parser/src/utils.rs b/sv-parser-parser/src/utils.rs index 2b6f022..2926024 100644 --- a/sv-parser-parser/src/utils.rs +++ b/sv-parser-parser/src/utils.rs @@ -376,6 +376,7 @@ pub(crate) enum VersionSpecifier { Ieee1800_2009, Ieee1800_2012, Ieee1800_2017, + Directive, } thread_local!( @@ -410,6 +411,9 @@ pub(crate) fn begin_keywords(version: &str) { "1800-2017" => current_version .borrow_mut() .push(VersionSpecifier::Ieee1800_2017), + "directive" => current_version + .borrow_mut() + .push(VersionSpecifier::Directive), _ => (), }); } @@ -453,6 +457,7 @@ pub(crate) fn is_keyword(s: &Span) -> bool { Some(VersionSpecifier::Ieee1800_2009) => KEYWORDS_1800_2009, Some(VersionSpecifier::Ieee1800_2012) => KEYWORDS_1800_2012, Some(VersionSpecifier::Ieee1800_2017) => KEYWORDS_1800_2017, + Some(VersionSpecifier::Directive) => KEYWORDS_DIRECTIVE, None => KEYWORDS_1800_2017, }; for k in keywords {