Fix escaped_identifier
This commit is contained in:
parent
c965a038d8
commit
d3d090c3d4
@ -2,6 +2,7 @@
|
||||
|
||||
## [Unreleased](https://github.com/dalance/sv-parser/compare/v0.4.19...Unreleased) - ReleaseDate
|
||||
|
||||
* [Fixed] escaped_ideitifier including `` ` ``
|
||||
* [Fixed] time_literal spacing
|
||||
|
||||
## [v0.4.19](https://github.com/dalance/sv-parser/compare/v0.4.18...v0.4.19) - 2019-12-12
|
||||
|
@ -548,6 +548,9 @@ pub(crate) fn source_description(s: Span) -> IResult<Span, SourceDescription> {
|
||||
map(string_literal, |x| {
|
||||
SourceDescription::StringLiteral(Box::new(x))
|
||||
}),
|
||||
map(escaped_identifier, |x| {
|
||||
SourceDescription::EscapedIdentifier(Box::new(x))
|
||||
}),
|
||||
source_description_not_directive,
|
||||
map(compiler_directive, |x| {
|
||||
SourceDescription::CompilerDirective(Box::new(x))
|
||||
@ -559,7 +562,7 @@ pub(crate) fn source_description(s: Span) -> IResult<Span, SourceDescription> {
|
||||
#[packrat_parser]
|
||||
pub(crate) fn source_description_not_directive(s: Span) -> IResult<Span, SourceDescription> {
|
||||
let (s, a) = many1(alt((
|
||||
is_not("`/\""),
|
||||
is_not("`/\"\\"),
|
||||
terminated(tag("/"), peek(not(alt((tag("/"), tag("*")))))),
|
||||
)))(s)?;
|
||||
|
||||
|
@ -403,6 +403,11 @@ mod unit {
|
||||
r##"module a; initial begin #1 ps[idx] = 1'b1; end endmodule"##,
|
||||
Ok((_, _))
|
||||
);
|
||||
test!(
|
||||
source_text,
|
||||
r##"module a; reg \`~!-_=+\|[]{};:'"",./<>? ; endmodule"##,
|
||||
Ok((_, _))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -234,6 +234,13 @@ pub fn preprocess_str<T: AsRef<Path>, U: AsRef<Path>>(
|
||||
let range = Range::new(locate.offset, locate.offset + locate.len);
|
||||
ret.push(locate.str(&s), Some((path.as_ref(), range)));
|
||||
}
|
||||
NodeEvent::Enter(RefNode::SourceDescription(SourceDescription::EscapedIdentifier(
|
||||
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::KeywordsDirective(x)) if !skip => {
|
||||
let locate: Locate = x.try_into().unwrap();
|
||||
let range = Range::new(locate.offset, locate.offset + locate.len);
|
||||
@ -785,4 +792,17 @@ endmodule
|
||||
"Err(Error { inner: \n\nInclude line can\'t have other items })"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test12() {
|
||||
let (ret, _) =
|
||||
preprocess(get_testcase("test12.sv"), &HashMap::new(), &[] as &[String]).unwrap();
|
||||
assert_eq!(
|
||||
ret.text(),
|
||||
r##"module a;
|
||||
reg \`~!-_=+\|[]{};:'"",./<>? ;
|
||||
endmodule
|
||||
"##
|
||||
);
|
||||
}
|
||||
}
|
||||
|
3
sv-parser-pp/testcases/test12.sv
Normal file
3
sv-parser-pp/testcases/test12.sv
Normal file
@ -0,0 +1,3 @@
|
||||
module a;
|
||||
reg \`~!-_=+\|[]{};:'"",./<>? ;
|
||||
endmodule
|
@ -180,6 +180,7 @@ pub enum SourceDescription {
|
||||
StringLiteral(Box<StringLiteral>),
|
||||
NotDirective(Box<SourceDescriptionNotDirective>),
|
||||
CompilerDirective(Box<CompilerDirective>),
|
||||
EscapedIdentifier(Box<EscapedIdentifier>),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Node)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user