difftreelog
fix(parser) allow tabs in multiline strings
in: master
3 files changed
bindings/jsonnet/src/lib.rsdiffbeforeafterboth198 add: false,198 add: false,199 visibility: Visibility::Normal,199 visibility: Visibility::Normal,200 invoke: LazyBinding::Bound(LazyVal::new_resolved(val.clone())),200 invoke: LazyBinding::Bound(LazyVal::new_resolved(val.clone())),201 location: None,201 },202 },202 );203 );203 let new_obj = ObjValue::new(Some(old.clone()), Rc::new(new));204 let new_obj = ObjValue::new(Some(old.clone()), Rc::new(new));crates/jrsonnet-parser/src/expr.rsdiffbeforeafterboth1#[cfg(feature = "deserialize")]2use serde::Deserialize;3#[cfg(feature = "serialize")]4use serde::Serialize;1use std::{fmt::Debug, ops::Deref, path::PathBuf, rc::Rc};5use std::{fmt::Debug, ops::Deref, path::PathBuf, rc::Rc};2#[cfg(feature = "dump")]6#[cfg(feature = "dump")]3use structdump_derive::Codegen;7use structdump_derive::Codegen;4#[cfg(feature = "serialize")]5use serde::Serialize;6#[cfg(feature = "deserialize")]7use serde::Deserialize;889#[cfg_attr(feature = "dump", derive(Codegen))]9#[cfg_attr(feature = "dump", derive(Codegen))]10#[cfg_attr(feature = "serialize", derive(Serialize))]10#[cfg_attr(feature = "serialize", derive(Serialize))]crates/jrsonnet-parser/src/lib.rsdiffbeforeafterboth9pub use expr::*;9pub use expr::*;10pub use peg;10pub use peg;111112#[derive(Default)]12pub struct ParserSettings {13pub struct ParserSettings {13 pub loc_data: bool,14 pub loc_data: bool,14 pub file_name: Rc<PathBuf>,15 pub file_name: Rc<PathBuf>,83 = str:$((!['\n'][_])* "\n") {str}84 = str:$((!['\n'][_])* "\n") {str}84 pub rule string_block() -> String85 pub rule string_block() -> String85 = "|||" (!['\n']single_whitespace())* "\n"86 = "|||" (!['\n']single_whitespace())* "\n"86 prefix:[' ']+ first_line:whole_line()87 prefix:[' ' | '\t']+ first_line:whole_line()87 lines:([' ']*<{prefix.len()}> s:whole_line() {s})*88 lines:([' ' | '\t']*<{prefix.len()}> s:whole_line() {s})*88 [' ']*<, {prefix.len() - 1}> "|||"89 [' ' | '\t']*<, {prefix.len() - 1}> "|||"89 {let mut l = first_line.to_owned(); l.extend(lines); l}90 {let mut l = first_line.to_owned(); l.extend(lines); l}90 pub rule string() -> String91 pub rule string() -> String91 = "\"" str:$(("\\\"" / "\\\\" / (!['"'][_]))*) "\"" {unescape::unescape(str).unwrap()}92 = "\"" str:$(("\\\"" / "\\\\" / (!['"'][_]))*) "\"" {unescape::unescape(str).unwrap()}359 assert_eq!(360 assert_eq!(360 parse!("|||\n Hello world!\n a\n|||"),361 parse!("|||\n Hello world!\n a\n|||"),361 el!(Expr::Str("Hello world!\n a\n".into())),362 el!(Expr::Str("Hello world!\n a\n".into())),362 )363 );364 assert_eq!(365 parse!("|||\n Hello world!\n a\n|||"),366 el!(Expr::Str("Hello world!\n a\n".into())),367 );368 assert_eq!(369 parse!("|||\n\t\tHello world!\n\t\t\ta\n|||"),370 el!(Expr::Str("Hello world!\n\ta\n".into())),371 );372 assert_eq!(373 parse!("|||\n Hello world!\n a\n |||"),374 el!(Expr::Str("Hello world!\n a\n".into())),375 );363 }376 }364377365 #[test]378 #[test]