Skip to content

Commit 9b898fb

Browse files
committed
Allow current node as an expression
This now passes the latest compliance tests.
1 parent 73d5265 commit 9b898fb

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

jmespath.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,10 @@
528528
return {type: "ValueProjection", children: [left, right]};
529529
},
530530

531+
nudCurrent: function() {
532+
return {type: "Current"};
533+
},
534+
531535
nudLbracket: function() {
532536
if (this.lookahead(0) === "Number" || this.lookahead(0) === "Colon") {
533537
var right = this.parseIndexExpression();

test/compliance/current.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[
2+
{
3+
"given": {
4+
"foo": [{"name": "a"}, {"name": "b"}],
5+
"bar": {"baz": "qux"}
6+
},
7+
"cases": [
8+
{
9+
"expression": "@",
10+
"result": {
11+
"foo": [{"name": "a"}, {"name": "b"}],
12+
"bar": {"baz": "qux"}
13+
}
14+
},
15+
{
16+
"expression": "@.bar",
17+
"result": {"baz": "qux"}
18+
},
19+
{
20+
"expression": "@.foo[0]",
21+
"result": {"name": "a"}
22+
}
23+
]
24+
}
25+
]

test/compliance/syntax.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,6 @@
9595
{
9696
"expression": "a][",
9797
"error": "syntax"
98-
},
99-
{
100-
"expression": "@",
101-
"error": "syntax"
102-
},
103-
{
104-
"expression": "@.foo",
105-
"error": "syntax"
10698
}
10799
]
108100
},

0 commit comments

Comments
 (0)