Fix text macro identifier parsing
This commit is contained in:
parent
8527a03b12
commit
2bef1e665f
@ -3,6 +3,7 @@
|
|||||||
## [Unreleased](https://github.com/dalance/sv-parser/compare/v0.3.2...Unreleased) - ReleaseDate
|
## [Unreleased](https://github.com/dalance/sv-parser/compare/v0.3.2...Unreleased) - ReleaseDate
|
||||||
|
|
||||||
* [Fixed] define arument
|
* [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
|
## [v0.3.2](https://github.com/dalance/sv-parser/compare/v0.2.1...v0.3.2) - 2019-10-29
|
||||||
|
|
||||||
|
@ -239,7 +239,9 @@ pub(crate) fn default_text(s: Span) -> IResult<Span, DefaultText> {
|
|||||||
#[packrat_parser]
|
#[packrat_parser]
|
||||||
pub(crate) fn text_macro_usage(s: Span) -> IResult<Span, TextMacroUsage> {
|
pub(crate) fn text_macro_usage(s: Span) -> IResult<Span, TextMacroUsage> {
|
||||||
let (s, a) = symbol("`")(s)?;
|
let (s, a) = symbol("`")(s)?;
|
||||||
|
begin_keywords("directive");
|
||||||
let (s, b) = text_macro_identifier(s)?;
|
let (s, b) = text_macro_identifier(s)?;
|
||||||
|
end_keywords();
|
||||||
let (s, c) = opt(paren(list_of_actual_arguments))(s)?;
|
let (s, c) = opt(paren(list_of_actual_arguments))(s)?;
|
||||||
Ok((s, TextMacroUsage { nodes: (a, b, c) }))
|
Ok((s, TextMacroUsage { nodes: (a, b, c) }))
|
||||||
}
|
}
|
||||||
|
@ -1444,3 +1444,28 @@ pub(crate) const KEYWORDS_1800_2017: &[&str] = &[
|
|||||||
"xnor",
|
"xnor",
|
||||||
"xor",
|
"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",
|
||||||
|
];
|
||||||
|
@ -376,6 +376,7 @@ pub(crate) enum VersionSpecifier {
|
|||||||
Ieee1800_2009,
|
Ieee1800_2009,
|
||||||
Ieee1800_2012,
|
Ieee1800_2012,
|
||||||
Ieee1800_2017,
|
Ieee1800_2017,
|
||||||
|
Directive,
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_local!(
|
thread_local!(
|
||||||
@ -410,6 +411,9 @@ pub(crate) fn begin_keywords(version: &str) {
|
|||||||
"1800-2017" => current_version
|
"1800-2017" => current_version
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.push(VersionSpecifier::Ieee1800_2017),
|
.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_2009) => KEYWORDS_1800_2009,
|
||||||
Some(VersionSpecifier::Ieee1800_2012) => KEYWORDS_1800_2012,
|
Some(VersionSpecifier::Ieee1800_2012) => KEYWORDS_1800_2012,
|
||||||
Some(VersionSpecifier::Ieee1800_2017) => KEYWORDS_1800_2017,
|
Some(VersionSpecifier::Ieee1800_2017) => KEYWORDS_1800_2017,
|
||||||
|
Some(VersionSpecifier::Directive) => KEYWORDS_DIRECTIVE,
|
||||||
None => KEYWORDS_1800_2017,
|
None => KEYWORDS_1800_2017,
|
||||||
};
|
};
|
||||||
for k in keywords {
|
for k in keywords {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user