difftreelog
fix(parser) allow tabs in multiline strings
in: master
3 files changed
bindings/jsonnet/src/lib.rsdiffbeforeafterboth--- a/bindings/jsonnet/src/lib.rs
+++ b/bindings/jsonnet/src/lib.rs
@@ -198,6 +198,7 @@
add: false,
visibility: Visibility::Normal,
invoke: LazyBinding::Bound(LazyVal::new_resolved(val.clone())),
+ location: None,
},
);
let new_obj = ObjValue::new(Some(old.clone()), Rc::new(new));
crates/jrsonnet-parser/src/expr.rsdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/expr.rs
+++ b/crates/jrsonnet-parser/src/expr.rs
@@ -1,10 +1,10 @@
+#[cfg(feature = "deserialize")]
+use serde::Deserialize;
+#[cfg(feature = "serialize")]
+use serde::Serialize;
use std::{fmt::Debug, ops::Deref, path::PathBuf, rc::Rc};
#[cfg(feature = "dump")]
use structdump_derive::Codegen;
-#[cfg(feature = "serialize")]
-use serde::Serialize;
-#[cfg(feature = "deserialize")]
-use serde::Deserialize;
#[cfg_attr(feature = "dump", derive(Codegen))]
#[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]