-
Notifications
You must be signed in to change notification settings - Fork 9
/
jsox2.ebnf
80 lines (70 loc) · 4.5 KB
/
jsox2.ebnf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
Name = "JSON Grammar".
Author = "d3x0r".
Version = "1.0".
WS = "(whitespace)" ( "\\x20" | "\\r" | "\\n" | "\\t" | "\\u07ec" | "\\u07ed" ) { "\\x20" | "\\r" | "\\n" | "\\t" | "\\u07ec" | "\\u07ed" } .
LegalEscapes = "(Legal Escapes)" ( "b" | "n" | "r" | "f" | "t" | ("'" | '"' | "`")
| ( "u" ( "{" {"0-9" | "A-F" | "a-f"} "}" | "4 hex digits" ) )
| ( "x" ("0-9" | "A-F" | "a-f") ("0-9" | "A-F" | "a-f") )
| ( "0-2" "0-7" "0-7" )
).
Val = "(Value)" (
("(Comment)" ( ( "/" "/" { "character not \\n or \\r" } ("\\r"|"\\n") )
| ( "/" "*" { "character" } "*" "/" )
)|
( "(whitespace)" {( "\\x20" | "\\r" | "\\n" | "\\t" | "\\u07ec" | "\\u07ed" )} ) |
("(String)" ( '"'| "'"| "`") ( ( 'character not open-quote or \\ ' ) | ( '\\' '"' ) | ("\\" "\\" ) | ( "\\" "Legal Escapes" ) )
{ ( 'character not open-quote or \\ ' ) | ( '\\' '"' ) | ("\\" "\\" ) | ( "\\" "Legal Escapes" ) }
)
( '"'| "'"| "`") )|
( "(ident)" ( "String" | ( ( "not \\u{FEFF}" | "non-digit" | "not { [ ( < > ) ] } , : \" ' ` ~ ! + - * / ." | "a-z" "A-Z" )
{ "not \\u{FEFF}" | "non-digit" | "not { [ ( < > ) ] } , : \" ' ` ~ ! + - * / ." | "a-z" "A-Z" "0-9" }
)
)
)
( "(Object)" "{" ( (|"whitespace")ident(|"whitespace") ":" Value ) { "," ( (|"whitespace") ident (|"whitespace") ":" Value) } "}" ) |
( "(typed-object-def)" ident object ) |
( "(typed-object-use)" ident "{" ( Value ) { "," (Value) } "}" ) |
( "(Array)" "[" ( Value ) { "," Value } "]" ) |
( "(typed-array)" "ident" "Array" ) |
( "(typed-string)" "ident" String ) |
( |"-") ( "NaN" | "Infinity" |
( ( "-" | "+" ) { "-" | "+" } | ("0-9") ) "/*Number Parser Begin*/"
( ( "(BigInt)" (("0-9"){ "0-9"|"_" }) "n" ) |
"(Number)"( "(int)" ( ( "if 0" {"_"} (
( ( "x" | "X" ) ("0-9" | "A-F" | "a-f" |"_") {"0-9" | "A-F" | "a-f" |"_"} ) |
( ( "o" | "O" ) ("0-7"|"_") { "0-7"|"_" } ) |
( ( "b" | "B" ) ("0-1"|"_") { "0-1"|"_" } ) ) )
| ( ("0-9"|"_") {"0-9"|"_"} (| "(float)" (| "." { "0-9" |"_"} ) (| ( ( "e" | "E" ) (|"+"|"-"|"_") ("0-9"|"_") { "0-9"|"_" } ) ) ) )
)
)
| "(Date)" ( ( ( "0-9" |"-"){"0-9"|"-"} "T" ( "0-9" |":"){"0-9"|":"} (|"." ("0-9"){"0-9"} ))
(
| "/*Timezone*/" ( ( |"+"|"-") "0-9" "0-9" ":" "0-9" "0-9"
| "Z" ) ) )
)) |
true | false | null | undefined ).
PredefinedTypes = (
( "(TypedArray)" ( "ab" | "u8" | "s8" | "u8" | "u16" | "s16"
| "u32"
| "s32"
| "f32"
| "f64"
) "[" "base64 ArrayBuffer bytes" "]" ) |
( "(reference)" "ref" "[" ( (|"whitespace")( "ident" | "int" ) (|"whitespace") { ("," (|"whitespace")( "ident" | "int" )(|"whitespace")) }) "]" )
).
NumberRule = ("(Number/Date/BigInt)"
( |"-") ( "NaN" | "Infinity" |
( ( "-" | "+" ) { "-" | "+" } | ("0-9") ) "/*Number Parser Begin*/"
( ( "(BigInt)" (("0-9"){ "0-9"|"_" }) "n" ) |
"(Number)"( "(int)" ( ( "if 0" {"_"} (
( ( "x" | "X" ) ("0-9" | "A-F" | "a-f" |"_") {"0-9" | "A-F" | "a-f" |"_"} ) |
( ( "o" | "O" ) ("0-7"|"_") { "0-7"|"_" } ) |
( ( "b" | "B" ) ("0-1"|"_") { "0-1"|"_" } ) ) )
| ( ("0-9"|"_") {"0-9"|"_"} (| "(float)" (| "." { "0-9" |"_"} ) (| ( ( "e" | "E" ) (|"+"|"-"|"_") ("0-9"|"_") { "0-9"|"_" } ) ) ) )
)
)
| "(Date)" ( ( ( "0-9" |"-"){"0-9"|"-"} "T" ( "0-9" |":"){"0-9"|":"} (|"." ("0-9"){"0-9"} ))
(
| "/*Timezone*/" ( ( |"+"|"-") "0-9" "0-9" ":" "0-9" "0-9"
| "Z" ) ) )
))).