Add LF/CR+LF support

This commit is contained in:
dalance 2019-11-05 20:40:31 +09:00
parent d03120fc7d
commit a733e3b980
3 changed files with 12 additions and 2 deletions

View File

@ -2,6 +2,8 @@
## [Unreleased](https://github.com/dalance/sv-parser/compare/v0.3.4...Unreleased) - ReleaseDate ## [Unreleased](https://github.com/dalance/sv-parser/compare/v0.3.4...Unreleased) - ReleaseDate
* [Added] LF/CR+LF support
## [v0.3.4](https://github.com/dalance/sv-parser/compare/v0.3.3...v0.3.4) - 2019-11-05 ## [v0.3.4](https://github.com/dalance/sv-parser/compare/v0.3.3...v0.3.4) - 2019-11-05
* [Fixed] define with string literal * [Fixed] define with string literal

View File

@ -204,7 +204,13 @@ pub(crate) fn text_macro_identifier_exact(s: Span) -> IResult<Span, TextMacroIde
#[tracable_parser] #[tracable_parser]
#[packrat_parser] #[packrat_parser]
pub(crate) fn macro_text(s: Span) -> IResult<Span, MacroText> { pub(crate) fn macro_text(s: Span) -> IResult<Span, MacroText> {
let (s, a) = many1(alt((tag("\\\n"), tag("\\"), is_not("\\\n"))))(s)?; let (s, a) = many1(alt((
tag("\\\n"),
tag("\\\r\n"),
tag("\\\r"),
tag("\\"),
is_not("\\\r\n"),
)))(s)?;
let mut ret = None; let mut ret = None;
for x in a { for x in a {

View File

@ -437,7 +437,9 @@ fn resolve_text_macro_usage<T: AsRef<Path>, U: AsRef<Path>>(
.replace("``", "") .replace("``", "")
.replace("`\\`\"", "\\\"") .replace("`\\`\"", "\\\"")
.replace("`\"", "\"") .replace("`\"", "\"")
.replace("\\\n", ""), .replace("\\\n", "")
.replace("\\\r\n", "")
.replace("\\\r", ""),
); );
} }
} }