Better HF grammar implementation (#4953)

This commit is contained in:
oobabooga 2023-12-17 02:01:23 -03:00 committed by GitHub
parent aa200f8723
commit 12690d3ffc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 830 additions and 116 deletions

View file

@ -1,25 +1,14 @@
root ::= object
object ::= "{" ws ( string ":" ws value ("," ws string ":" ws value)* )? "}"
value ::= object | array | string | number | ("true" | "false" | "null") ws
object ::=
"{" ws (
string ":" ws value
("," ws string ":" ws value)*
)? "}" ws
array ::= "[" ws ( value ("," ws value)* )? "]" ws
array ::=
"[" ws (
value
("," ws value)*
)? "]" ws
string ::=
"\"" (
[^"\\] |
"\\" (["\\/bfnrt] | "u" [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F]) # escapes
)* "\"" ws
string ::= "\"" ( [a-zA-Z0-9] )* "\"" ws
number ::= ("-"? ([0-9] | [1-9] [0-9]*)) ("." [0-9]+)? ([eE] [-+]? [0-9]+)? ws
# Optional space: by convention, applied in this grammar after literal chars when allowed
ws ::= ([ \t\n] ws)?