diff --git a/sv-parser-parser/src/general/compiler_directives.rs b/sv-parser-parser/src/general/compiler_directives.rs index 2eea5f6e..9d2a116c 100644 --- a/sv-parser-parser/src/general/compiler_directives.rs +++ b/sv-parser-parser/src/general/compiler_directives.rs @@ -59,6 +59,20 @@ pub(crate) fn compiler_directive(s: Span) -> IResult { map(text_macro_usage, |x| { CompilerDirective::TextMacroUsage(Box::new(x)) }), + alt(( + map(delay_mode_distributed_compiler_directive, |x| { + CompilerDirective::DelayModeDistributedDirective(Box::new(x)) + }), + map(delay_mode_path_compiler_directive, |x| { + CompilerDirective::DelayModePathDirective(Box::new(x)) + }), + map(delay_mode_unit_compiler_directive, |x| { + CompilerDirective::DelayModeUnitDirective(Box::new(x)) + }), + map(delay_mode_zero_compiler_directive, |x| { + CompilerDirective::DelayModeZeroDirective(Box::new(x)) + }), + )) ))(s); end_directive(); ret @@ -118,6 +132,23 @@ pub(crate) fn compiler_directive_without_resetall(s: Span) -> IResult IResult IResult { + let (s, a) = symbol("`")(s)?; + let (s, b) = keyword("delay_mode_distributed")(s)?; + Ok((s, DelayModeDistributedDirective { nodes: (a, b) })) +} + +#[tracable_parser] +#[packrat_parser] +pub(crate) fn delay_mode_path_compiler_directive( + s: Span, +) -> IResult { + let (s, a) = symbol("`")(s)?; + let (s, b) = keyword("delay_mode_path")(s)?; + Ok((s, DelayModePathDirective { nodes: (a, b) })) +} + +#[tracable_parser] +#[packrat_parser] +pub(crate) fn delay_mode_unit_compiler_directive( + s: Span, +) -> IResult { + let (s, a) = symbol("`")(s)?; + let (s, b) = keyword("delay_mode_unit")(s)?; + Ok((s, DelayModeUnitDirective { nodes: (a, b) })) +} + +#[tracable_parser] +#[packrat_parser] +pub(crate) fn delay_mode_zero_compiler_directive( + s: Span, +) -> IResult { + let (s, a) = symbol("`")(s)?; + let (s, b) = keyword("delay_mode_zero")(s)?; + Ok((s, DelayModeZeroDirective { nodes: (a, b) })) +} \ No newline at end of file diff --git a/sv-parser-parser/src/keywords.rs b/sv-parser-parser/src/keywords.rs index 52442fef..c6b44628 100644 --- a/sv-parser-parser/src/keywords.rs +++ b/sv-parser-parser/src/keywords.rs @@ -1466,4 +1466,8 @@ pub(crate) const KEYWORDS_DIRECTIVE: &[&str] = &[ "unconnected_drive", "undef", "undefineall", + "delay_mode_distributed", + "delay_mode_path", + "delay_mode_unit", + "delay_mode_zero" ]; diff --git a/sv-parser-pp/src/preprocess.rs b/sv-parser-pp/src/preprocess.rs index 9a01eff3..06e78509 100644 --- a/sv-parser-pp/src/preprocess.rs +++ b/sv-parser-pp/src/preprocess.rs @@ -406,6 +406,42 @@ pub fn preprocess_str, U: AsRef, V: BuildHasher>( NodeEvent::Leave(RefNode::EndcelldefineDriveCompilerDirective(_)) => { skip_whitespace = false; } + // NodeEvent::Enter(RefNode::DelayModeDistributedDirective(x)) => { + // 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))); + // skip_whitespace = true; + // } + // NodeEvent::Leave(RefNode::DelayModeDistributedDirective(_)) => { + // skip_whitespace = false; + // } + // NodeEvent::Enter(RefNode::DelayModePathDirective(x)) => { + // 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))); + // skip_whitespace = true; + // } + // NodeEvent::Leave(RefNode::DelayModePathDirective(_)) => { + // skip_whitespace = false; + // } + // NodeEvent::Enter(RefNode::DelayModeUnitDirective(x)) => { + // 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))); + // skip_whitespace = true; + // } + // NodeEvent::Leave(RefNode::DelayModeUnitDirective(_)) => { + // skip_whitespace = false; + // } + // NodeEvent::Enter(RefNode::DelayModeZeroDirective(x)) => { + // 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))); + // skip_whitespace = true; + // } + // NodeEvent::Leave(RefNode::DelayModeZeroDirective(_)) => { + // skip_whitespace = false; + // } NodeEvent::Enter(RefNode::Pragma(x)) => { let locate: Locate = x.try_into().unwrap(); let range = Range::new(locate.offset, locate.offset + locate.len); @@ -1639,4 +1675,12 @@ mod tests { testfile_contents("expected/undefineall.sv") ); } // }}} + + #[test] + fn annex_e(){ + match preprocess_usualargs("IEEE18002017_AnnexE_delaydirectives.sv"){ + Ok(_x) => (), + Err(x) => panic!("failed with {}",x) + } + } } diff --git a/sv-parser-pp/testcases/IEEE18002017_AnnexE_delaydirectives.sv b/sv-parser-pp/testcases/IEEE18002017_AnnexE_delaydirectives.sv new file mode 100644 index 00000000..f4f95ade --- /dev/null +++ b/sv-parser-pp/testcases/IEEE18002017_AnnexE_delaydirectives.sv @@ -0,0 +1,18 @@ +/* +The compiler directives described in this annex are for informative purposes only and are not part of this +standard. +This annex describes additional compiler directives as companions to the compiler directives described in +Clause 22. The compiler directives described in this annex may not be available in all implementations of +SystemVerilog. The following compiler directives are described in this annex: +*/ + +//not supported: +// `default_decay_time 1.3 //[E.2] +// `defualt_decay_time 5 +// `default_decay_time infinite +// `default_trireg_strength 100 //[E.3] + +`delay_mode_distributed //[E.4] +`delay_mode_path //[E.5] +`delay_mode_unit //[E.6] +`delay_mode_zero //[E.7] \ No newline at end of file diff --git a/sv-parser-syntaxtree/src/general/compiler_directives.rs b/sv-parser-syntaxtree/src/general/compiler_directives.rs index e0c7c269..73324b54 100644 --- a/sv-parser-syntaxtree/src/general/compiler_directives.rs +++ b/sv-parser-syntaxtree/src/general/compiler_directives.rs @@ -22,6 +22,10 @@ pub enum CompilerDirective { PositionCompilerDirective(Box), KeywordsDirective(Box), EndkeywordsDirective(Box), + DelayModeDistributedDirective(Box), + DelayModePathDirective(Box), + DelayModeUnitDirective(Box), + DelayModeZeroDirective(Box) } #[derive(Clone, Debug, PartialEq, Node)] @@ -305,3 +309,24 @@ pub struct VersionSpecifier { pub struct EndkeywordsDirective { pub nodes: (Symbol, Keyword), } + + +#[derive(Clone, Debug, PartialEq, Node)] +pub struct DelayModeDistributedDirective { + pub nodes: (Symbol, Keyword), +} + +#[derive(Clone, Debug, PartialEq, Node)] +pub struct DelayModePathDirective { + pub nodes: (Symbol, Keyword), +} + +#[derive(Clone, Debug, PartialEq, Node)] +pub struct DelayModeUnitDirective { + pub nodes: (Symbol, Keyword), +} + +#[derive(Clone, Debug, PartialEq, Node)] +pub struct DelayModeZeroDirective { + pub nodes: (Symbol, Keyword), +}