Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// JSON Number.
Number: /^-?(?:0|(?:[1-9][0-9]*))(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?/,
// JSON String.
String: /^"(?:[^"\\]|\\(?:"|\/|\\|b|f|n|r|t|u[0-9a-fA-F]{4}))*"?/,
// JSON literal keywords.
Keyword: /^true|false|null/,
};
/**
* The parser rules for JSON.
*/
const ParseRules = {
Document: [p('{'), list('Variable', opt(p(','))), p('}')],
Variable: [namedKey('variable'), p(':'), 'Value'],
Value(token) {
switch (token.kind) {
case 'Number':
return 'NumberValue';
case 'String':
return 'StringValue';
case 'Punctuation':
switch (token.value) {
case '[':
return 'ListValue';
case '{':
return 'ObjectValue';
}
return null;
case 'Keyword':