Fix escaped macro identifier #28
This commit is contained in:
parent
a60246e8b7
commit
b26b56d624
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
## [Unreleased](https://github.com/dalance/sv-parser/compare/v0.9.0...Unreleased) - ReleaseDate
|
## [Unreleased](https://github.com/dalance/sv-parser/compare/v0.9.0...Unreleased) - ReleaseDate
|
||||||
|
|
||||||
|
* [Fixed] escaped_ideitifier at macro name [#28](https://github.com/dalance/sv-parser/issues/28)
|
||||||
* [Fixed] begin_keywords "1364-2001-noconfig" failure [#28](https://github.com/dalance/sv-parser/issues/28)
|
* [Fixed] begin_keywords "1364-2001-noconfig" failure [#28](https://github.com/dalance/sv-parser/issues/28)
|
||||||
* [Changed] update nom to 6.0.0
|
* [Changed] update nom to 6.0.0
|
||||||
|
|
||||||
|
@ -561,7 +561,9 @@ fn identifier(node: RefNode, s: &str) -> Option<String> {
|
|||||||
}
|
}
|
||||||
RefNode::EscapedIdentifier(x) => {
|
RefNode::EscapedIdentifier(x) => {
|
||||||
let x: Locate = x.nodes.0.try_into().unwrap();
|
let x: Locate = x.nodes.0.try_into().unwrap();
|
||||||
return Some(String::from(x.str(s)));
|
let x = x.str(s);
|
||||||
|
let x = &x[1..]; // remove \
|
||||||
|
return Some(String::from(x));
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
@ -1132,6 +1134,32 @@ endmodule
|
|||||||
module mymod;
|
module mymod;
|
||||||
mysubmod u_mysubmod() ;
|
mysubmod u_mysubmod() ;
|
||||||
endmodule
|
endmodule
|
||||||
|
"##
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test16() {
|
||||||
|
let (ret, _) = preprocess(
|
||||||
|
get_testcase("test16.sv"),
|
||||||
|
&HashMap::new(),
|
||||||
|
&[] as &[String],
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
ret.text(),
|
||||||
|
r##"module a;
|
||||||
|
`define HELLO0 "HELLO"
|
||||||
|
`define \HELLO1 "HELLO"
|
||||||
|
initial begin
|
||||||
|
$display("HELLO" );
|
||||||
|
$display("HELLO" );
|
||||||
|
$display("HELLO" );
|
||||||
|
$display("HELLO" );
|
||||||
|
end
|
||||||
|
endmodule
|
||||||
"##
|
"##
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
10
sv-parser-pp/testcases/test16.sv
Normal file
10
sv-parser-pp/testcases/test16.sv
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
module a;
|
||||||
|
`define HELLO0 "HELLO"
|
||||||
|
`define \HELLO1 "HELLO"
|
||||||
|
initial begin
|
||||||
|
$display(`HELLO0);
|
||||||
|
$display(`\HELLO0 );
|
||||||
|
$display(`HELLO1);
|
||||||
|
$display(`\HELLO1 );
|
||||||
|
end
|
||||||
|
endmodule
|
Loading…
x
Reference in New Issue
Block a user