Fix resetall in design element
This commit is contained in:
parent
6fdc341ed7
commit
1e1a5834f1
@ -3,6 +3,7 @@
|
||||
## [Unreleased](https://github.com/dalance/sv-parser/compare/v0.4.18...Unreleased) - ReleaseDate
|
||||
|
||||
* [Added] include line check
|
||||
* [Fixed] resetall directive in design element
|
||||
|
||||
## [v0.4.18](https://github.com/dalance/sv-parser/compare/v0.4.17...v0.4.18) - 2019-12-12
|
||||
|
||||
|
@ -64,6 +64,65 @@ pub(crate) fn compiler_directive(s: Span) -> IResult<Span, CompilerDirective> {
|
||||
ret
|
||||
}
|
||||
|
||||
#[tracable_parser]
|
||||
#[packrat_parser]
|
||||
pub(crate) fn compiler_directive_without_resetall(s: Span) -> IResult<Span, CompilerDirective> {
|
||||
begin_directive();
|
||||
let ret = alt((
|
||||
map(include_compiler_directive, |x| {
|
||||
CompilerDirective::IncludeCompilerDirective(Box::new(x))
|
||||
}),
|
||||
map(text_macro_definition, |x| {
|
||||
CompilerDirective::TextMacroDefinition(Box::new(x))
|
||||
}),
|
||||
map(undefine_compiler_directive, |x| {
|
||||
CompilerDirective::UndefineCompilerDirective(Box::new(x))
|
||||
}),
|
||||
map(undefineall_compiler_directive, |x| {
|
||||
CompilerDirective::UndefineallCompilerDirective(Box::new(x))
|
||||
}),
|
||||
map(conditional_compiler_directive, |x| {
|
||||
CompilerDirective::ConditionalCompilerDirective(Box::new(x))
|
||||
}),
|
||||
map(timescale_compiler_directive, |x| {
|
||||
CompilerDirective::TimescaleCompilerDirective(Box::new(x))
|
||||
}),
|
||||
map(default_nettype_compiler_directive, |x| {
|
||||
CompilerDirective::DefaultNettypeCompilerDirective(Box::new(x))
|
||||
}),
|
||||
map(unconnected_drive_compiler_directive, |x| {
|
||||
CompilerDirective::UnconnectedDriveCompilerDirective(Box::new(x))
|
||||
}),
|
||||
map(nounconnected_drive_compiler_directive, |x| {
|
||||
CompilerDirective::NounconnectedDriveCompilerDirective(Box::new(x))
|
||||
}),
|
||||
map(celldefine_compiler_directive, |x| {
|
||||
CompilerDirective::CelldefineDriveCompilerDirective(Box::new(x))
|
||||
}),
|
||||
map(endcelldefine_compiler_directive, |x| {
|
||||
CompilerDirective::EndcelldefineDriveCompilerDirective(Box::new(x))
|
||||
}),
|
||||
map(pragma, |x| CompilerDirective::Pragma(Box::new(x))),
|
||||
map(line_compiler_directive, |x| {
|
||||
CompilerDirective::LineCompilerDirective(Box::new(x))
|
||||
}),
|
||||
map(position_compiler_directive, |x| {
|
||||
CompilerDirective::PositionCompilerDirective(Box::new(x))
|
||||
}),
|
||||
map(keywords_directive, |x| {
|
||||
CompilerDirective::KeywordsDirective(Box::new(x))
|
||||
}),
|
||||
map(endkeywords_directive, |x| {
|
||||
CompilerDirective::EndkeywordsDirective(Box::new(x))
|
||||
}),
|
||||
map(text_macro_usage, |x| {
|
||||
CompilerDirective::TextMacroUsage(Box::new(x))
|
||||
}),
|
||||
))(s);
|
||||
end_directive();
|
||||
ret
|
||||
}
|
||||
|
||||
#[tracable_parser]
|
||||
#[packrat_parser]
|
||||
pub(crate) fn resetall_compiler_directive(s: Span) -> IResult<Span, ResetallCompilerDirective> {
|
||||
|
@ -15,6 +15,9 @@ pub(crate) fn source_text(s: Span) -> IResult<Span, SourceText> {
|
||||
#[packrat_parser]
|
||||
pub(crate) fn description(s: Span) -> IResult<Span, Description> {
|
||||
alt((
|
||||
map(resetall_compiler_directive, |x| {
|
||||
Description::ResetallCompilerDirective(Box::new(x))
|
||||
}),
|
||||
map(module_declaration, |x| {
|
||||
Description::ModuleDeclaration(Box::new(x))
|
||||
}),
|
||||
|
@ -339,9 +339,10 @@ pub(crate) fn white_space(s: Span) -> IResult<Span, WhiteSpace> {
|
||||
map(preceded(peek(char('/')), comment), |x| {
|
||||
WhiteSpace::Comment(Box::new(x))
|
||||
}),
|
||||
map(preceded(peek(char('`')), compiler_directive), |x| {
|
||||
WhiteSpace::CompilerDirective(Box::new(x))
|
||||
}),
|
||||
map(
|
||||
preceded(peek(char('`')), compiler_directive_without_resetall),
|
||||
|x| WhiteSpace::CompilerDirective(Box::new(x)),
|
||||
),
|
||||
))(s)
|
||||
}
|
||||
}
|
||||
|
@ -209,7 +209,11 @@ pub fn preprocess_str<T: AsRef<Path>, U: AsRef<Path>>(
|
||||
_ => (),
|
||||
}
|
||||
match n {
|
||||
NodeEvent::Enter(RefNode::ResetallCompilerDirective(_)) if !skip => {}
|
||||
NodeEvent::Enter(RefNode::ResetallCompilerDirective(x)) if !skip => {
|
||||
let locate: Locate = x.try_into().unwrap();
|
||||
let range = Range::new(locate.offset, locate.offset + locate.len);
|
||||
ret.push(locate.str(&s), Some((path.as_ref(), range)));
|
||||
}
|
||||
NodeEvent::Enter(RefNode::UndefineCompilerDirective(x)) if !skip => {
|
||||
let (_, _, ref name) = x.nodes;
|
||||
let id = identifier((&name.nodes.0).into(), &s).unwrap();
|
||||
|
@ -13,6 +13,7 @@ pub struct SourceText {
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Node)]
|
||||
pub enum Description {
|
||||
ResetallCompilerDirective(Box<ResetallCompilerDirective>),
|
||||
ModuleDeclaration(Box<ModuleDeclaration>),
|
||||
UdpDeclaration(Box<UdpDeclaration>),
|
||||
InterfaceDeclaration(Box<InterfaceDeclaration>),
|
||||
|
Loading…
x
Reference in New Issue
Block a user