Keep text_macro_definition after preprocess #19
This commit is contained in:
parent
d1bc8f8088
commit
ce598fd4ef
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
## [Unreleased](https://github.com/dalance/sv-parser/compare/v0.8.3...Unreleased) - ReleaseDate
|
## [Unreleased](https://github.com/dalance/sv-parser/compare/v0.8.3...Unreleased) - ReleaseDate
|
||||||
|
|
||||||
|
* [Changed] keep text_macro_definition after preprocess [#19](https://github.com/dalance/sv-parser/issues/19)
|
||||||
|
|
||||||
## [v0.8.3](https://github.com/dalance/sv-parser/compare/v0.8.2...v0.8.3) - 2020-11-06
|
## [v0.8.3](https://github.com/dalance/sv-parser/compare/v0.8.2...v0.8.3) - 2020-11-06
|
||||||
|
|
||||||
* [Fixed] textmacro without arguments issue [#20](https://github.com/dalance/sv-parser/issues/20)
|
* [Fixed] textmacro without arguments issue [#20](https://github.com/dalance/sv-parser/issues/20)
|
||||||
|
@ -434,6 +434,11 @@ pub fn preprocess_str<T: AsRef<Path>, U: AsRef<Path>, V: BuildHasher>(
|
|||||||
};
|
};
|
||||||
|
|
||||||
defines.insert(id, Some(define));
|
defines.insert(id, Some(define));
|
||||||
|
|
||||||
|
// Keep TextMacroDefinition after preprocess
|
||||||
|
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::IncludeCompilerDirective(x)) if !ignore_include => {
|
NodeEvent::Enter(RefNode::IncludeCompilerDirective(x)) if !ignore_include => {
|
||||||
skip_nodes.push(x.into());
|
skip_nodes.push(x.into());
|
||||||
@ -885,7 +890,9 @@ endmodule
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ret.text(),
|
ret.text(),
|
||||||
r##"
|
r##"`define connect(NAME, INDEX = 0) \
|
||||||
|
assign NAME``_``INDEX``__x = NAME[INDEX].x; \
|
||||||
|
assign NAME``_``INDEX``__y = NAME[INDEX].y;
|
||||||
|
|
||||||
module a ();
|
module a ();
|
||||||
|
|
||||||
@ -908,7 +915,13 @@ module a ();
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ret.text(),
|
ret.text(),
|
||||||
r##"
|
r##"`define disp(clk, exp, msg) \
|
||||||
|
always @(posedge clk) begin \
|
||||||
|
if (!(exp)) begin \
|
||||||
|
$display msg; \
|
||||||
|
end \
|
||||||
|
end \
|
||||||
|
|
||||||
module a ();
|
module a ();
|
||||||
|
|
||||||
always @(posedge clk) begin
|
always @(posedge clk) begin
|
||||||
@ -936,9 +949,9 @@ endmodule
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
ret.text(),
|
ret.text(),
|
||||||
r##"module a;
|
r##"module a;
|
||||||
|
`define HI Hello
|
||||||
|
`define LO "`HI, world"
|
||||||
|
`define H(x) "Hello, x"
|
||||||
initial begin
|
initial begin
|
||||||
$display("`HI, world");
|
$display("`HI, world");
|
||||||
$display("`HI, world" );
|
$display("`HI, world" );
|
||||||
@ -961,7 +974,7 @@ endmodule
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ret.text(),
|
ret.text(),
|
||||||
r##"
|
r##"`define msg(x,y) `"x: `\`"y`\`"`"
|
||||||
|
|
||||||
module a;
|
module a;
|
||||||
initial begin
|
initial begin
|
||||||
@ -1075,7 +1088,7 @@ endmodule
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ret.text(),
|
ret.text(),
|
||||||
r##"
|
r##"`define NAME 42 // Comment
|
||||||
interface foo #(WIDTH = 42 ) ();
|
interface foo #(WIDTH = 42 ) ();
|
||||||
endinterface
|
endinterface
|
||||||
"##
|
"##
|
||||||
@ -1115,7 +1128,7 @@ endmodule
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ret.text(),
|
ret.text(),
|
||||||
r##"
|
r##"`define MOD_INST u_mysubmod
|
||||||
module mymod;
|
module mymod;
|
||||||
mysubmod u_mysubmod() ;
|
mysubmod u_mysubmod() ;
|
||||||
endmodule
|
endmodule
|
||||||
|
Loading…
x
Reference in New Issue
Block a user