git.delta.rocks / jrsonnet / refs/commits / 5349cbfcc104

difftreelog

fix remove comment escaping syntax

Yaroslav Bolyukin2024-08-30parent: #562e7b7.patch.diff
in: master

1 file changed

modifiedcrates/jrsonnet-parser/src/lib.rsdiffbeforeafterboth
40 /// Standard C-like comments40 /// Standard C-like comments
41 rule comment()41 rule comment()
42 = "//" (!eol()[_])* eol()42 = "//" (!eol()[_])* eol()
43 / "/*" ("\\*/" / "\\\\" / (!("*/")[_]))* "*/"43 / "/*" (!("*/")[_])* "*/"
44 / "#" (!eol()[_])* eol()44 / "#" (!eol()[_])* eol()
4545
46 rule single_whitespace() = quiet!{([' ' | '\r' | '\n' | '\t'] / comment())} / expected!("<whitespace>")46 rule single_whitespace() = quiet!{([' ' | '\r' | '\n' | '\t'] / comment())} / expected!("<whitespace>")
597 );597 );
598 }598 }
599
600 /// Comments should be able to be escaped
601 #[test]
602 fn comment_escaping() {
603 assert_eq!(
604 parse!("2/*\\*/+*/ - 22"),
605 el!(
606 Expr::BinaryOp(el!(Expr::Num(2.0), 0, 1), Sub, el!(Expr::Num(22.0), 12, 14)),
607 0,
608 14
609 )
610 );
611 }
612599
613 #[test]600 #[test]
614 fn suffix() {601 fn suffix() {