git.delta.rocks / jrsonnet / refs/commits / 2aa6f7043c18

difftreelog

feat(parser) bitnot, python comments

Лач2020-06-04parent: #e4b623d.patch.diff
in: master

1 file changed

modifiedcrates/jsonnet-parser/src/lib.rsdiffbeforeafterboth
30 rule comment() = "//" (!['\n'][_])* "\n" / "/*" ((!("*/")[_][_])/("\\" "*/"))* "*/"30 rule comment()
31 = "//" (!['\n'][_])* "\n"
32 / "/*" ((!("*/")[_][_])/("\\" "*/"))* "*/"
33 / "#" (!['\n'][_])* "\n"
34
31 rule _() = ([' ' | '\n' | '\t'] / comment())*35 rule _() = ([' ' | '\n' | '\t'] / comment())*
3236
245 a:(@) _ "%" _ b:@ {loc_expr_todo!(Expr::BinaryOp(a, BinaryOpType::Mod, b))}249 a:(@) _ "%" _ b:@ {loc_expr_todo!(Expr::BinaryOp(a, BinaryOpType::Mod, b))}
246 --250 --
247 e:expr_basic_with_suffix(s) {e}251 e:expr_basic_with_suffix(s) {e}
248 "-" _ expr:expr_basic_with_suffix(s) { loc_expr_todo!(Expr::UnaryOp(UnaryOpType::Minus, expr)) }252 "-" _ expr:expr(s) { loc_expr_todo!(Expr::UnaryOp(UnaryOpType::Minus, expr)) }
249 "!" _ expr:expr_basic_with_suffix(s) { loc_expr_todo!(Expr::UnaryOp(UnaryOpType::Not, expr)) }253 "!" _ expr:expr(s) { loc_expr_todo!(Expr::UnaryOp(UnaryOpType::Not, expr)) }
254 "~" _ expr:expr(s) { loc_expr_todo!(Expr::UnaryOp(UnaryOpType::BitNot, expr)) }
250 "(" _ e:expr(s) _ ")" {loc_expr_todo!(Expr::Parened(e))}255 "(" _ e:expr(s) _ ")" {loc_expr_todo!(Expr::Parened(e))}
251 } end:position!() {256 } end:position!() {
252 let LocExpr(e, _) = a;257 let LocExpr(e, _) = a;
474 );479 );
475 }480 }
481
482 #[test]
483 fn double_negation() {
484 use Expr::*;
485 assert_eq!(
486 parse!("!!a"),
487 el!(UnaryOp(
488 UnaryOpType::Not,
489 el!(UnaryOp(UnaryOpType::Not, el!(Var("a".to_owned()))))
490 ))
491 )
492 }
476493
477 #[test]494 #[test]
478 fn can_parse_stdlib() {495 fn can_parse_stdlib() {