Skip to content

Commit

Permalink
fix(parser): handle empty lines in text block
Browse files Browse the repository at this point in the history
  • Loading branch information
CertainLach committed Aug 26, 2020
1 parent 295345a commit 0f6b269
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crates/jrsonnet-parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ parser! {
= str:$((!['\n'][_])* "\n") {str}
pub rule string_block() -> String
= "|||" (!['\n']single_whitespace())* "\n"
empty_lines:$(['\n']*)
prefix:[' ' | '\t']+ first_line:whole_line()
lines:([' ' | '\t']*<{prefix.len()}> s:whole_line() {s})*
lines:("\n" {"\n"} / [' ' | '\t']*<{prefix.len()}> s:whole_line() {s})*
[' ' | '\t']*<, {prefix.len() - 1}> "|||"
{let mut l = first_line.to_owned(); l.extend(lines); l}
{let mut l = empty_lines.to_owned(); l.push_str(first_line); l.extend(lines); l}
pub rule string() -> String
= "\"" str:$(("\\\"" / "\\\\" / (!['"'][_]))*) "\"" {unescape::unescape(str).unwrap()}
/ "'" str:$(("\\'" / "\\\\" / (!['\''][_]))*) "'" {unescape::unescape(str).unwrap()}
Expand Down

0 comments on commit 0f6b269

Please sign in to comment.