Appendix A. Collected ABNF Grammars (Grammaires ABNF recueillies)
Appendix A. Collected ABNF Grammars (Grammaires ABNF recueillies)
Cet appendice rassemble la grammaire ABNF des passages ABNF utilisés dans tout le document.
La figure 2 contient la grammaire ABNF recueillie qui définit la syntaxe d'une requête JSONPath.
jsonpath-query = root-identifier segments
segments = *(S segment)
B = %x20 / ; Space
%x09 / ; Horizontal tab
%x0A / ; Line feed or New line
%x0D ; Carriage return
S = *B ; optional blank space
root-identifier = "$"
selector = name-selector /
wildcard-selector /
slice-selector /
index-selector /
filter-selector
name-selector = string-literal
string-literal = %x22 *double-quoted %x22 / ; "string"
%x27 *single-quoted %x27 ; 'string'
double-quoted = unescaped /
%x27 / ; '
ESC %x22 / ; \"
ESC escapable
single-quoted = unescaped /
%x22 / ; "
ESC %x27 / ; \'
ESC escapable
ESC = %x5C ; \ backslash
unescaped = %x20-21 / ; see RFC 8259
; omit 0x22 "
%x23-26 /
; omit 0x27 '
%x28-5B /
; omit 0x5C \
%x5D-D7FF /
; skip surrogate code points
%xE000-10FFFF
escapable = %x62 / ; b BS backspace U+0008
%x66 / ; f FF form feed U+000C
%x6E / ; n LF line feed U+000A
%x72 / ; r CR carriage return U+000D
%x74 / ; t HT horizontal tab U+0009
"/" / ; / slash (solidus) U+002F
"\" / ; \ backslash (reverse solidus) U+005C
(%x75 hexchar) ; uXXXX U+XXXX
hexchar = non-surrogate /
(high-surrogate "\" %x75 low-surrogate)
non-surrogate = ((DIGIT / "A"/"B"/"C" / "E"/"F") 3HEXDIG) /
("D" %x30-37 2HEXDIG )
high-surrogate = "D" ("8"/"9"/"A"/"B") 2HEXDIG
low-surrogate = "D" ("C"/"D"/"E"/"F") 2HEXDIG
HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F"
wildcard-selector = "*"
index-selector = int ; decimal integer
int = "0" /
(["-"] DIGIT1 *DIGIT) ; - optional
DIGIT1 = %x31-39 ; 1-9 non-zero digit
slice-selector = [start S] ":" S [end S] [":" [S step ]]
start = int ; inclus dans la sélection
end = int ; non inclus dans la sélection
step = int ; défaut : 1
filter-selector = "?" S logical-expr
logical-expr = logical-or-expr
logical-or-expr = logical-and-expr *(S "||" S logical-and-expr)
logical-and-expr = basic-expr *(S "&&" S basic-expr)
basic-expr = paren-expr /
comparison-expr /
test-expr
paren-expr = [logical-not-op S] "(" S logical-expr S ")"
logical-not-op = "!"
test-expr = [logical-not-op S]
(filter-query /
function-expr)
filter-query = rel-query / jsonpath-query
rel-query = current-node-identifier segments
current-node-identifier = "@"
comparison-expr = comparable S comparison-op S comparable
literal = number / string-literal /
true / false / null
comparable = literal /
singular-query /
function-expr
comparison-op = "==" / "!=" /
"<=" / ">=" /
"<" / ">"
singular-query = rel-singular-query / abs-singular-query
rel-singular-query = current-node-identifier singular-query-segments
abs-singular-query = root-identifier singular-query-segments
singular-query-segments = *(S (name-segment / index-segment))
name-segment = ("[" name-selector "]") /
("." member-name-shorthand)
index-segment = "[" index-selector "]"
number = (int / "-0") [ frac ] [ exp ]
frac = "." 1*DIGIT
exp = "e" [ "-" / "+" ] 1*DIGIT
true = %x74.72.75.65
false = %x66.61.6c.73.65
null = %x6e.75.6c.6c
function-name = function-name-first *function-name-char
function-name-first = LCALPHA
function-name-char = function-name-first / "_" / DIGIT
LCALPHA = %x61-7A ; "a".."z"
function-expr = function-name "(" S [function-argument
*(S "," S function-argument)] S ")"
function-argument = literal /
filter-query /
logical-expr /
function-expr
segment = child-segment / descendant-segment
child-segment = bracketed-selection /
("."
(wildcard-selector /
member-name-shorthand))
bracketed-selection = "[" S selector *(S "," S selector) S "]"
member-name-shorthand = name-first *name-char
name-first = ALPHA /
"_" /
%x80-D7FF /
%xE000-10FFFF
name-char = name-first / DIGIT
DIGIT = %x30-39
ALPHA = %x41-5A / %x61-7A
descendant-segment = ".." (bracketed-selection /
wildcard-selector /
member-name-shorthand)
Figure 2 : ABNF recueilli des requêtes JSONPath
La figure 3 contient la grammaire ABNF recueillie qui définit la syntaxe d'un chemin normalisé JSONPath tout en réutilisant les règles root-identifier, ESC, DIGIT et DIGIT1 de la figure 2.
normalized-path = root-identifier *(normal-index-segment)
normal-index-segment = "[" normal-selector "]"
normal-selector = normal-name-selector / normal-index-selector
normal-name-selector = %x27 *normal-single-quoted %x27 ; 'string'
normal-single-quoted = normal-unescaped /
ESC normal-escapable
normal-unescaped =
%x20-26 /
%x28-5B /
%x5D-D7FF /
%xE000-10FFFF
normal-escapable = %x62 /
%x66 /
%x6E /
%x72 /
%x74 /
"'" /
"\" /
(%x75 normal-hexchar)
normal-hexchar = "0" "0"
(
("0" %x30-37) /
("0" %x62) /
("0" %x65-66) /
("1" normal-HEXDIG)
)
normal-HEXDIG = DIGIT / %x61-66
normal-index-selector = "0" / (DIGIT1 *DIGIT)
Figure 3 : ABNF recueilli des chemins normalisés JSONPath