difftreelog
Merge pull request #175 from CertainLach/feat/chomped-string-block
in: master
Chomped string blocks
1 file changed
crates/jrsonnet-parser/src/lib.rsdiffbeforeafterboth143 pub rule whole_line() -> &'input str143 pub rule whole_line() -> &'input str144 = str:$((!['\n'][_])* "\n") {str}144 = str:$((!['\n'][_])* "\n") {str}145 pub rule string_block() -> String145 pub rule string_block() -> String146 = "|||" (!['\n']single_whitespace())* "\n"146 = "|||" chomped:"-"? (!['\n']single_whitespace())* "\n"147 empty_lines:$(['\n']*)147 empty_lines:$(['\n']*)148 prefix:[' ' | '\t']+ first_line:whole_line()148 prefix:[' ' | '\t']+ first_line:whole_line()149 lines:("\n" {"\n"} / [' ' | '\t']*<{prefix.len()}> s:whole_line() {s})*149 lines:("\n" {"\n"} / [' ' | '\t']*<{prefix.len()}> s:whole_line() {s})*150 [' ' | '\t']*<, {prefix.len() - 1}> "|||"150 [' ' | '\t']*<, {prefix.len() - 1}> "|||"151 {let mut l = empty_lines.to_owned(); l.push_str(first_line); l.extend(lines); l}151 {152 let mut l = empty_lines.to_owned();153 l.push_str(first_line);154 l.extend(lines);155 if chomped.is_some() {156 debug_assert!(l.ends_with('\n'));157 l.truncate(l.len() - 1);158 }159 l160 }152161