grammar Json5 { patterns: ("*.json5") } entry union Value { | Object #Object | Array #Array | String #String | Number #Number | Boolean #Boolean | Null #Null } class Object { '{' (ObjectPair (COMMA ObjectPair)* COMMA)? '}' } class ObjectPair { ObjectKey COLON Value } union ObjectKey { | Identifier | String } class Array { '[' (Value (COMMA Value)* COMMA)? ']' } atomic class String { | '"' StringElement* '"' | "'" StringElement* "'" } atomic union StringElement { | '\' HexDigit #HexDigit | '\' Escaped #Escaped | StringText #StringText } text class HexDigit { /[0-9a-fA-F]{4}/ } text class Escaped { ANY } text class StringText { /[^"'\\\\]+/ } atomic text class Number { /[+-]?(0|[1-9][0-9]*)/ } union Boolean { | "true" #True | "false" #False } class Null { "null" } class Identifier { /[_\p{XID_start}][\p{XID_continue}]*/ } token { COLON: ':' COMMA: ',' } hide class Comment { | '#' ROL } hide class WhiteSpace { // UNICODE_WHITE_SPACE ' ' | '\n' | '\r' }