From 596f31e7c6e59685d1c04e91ea01b5982c044459 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 24 May 2016 17:06:50 +0200 Subject: [PATCH] parser: allow root path specifications All a patch specification to be just '@' or '$' - this is mainly useful when exporting the keys of the toplevel object to the shell. Example: $ echo '{ "abc": 1, "def": 2 }' | jsonpath -e 'keys=@' export keys='abc'\ 'def'; Signed-off-by: Jo-Philipp Wich --- parser.y | 2 ++ 1 file changed, 2 insertions(+) diff --git a/parser.y b/parser.y index f77779b..f037a69 100644 --- a/parser.y +++ b/parser.y @@ -56,6 +56,8 @@ expr(A) ::= path(B). { A = B; } path(A) ::= T_ROOT segments(B). { A = alloc_op(T_ROOT, 0, NULL, B); } path(A) ::= T_THIS segments(B). { A = alloc_op(T_THIS, 0, NULL, B); } +path(A) ::= T_ROOT(B). { A = B; } +path(A) ::= T_THIS(B). { A = B; } segments(A) ::= segments(B) segment(C). { A = append_op(B, C); } segments(A) ::= segment(B). { A = B; } -- 2.25.1