From 18e828f17cc3f87728d57e424814df45b5eec7f1 Mon Sep 17 00:00:00 2001 From: Stephen Dolan Date: Tue, 17 Dec 2013 22:28:26 +0000 Subject: [PATCH] Allow negated object values without parens. Fixes #247 --- parser.y | 4 +++- tests/all.test | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/parser.y b/parser.y index 4c0b6a2..bc7bba9 100644 --- a/parser.y +++ b/parser.y @@ -458,7 +458,9 @@ ExpD: ExpD '|' ExpD { $$ = block_join($1, $3); } | - +'-' ExpD { + $$ = BLOCK($2, gen_call("_negate", gen_noop())); +} | Term { $$ = $1; } diff --git a/tests/all.test b/tests/all.test index 259cdf2..f50b7eb 100644 --- a/tests/all.test +++ b/tests/all.test @@ -36,6 +36,10 @@ null null [] +{x: -1} +null +{"x": -1} + # The input line starts with a 0xFEFF (byte order mark) codepoint # No, there is no reason to have a byte order mark in UTF8 text. # But apparently people do, so jq shouldn't break on it. -- 2.40.0