Syntax Specification

The JSON syntax is formally specified in terms of a standard JSON parser, which will return native JSON objects, and a second-level JSON string parser, that will return structured SDF instances as described the specification in the previous section. The final instantiated type(s) will further depend on the formal type(s) in the model context.

TBD: provide Antlr4 files

JSON Syntax Elements

The following EBNF is the standard JSON parser production rules from JSON.org.

json =
   element ;

value =
   object
   | array
   | string
   | number
   | "true"
   | "false"
   | "null"
   ;

object =
    '{' ws '}'
    | '{' members '}'
    ;

members =
    member
    | member ',' members
    ;

member =
    ws string ws ':' element ;

array =
    '[' ws ']'
    | '[' elements ']'
    ;

elements =
    element
    | element ',' elements
    ;

element =
    ws value ws ;

string =
    '"' characters '"' ;

characters =
    ""
    | character characters
    ;

character =
    '0020' - '10FFFF'
    | '"' - '\'
    | '\' escape
    ;

escape =
    '"'
    | '\'
    | '/'
    | 'b'
    | 'f'
    | 'n'
    | 'r'
    | 't'
    | 'u' hex hex hex hex
    ;

hex =
    digit
    | 'A' - 'F'
    | 'a' - 'f'
    ;

number =
    integer fraction exponent ;

integer =
    digit
    | onenine digits
    | '-' digit
    | '-' onenine digits
    ;

digits =
    digit
    | digit digits
    ;

digit =
    '0'
    | onenine
    ;

onenine =
    '1' - '9' ;

fraction =
    ""
    | '.' digits
    ;

exponent =
    ""
    | 'E' sign digits
    | 'e' sign digits
    ;

sign =
    ""
    | '+'
    | '-'
    ;

ws =
    ""
    | '0020' ws
    | '000A' ws
    | '000D' ws
    | '0009' ws
    ;

String Parser

TBD: define