Skip to content

Commit 4a84648

Browse files
Clean up Grammar (#54)
* Clean up GRAMMAR for ingest into website * Fix function expressions link
1 parent 6bb7c83 commit 4a84648

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

GRAMMAR

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1+
; This file is parsed to generate the specification included in the website
12
; Double semicolons (;;) at the beginning of a line represent documentation in markdown format for the preceding rule
23
; intended for inclusion in the html version of the specification.
34
; Double semicolons inline with a rule represent an alternative header to use when rendering markdown. This can optionally
45
; include a trailing '\' to indicate that it is to be included with the documentation of the following rule.
56

6-
;; # JMESPath Specification
7-
;;
8-
;; This document describes the specification for jmespath.
9-
;;
10-
;; If you'd like an introduction to the JMESPath language, see the JMESPath Tutorial and the JMESPath Examples page.
11-
;;
12-
;; In the specification, examples are shown through the use of a search function. The syntax for this function is:
7+
;; In this specification, examples are shown through the use of a search function. The syntax for this function is:
138
;;
149
;; ```
1510
;; search(<jmespath expr>, <JSON document>) -> <return value>
@@ -33,7 +28,7 @@
3328
;; - object (an unordered collection of key value pairs)
3429
;; - null
3530
;;
36-
;; Expression types are discussed in the Functions Expressions section.
31+
;; Expression types are discussed in the [Function Expressions](#function-expressions) section.
3732
;;
3833
;; Implementations can map the corresponding JSON types to their language equivalent. For example, a JSON null could map to
3934
;; None in python, and nil in ruby and go.
@@ -49,15 +44,17 @@
4944
;; - and: &&
5045
;; - unary not: !
5146
;; - rbracket: ]
47+
;;
48+
;; %%GRAMMAR%%
5249

5350
expression = sub-expression / index-expression / comparator-expression / list-filter-expr
5451
expression =/ or-expression / identifier
5552
expression =/ and-expression / not-expression / paren-expression
5653
expression =/ multi-select-list / multi-select-hash / literal
5754
expression =/ function-expression / pipe-expression / raw-string
5855
expression =/ current-node
59-
sub-expression = expression "." ( identifier / multi-select-list / multi-select-hash / function-expression / "*" ) ;; # SubExpressions
60-
;; A subexpression is a combination of two expressions separated by the '.' char. A subexpression is evaluated as follows:
56+
sub-expression = expression "." ( identifier / multi-select-list / multi-select-hash / function-expression / "*" ) ;; # Sub-expressions
57+
;; A sub-expression is a combination of two expressions separated by the '.' char. A sub-expression is evaluated as follows:
6158
;;
6259
;; - Evaluate the expression on the left with the original JSON document.
6360
;; - Evaluate the expression on the right with the result of the left expression evaluation.
@@ -67,7 +64,7 @@ sub-expression = expression "." ( identifier / multi-select-list / multi-sele
6764
;; left-evaluation = search(left-expression, original-json-document)
6865
;; result = search(right-expression, left-evaluation)
6966
;; ```
70-
;; A subexpression is itself an expression, so there can be multiple levels of subexpressions: grandparent.parent.child.
67+
;; A sub-expression is itself an expression, so there can be multiple levels of sub-expressions: grandparent.parent.child.
7168
;; Examples
7269
;;
7370
;; Given a JSON document: ``{"foo": {"bar": "baz"}}``, and a jmespath expression: foo.bar, the evaluation process would be:
@@ -202,7 +199,7 @@ not-expression = "!" expression ;; # Not Expressions
202199
;; search(!EmptyList, {"EmptyList": []}) -> true
203200
;; ```
204201

205-
paren-expression = "(" expression ")" ;; # Paren Expressions
202+
paren-expression = "(" expression ")" ;; # Parenthetical Expressions
206203
;; A paren-expression allows a user to override the precedence order of an expression, e.g. (a || b) && c.
207204
;;
208205
;; ## Examples
@@ -439,7 +436,7 @@ comparator = "<" / "<=" / "==" / ">=" / ">" / "!="
439436
;; search(foo[?a==b], {"foo": [{"a": 1, "b": 2}, {"a": 2, "b": 2}]}) -> [{"a": 2, "b": 2}]
440437
;; ```
441438

442-
function-expression = unquoted-string ( no-args / one-or-more-args ) ;; # Functions Expressions \
439+
function-expression = unquoted-string ( no-args / one-or-more-args ) ;; # Function Expressions \
443440
no-args = "(" ")" ;; \
444441
one-or-more-args = "(" ( function-arg *( "," function-arg ) ) ")" ;; \
445442
function-arg = expression / expression-type ;; \
@@ -539,13 +536,14 @@ raw-string-escape = escape ("'" / escape)
539536
;; - Not expanding tab characters or any other escape sequences documented in RFC 4627 section 2.5.
540537
;;
541538
;; ## Examples
542-
;;
539+
;; ```
543540
;; search('foo', "") -> "foo"
544541
;; search(' bar ', "") -> " bar "
545542
;; search('[baz]', "") -> "[baz]"
546543
;; search('[baz]', "") -> "[baz]"
547544
;; search('\u03a6', "") -> "\u03a6"
548545
;; search('\\', "") -> "\\"
546+
;; ```
549547

550548
literal = "`" json-value "`" ;; # Literal Expressions
551549
;; A literal expression is an expression that allows arbitrary JSON objects to be specified. This is useful in filter

0 commit comments

Comments
 (0)