module lang::json::\syntax::JSON
rascal-0.40.16
Usage
import lang::json::\syntax::JSON;
syntax JSONText
start syntax JSONText
= Object
| Array
;
syntax Value
syntax Value
= Object
| Array
| NumericLiteral
| StringLiteral
| False: "false"
| Null: "null"
| True: "true"
;
syntax Object
syntax Object
= Object: "{" { Member "," }* members "}"
;
syntax Member
syntax Member
= Member: StringLiteral memberName ":" Value memberValue
;
syntax Array
syntax Array
= Array: "[" { Value ","}* values "]"
;
syntax NumericLiteral
lexical NumericLiteral
= RealLiteral
| IntegerLiteral
;
syntax RealLiteral
lexical RealLiteral
= [\-]? [0] [E e] [+ \-]? [0-9]+
| [\-]? [1-9] [0-9]* [E e] [+ \-]? [0-9]+
| [\-]? [0] "." !>> "." [0-9]*
| [\-]? [1-9] [0-9]* "." !>> "." [0-9]*
| [\-]? [0] "." [0-9]* [E e] [+ \-]? [0-9]+
| [\-]? [1-9] [0-9]* "." [0-9]* [E e] [+ \-]? [0-9]+
;
syntax IntegerLiteral
lexical IntegerLiteral
= [\-]? "0" !>> [0-9]
| [\-]? [1-9] [0-9]* !>> [0-9] ;
syntax StringLiteral
lexical StringLiteral
= "\"" StringChar* chars "\"";
syntax StringChar
lexical StringChar
= ![\" \\]
| "\\" [\" \\ / b f n r t]
| UnicodeEscape
;
syntax UnicodeEscape
lexical UnicodeEscape
= utf16: "\\" [u] [0-9 A-F a-f] [0-9 A-F a-f] [0-9 A-F a-f] [0-9 A-F a-f]
| utf32: "\\" [U] [0-9 A-F a-f] [0-9 A-F a-f] [0-9 A-F a-f] [0-9 A-F a-f] [0-9 A-F a-f] [0-9 A-F a-f]
;
syntax JSONKeywords
keyword JSONKeywords
= "false"
| "null"
| "true"
;
syntax LAYOUT
layout LAYOUT
= [\t-\n \r \ ]* !>> [\t-\n \r \ ]
;