## Full example

    // Source: https://github.com/antlr/grammars-v4/blob/master/json/JSON.g4

    /** Taken from "The Definitive ANTLR 4 Reference" by Terence Parr */

    // Derived from http://json.org
    grammar JSON;

    json
       : value
       ;

    obj
       : '{' pair (',' pair)* '}'
       | '{' '}'
       ;

    pair
       : STRING ':' value
       ;

    array
       : '[' value (',' value)* ']'
       | '[' ']'
       ;

    value
       : STRING
       | NUMBER
       | obj
       | array
       | 'true'
       | 'false'
       | 'null'
       ;

    STRING
       : '"' (ESC | SAFECODEPOINT)* '"'
       ;

    fragment ESC
       : '\\' (["\\/bfnrt] | UNICODE)
       ;
    fragment UNICODE
       : 'u' HEX HEX HEX HEX
       ;
    fragment HEX
       : [0-9a-fA-F]
       ;
    fragment SAFECODEPOINT
       : ~ ["\\\u0000-\u001F]
       ;

    NUMBER
       : '-'? INT ('.' [0-9] +)? EXP?
       ;

    fragment INT
       : '0' | [1-9] [0-9]*
       ;

    // no leading zeros

    fragment EXP
       : [Ee] [+\-]? INT
       ;

    // \- since - means "range" inside [...]

    WS
       : [ \t\n\r] + -> skip
       ;