@sap/cds-dk 8.3.0 → 8.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +40 -13
  2. package/bin/build.js +1 -1
  3. package/bin/cds.js +12 -0
  4. package/bin/compile/index.js +6 -1
  5. package/bin/env.js +3 -2
  6. package/bin/init.js +8 -4
  7. package/bin/repl.js +3 -3
  8. package/lib/build/util.js +32 -20
  9. package/lib/deploy/to-hana/hana.js +2 -21
  10. package/lib/env/schemas/cds-rc.js +174 -2
  11. package/lib/import/asyncapi/parserContext.js +4 -30
  12. package/lib/import/odata/v2parser.js +3 -2
  13. package/lib/import/openapi/importOpenAPI.js +616 -569
  14. package/lib/import/openapi/utilities.js +7 -2
  15. package/lib/init/constants.js +2 -1
  16. package/lib/init/index.js +4 -0
  17. package/lib/init/projectReader.js +1 -2
  18. package/lib/init/registries/mta.js +8 -1
  19. package/lib/init/template/approuter/files/package.json +1 -1
  20. package/lib/init/template/cf-manifest/files/manifest.yml.hbs +3 -1
  21. package/lib/init/template/enterprise-messaging-shared/index.js +1 -1
  22. package/lib/init/template/file-based-messaging/index.js +1 -1
  23. package/lib/init/template/hana/files/package.json.hbs +2 -0
  24. package/lib/init/template/hana/index.js +1 -1
  25. package/lib/init/template/handler/index.js +1 -1
  26. package/lib/init/template/html5-repo/files/app-package.json.hbs +2 -2
  27. package/lib/init/template/html5-repo/files/ui5-deploy.yaml.hbs +2 -2
  28. package/lib/init/template/local-messaging/index.js +1 -1
  29. package/lib/init/template/nodejs/files/.vscode/extensions.json +0 -5
  30. package/lib/init/template/nodejs/files/.vscode/settings.json +1 -1
  31. package/lib/init/template/nodejs/files/.vscode/tasks.json +0 -2
  32. package/lib/init/template/nodejs/files/package.json.hbs +1 -1
  33. package/lib/init/template/postgres/index.js +1 -1
  34. package/lib/init/template/redis-messaging/index.js +1 -1
  35. package/lib/init/template/side-by-side-extensibility/files/mta.yaml.hbs +40 -0
  36. package/lib/init/template/side-by-side-extensibility/files/package.json.hbs +17 -0
  37. package/lib/init/template/side-by-side-extensibility/index.js +34 -0
  38. package/lib/init/template/typescript/files/package.json +2 -2
  39. package/lib/init/template/xsuaa/index.js +1 -1
  40. package/lib/util/fs.js +1 -1
  41. package/lib/util/jsonc.js +1 -1
  42. package/lib/util/jsonc.pegjs +6 -2
  43. package/npm-shrinkwrap.json +55 -143
  44. package/package.json +1 -1
@@ -2,8 +2,13 @@ module.exports = { cdsName, nameFromPath, pathAndMethod, serviceName };
2
2
 
3
3
  function cdsName(oasName) {
4
4
  if (oasName === "") return "_";
5
+ if (typeof oasName === "number") return `_${JSON.stringify(oasName)}`;
5
6
  let name = oasName;
6
- if (name.match(/^(\p{Nd}|\p{Mn}|\p{Mc}|\p{Pc}|\p{Cf})/u)) name = "_" + name;
7
+ if (
8
+ !name.startsWith("_") &&
9
+ name.match(/^(\p{Nd}|\p{Mn}|\p{Mc}|\p{Pc}|\p{Cf})/u)
10
+ )
11
+ name = "_" + name;
7
12
  return name.replace(/[^_\p{L}\p{Nl}\p{Nd}\p{Mn}\p{Mc}\p{Pc}\p{Cf}]/gu, "_");
8
13
  //TODO: shorten if longer than 128 characters
9
14
  }
@@ -15,7 +20,7 @@ function nameFromPath(path, method) {
15
20
  .replace(/{[^}]+}/g, ".")
16
21
  .replace(/\/\./g, "_")
17
22
  .replace(/[^_\p{L}\p{Nl}\p{Nd}\p{Mn}\p{Mc}\p{Pc}\p{Cf}]/gu, "_");
18
- if (cleanPath === "") cleanPath = "_";
23
+ if (cleanPath === "") cleanPath = "_root";
19
24
  //TODO: shorten if longer than 128 characters
20
25
  return method === "get" ? cleanPath : `${cleanPath}_${method}`;
21
26
  }
@@ -5,7 +5,7 @@ module.exports = {
5
5
  COMMAND_ADD: 'add',
6
6
 
7
7
  JAVA_LTS_VERSIONS: [17, 21],
8
- MAVEN_ARCHETYPE_VERSION: '3.2.0',
8
+ MAVEN_ARCHETYPE_VERSION: '3.3.1',
9
9
 
10
10
  OPTIONS: Object.freeze({
11
11
  COMPLETION: 'completion',
@@ -24,6 +24,7 @@ module.exports = {
24
24
  MULTITENANCY: 'multitenancy',
25
25
  TOGGLES: 'toggles',
26
26
  EXTENSIBILITY: 'extensibility',
27
+ SIDE_BY_SIDE_EXTENSIBILITY: 'side-by-side-extensibility',
27
28
  MTX: 'mtx',
28
29
  XSUAA: 'xsuaa',
29
30
  HANA: 'hana',
package/lib/init/index.js CHANGED
@@ -265,6 +265,10 @@ module.exports = class CDSGenerator {
265
265
  // set is ordered ... always
266
266
  options.add = new Set(trimmedTokens);
267
267
 
268
+ if (options?.java) { // --java -> --add java
269
+ options.add.add('java')
270
+ }
271
+
268
272
  if (cds.cli.command === COMMAND_INIT && !options.add.has(JAVA)) {
269
273
  options.add.add(NODEJS);
270
274
  }
@@ -89,7 +89,7 @@ module.exports = new class ProjectReader {
89
89
  * @property {boolean} hasApprouter Indicates if the project uses the SAP Application Router.
90
90
  * @property {boolean} hasHtml5Repo Indicates if the project uses the SAP BTP HTML5 Application Repository.
91
91
  * @property {boolean} hasPortal Indicates if the project uses the SAP Cloud Portal service.
92
- * @property {boolean} hasWorkzone Indicates if the project uses the SAP Build Work Zone service.
92
+ * @property {boolean} hasWorkzoneStandard Indicates if the project uses the SAP Build Work Zone, Standard Edition service.
93
93
  * @property {boolean} hasDestination Indicates if the project uses the SAP BTP Destination service.
94
94
  * @property {boolean} hasMTXRoute Indicates if the approuter should have a multitenant route.
95
95
  * @property {boolean} hasMTXRouteJava Indicates if the approuter should have a multitenant subscription route (java).
@@ -118,7 +118,6 @@ module.exports = new class ProjectReader {
118
118
  const isApp = name => name !== 'appconfig' && !name.startsWith('_') && name !== 'router' && name !== 'portal'
119
119
  const reserved = {
120
120
  has: x => _inProd(x),
121
- shortcut: () => true,
122
121
  profile: () => cds.cli.options?.for,
123
122
  language: () => exists('pom.xml') ? 'java' : 'nodejs',
124
123
  isJava: () => _isJava(),
@@ -5,7 +5,8 @@ const srvNode4 = path => ({ in: 'modules', where: { type: 'nodejs', path } })
5
5
  const srvJava4 = path => ({ in: 'modules', where: { type: 'java', path } })
6
6
 
7
7
  // REVISIT: Clean up
8
- const isJava = process.argv[process.argv.indexOf('--add') + 1].split(',').includes('java') || cds.env['project-nature'] === 'java' || cds.cli.options?.add?.has('java')
8
+ const isJava = process.argv[process.argv.indexOf('--add') + 1].split(/[,\s+]/).includes('java') || cds.env['project-nature'] === 'java' || cds.cli.options?.add?.has('java') || process.argv.includes('--java')
9
+
9
10
  const srv4 = isJava ? srvJava4 : srvNode4
10
11
 
11
12
  const approuter = { in: 'modules', where: { type: 'approuter.nodejs' } }
@@ -25,6 +26,11 @@ const destinations = {
25
26
  where: { type: 'com.sap.application.content', 'build-parameters.no-source': true }
26
27
  }
27
28
 
29
+ const destinationSideBySideExtensibility = {
30
+ in: [destinations, 'parameters.content.subaccount.destinations' ],
31
+ where: { URL: '~{srv-api/srv-url}', Authentication: 'OAuth2ClientCredentials' }
32
+ }
33
+
28
34
  const connectivity = {
29
35
  in: 'resources',
30
36
  where: { type: 'org.cloudfoundry.managed-service', 'parameters.service': 'connectivity' }
@@ -186,6 +192,7 @@ module.exports = {
186
192
  xsuaa,
187
193
  destination,
188
194
  destinations,
195
+ destinationSideBySideExtensibility,
189
196
  connectivity,
190
197
  enterpriseMessaging,
191
198
  kafkaMessaging,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "approuter",
3
3
  "dependencies": {
4
- "@sap/approuter": "^16.0.0"
4
+ "@sap/approuter": "^17.0.0"
5
5
  },
6
6
  "engines": {
7
7
  "node": "^20.0.0"
@@ -20,7 +20,9 @@ applications:
20
20
  disk_quota: 512M
21
21
  env:
22
22
  SPRING_PROFILES_ACTIVE: cloud
23
- buildpack: java_buildpack
23
+ JBP_CONFIG_COMPONENTS: "jres: ['com.sap.xs.java.buildpack.jdk.SAPMachineJDK']"
24
+ JBP_CONFIG_SAP_MACHINE_JDK: '{ version: 21.+ }'
25
+ buildpack: sap_java_buildpack_jakarta
24
26
  {{/isJava}}
25
27
  services:
26
28
  {{#hasHana}}
@@ -34,7 +34,7 @@ module.exports = class EnterpriseMessagingSharedTemplate extends require('../../
34
34
  const project = readProject()
35
35
  const { configFile, isNodejs } = project
36
36
  if (isNodejs) {
37
- project.shortcut = !(await read(configFile)).cds?.requires?.messaging?.kind
37
+ project.shortcut = typeof (await read(configFile)).cds?.requires?.messaging !== 'object'
38
38
  project.cloudevents = cds.cli.options.cloudevents
39
39
  await merge(__dirname, 'files/package.json.hbs').into(configFile, { with: project })
40
40
  }
@@ -21,7 +21,7 @@ module.exports = class FileBasedMessagingTemplate extends require('../../plugin'
21
21
  async run() {
22
22
  const project = readProject()
23
23
  const { configFile } = project
24
- project.shortcut = !(await read(configFile)).cds?.requires?.messaging?.kind
24
+ project.shortcut = typeof (await read(configFile)).cds?.requires?.messaging !== 'object'
25
25
  await merge(__dirname, 'files/package.json.hbs').into(configFile, { with: project })
26
26
  }
27
27
  }
@@ -1,7 +1,9 @@
1
1
  {
2
+ {{#isNodejs}}
2
3
  "dependencies": {
3
4
  "@cap-js/hana": "^1"
4
5
  },
6
+ {{/isNodejs}}
5
7
  {{#isNodejs}}
6
8
  "cds": {
7
9
  {{/isNodejs}}
@@ -20,7 +20,7 @@ module.exports = class HanaTemplate extends require('../../plugin') {
20
20
  async run() {
21
21
  const project = readProject()
22
22
  const { isJava, configFile, db } = project
23
- project.shortcut = !(await read(configFile)).cds?.requires?.db?.kind
23
+ project.shortcut = typeof (await read(configFile)).cds?.requires?.db !== 'object'
24
24
 
25
25
  // REVISIT: Let cds build generate those by default
26
26
  await merge(__dirname, 'files/src/.hdiconfig').into(join(db.folder, 'src/.hdiconfig'))
@@ -5,7 +5,7 @@ const mvn = require('../../mvn')
5
5
  module.exports = class Handler extends require('../../plugin') {
6
6
 
7
7
  static help() {
8
- return 'add handler stubs for actions and functions (Java)'
8
+ return 'add handler stubs for actions and functions (Java)'
9
9
  }
10
10
 
11
11
  options() {
@@ -8,13 +8,13 @@
8
8
  "start": "ui5 serve"
9
9
  },
10
10
  "devDependencies": {
11
- {{#hasWorkzone}}"@sap/ui5-builder-webide-extension": "^1.1.9",{{/hasWorkzone}}
11
+ {{#hasWorkzoneStandard}}"@sap/ui5-builder-webide-extension": "^1.1.9",{{/hasWorkzoneStandard}}
12
12
  "@ui5/cli": "^4",
13
13
  "ui5-task-zipper": "^3"
14
14
  },
15
15
  "ui5": {
16
16
  "dependencies": [
17
- {{#hasWorkzone}}"@sap/ui5-builder-webide-extension",{{/hasWorkzone}}
17
+ {{#hasWorkzoneStandard}}"@sap/ui5-builder-webide-extension",{{/hasWorkzoneStandard}}
18
18
  "ui5-task-zipper"
19
19
  ]
20
20
  }
@@ -13,13 +13,13 @@ builder:
13
13
  - "/test/**"
14
14
  - "/localService/**"
15
15
  customTasks:
16
- {{#hasWorkzone}}
16
+ {{#hasWorkzoneStandard}}
17
17
  - name: webide-extension-task-updateManifestJson
18
18
  afterTask: replaceVersion
19
19
  configuration:
20
20
  appFolder: webapp
21
21
  destDir: dist
22
- {{/hasWorkzone}}
22
+ {{/hasWorkzoneStandard}}
23
23
  - name: ui5-task-zipper
24
24
  afterTask: generateVersionInfo
25
25
  configuration:
@@ -22,7 +22,7 @@ module.exports = class LocalMessagingTemplate extends require('../../plugin') {
22
22
  async run() {
23
23
  const project = readProject()
24
24
  const { configFile } = project
25
- project.shortcut = !(await read(configFile)).cds?.requires?.messaging?.kind
25
+ project.shortcut = typeof (await read(configFile)).cds?.requires?.messaging !== 'object'
26
26
  await merge(__dirname, 'files/package.json.hbs').into(configFile, { with: project })
27
27
  }
28
28
  }
@@ -1,8 +1,4 @@
1
1
  {
2
- // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3
- // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4
-
5
- // List of extensions which should be recommended for users of this workspace.
6
2
  "recommendations": [
7
3
  "SAPSE.vscode-cds",
8
4
  "dbaeumer.vscode-eslint",
@@ -11,7 +7,6 @@
11
7
  "qwtel.sqlite-viewer",
12
8
  "humao.rest-client"
13
9
  ],
14
- // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
15
10
  "unwantedRecommendations": [
16
11
 
17
12
  ]
@@ -8,4 +8,4 @@
8
8
  // "tab",
9
9
  // "tsv"
10
10
  ]
11
- }
11
+ }
@@ -1,6 +1,4 @@
1
1
  {
2
- // See https://go.microsoft.com/fwlink/?LinkId=733558
3
- // for the documentation about the tasks.json format
4
2
  "version": "2.0.0",
5
3
  "tasks": [
6
4
  {
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "devDependencies": {
13
13
  "@cap-js/sqlite": "^1",
14
- "@cap-js/cds-types": "^0.6"
14
+ "@cap-js/cds-types": "^0.7.0"
15
15
  },
16
16
  "scripts": {
17
17
  "start": "cds-serve"
@@ -24,7 +24,7 @@ module.exports = class PostgresTemplate extends require('../../plugin') {
24
24
  async run() {
25
25
  const project = readProject()
26
26
  const { configFile, isJava } = project
27
- project.shortcut = !(await read(configFile)).cds?.requires?.db?.kind
27
+ project.shortcut = typeof (await read(configFile)).cds?.requires?.db !== 'object'
28
28
  await merge(__dirname, 'files/package.json.hbs').into('package.json', { project })
29
29
  if (isJava) await mvn.add('postgresql')
30
30
  }
@@ -28,7 +28,7 @@ module.exports = class RedisMessagingTemplate extends require('../../plugin') {
28
28
  async run() {
29
29
  const project = readProject()
30
30
  const { configFile } = project
31
- project.shortcut = !(await read(configFile)).cds?.requires?.messaging?.kind
31
+ project.shortcut = typeof (await read(configFile)).cds?.requires?.messaging !== 'object'
32
32
  await merge(__dirname, 'files/package.json.hbs').into(configFile, { project })
33
33
  }
34
34
  }
@@ -0,0 +1,40 @@
1
+ ---
2
+ modules:
3
+ - name: {{appName}}-srv
4
+ type: {{language}}
5
+ path: {{& srvPath}}
6
+ provides:
7
+ - name: srv-api # required by consumers of CAP services (e.g. approuter)
8
+ properties:
9
+ srv-url: ${default-url}
10
+
11
+ - name: {{appName}}-destinations
12
+ type: com.sap.application.content
13
+ requires:
14
+ - name: {{appName}}-auth
15
+ parameters:
16
+ service-key:
17
+ name: {{appName}}-auth-key
18
+ - name: srv-api
19
+ - name: {{appName}}-destination
20
+ parameters:
21
+ content-target: true
22
+ build-parameters:
23
+ no-source: true
24
+ parameters:
25
+ content:
26
+ subaccount:
27
+ existing_destinations_policy: update
28
+ destinations:
29
+ - Name: {{appName}}-side-by-side-extensibility
30
+ URL: ~{srv-api/srv-url}
31
+ Authentication: OAuth2ClientCredentials
32
+ TokenServiceInstanceName: {{appName}}-auth
33
+ TokenServiceKeyName: {{appName}}-auth-key
34
+
35
+ resources:
36
+ - name: {{appName}}-destination
37
+ type: org.cloudfoundry.managed-service
38
+ parameters:
39
+ service: destination
40
+ service-plan: lite
@@ -0,0 +1,17 @@
1
+ {
2
+ {{#isNodejs}}
3
+ "cds": {
4
+ {{/isNodejs}}
5
+ "requires": {
6
+ {{#profile}}
7
+ "[{{profile}}]": {
8
+ {{/profile}}
9
+ "side-by-side-extensibility": true
10
+ {{#profile}}
11
+ }
12
+ {{/profile}}
13
+ }
14
+ {{#isNodejs}}
15
+ }
16
+ {{/isNodejs}}
17
+ }
@@ -0,0 +1,34 @@
1
+ const { readProject } = require('../../projectReader')
2
+ const { merge } = require('../../merge')
3
+ const { destinations, destinationSideBySideExtensibility } = require('../../registries/mta')
4
+
5
+ module.exports = class extends require('../../plugin') {
6
+
7
+ requires() {
8
+ return ['destination']
9
+ }
10
+
11
+ static help() {
12
+ return 'logic extensibility via extension points'
13
+ }
14
+
15
+ static hasInProduction(env) {
16
+ return !!env.requires['side-by-side-extensibility']
17
+ }
18
+
19
+ canRun() {
20
+ const { isNodejs } = readProject()
21
+ if (isNodejs) throw 'Side-by-side extensibility is not supported for Node.js yet.'
22
+ }
23
+
24
+ async run() {
25
+ const project = readProject()
26
+ const { configFile } = project
27
+ await merge(__dirname, 'files/package.json.hbs').into(configFile, { with: project })
28
+ }
29
+
30
+ async combine() {
31
+ const project = readProject()
32
+ await merge(__dirname, 'files/mta.yaml.hbs').into('mta.yaml', { with: project, additions: [destinations, destinationSideBySideExtensibility]})
33
+ }
34
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "devDependencies": {
3
- "@cap-js/cds-types": "^0.6",
4
- "@types/node": "^20",
3
+ "@cap-js/cds-types": "^0.7.0",
4
+ "@types/node": "^22.0.0",
5
5
  "typescript": "^5"
6
6
  },
7
7
  "scripts": {
@@ -17,7 +17,7 @@ module.exports = class XsuaaTemplate extends require('../../plugin') {
17
17
  async run() {
18
18
  const project = readProject()
19
19
  const { configFile } = project
20
- project.shortcut = !(await read(configFile)).cds?.requires?.auth?.kind
20
+ project.shortcut = typeof (await read(configFile)).cds?.requires?.auth !== 'object'
21
21
  await merge(__dirname, 'files/package.json.hbs').into(configFile, { project, forceOverwrite: true })
22
22
  }
23
23
 
package/lib/util/fs.js CHANGED
@@ -27,7 +27,7 @@ module.exports = new class FsUtil {
27
27
  }
28
28
 
29
29
  async writeYAML(dst, yaml) {
30
- const content = YAML.stringify(yaml, { collectionStyle: 'block', lineWidth: 150 })
30
+ const content = YAML.stringify(yaml, { collectionStyle: 'block', lineWidth: 150, directives: false })
31
31
  await write(content).to(dst)
32
32
  }
33
33
 
package/lib/util/jsonc.js CHANGED
@@ -1 +1 @@
1
- "use strict";function peg$subclass(t,r){function e(){this.constructor=t}e.prototype=r.prototype,t.prototype=new e}function peg$SyntaxError(t,r,e,n){this.message=t,this.expected=r,this.found=e,this.location=n,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,peg$SyntaxError)}function peg$parse(t,r){r=void 0!==r?r:{};var e,n={},a={JSON:it},c=it,u=nt("{",!1),o=function(t,r,e){t[r]=e},s=nt("}",!1),h=nt("[",!1),i=function(t,r){t.push(r)},l=nt("]",!1),f=/^[+\-]/,A=at(["+","-"],!1,!1),p=/^[0-9]/,g=at([["0","9"]],!1,!1),d=nt(".",!1),C=nt("e",!1),v=ct("string"),x='"',b=nt('"',!1),y="\\",m=nt("\\",!1),E=nt("/",!1),S=nt("n",!1),$=nt("r",!1),F=nt("t",!1),w=nt("b",!1),R=nt("f",!1),j=nt("u",!1),k=/^[0-9a-f]/,M=at([["0","9"],["a","f"]],!1,!1),N=function(t){return String.fromCharCode(parseInt(t,16))},T=/^[^"]/,I=at(['"'],!0,!1),J="null",O=nt("null",!1),U="true",q=nt("true",!1),z="false",B=nt("false",!1),D=nt(":",!1),G=nt(",",!1),H=/^[ \t\n\r]/,K=at([" ","\t","\n","\r"],!1,!1),L=nt("//",!1),P=/^[\n\r\u2028\u2029]/,Q=at(["\n","\r","\u2028","\u2029"],!1,!1),V={type:"any"},W=nt("/*",!1),X="*/",Y=nt("*/",!1),Z=0,_=[{line:1,column:1}],tt=0,rt=[],et=0;if("startRule"in r){if(!(r.startRule in a))throw new Error("Can't start parsing from rule \""+r.startRule+'".');c=a[r.startRule]}function nt(t,r){return{type:"literal",text:t,ignoreCase:r}}function at(t,r,e){return{type:"class",parts:t,inverted:r,ignoreCase:e}}function ct(t){return{type:"other",description:t}}function ut(r){var e,n=_[r];if(n)return n;for(e=r-1;!_[e];)e--;for(n={line:(n=_[e]).line,column:n.column};e<r;)10===t.charCodeAt(e)?(n.line++,n.column=1):n.column++,e++;return _[r]=n,n}function ot(t,r){var e=ut(t),n=ut(r);return{start:{offset:t,line:e.line,column:e.column},end:{offset:r,line:n.line,column:n.column}}}function st(t){Z<tt||(Z>tt&&(tt=Z,rt=[]),rt.push(t))}function ht(t,r,e){return new peg$SyntaxError(peg$SyntaxError.buildMessage(t,r),t,r,e)}function it(){var t,r;return t=Z,gt()!==n&&(r=lt())!==n&&gt()!==n?(t,t=r):(Z=t,t=n),t}function lt(){var r;return(r=function(){var r,e,a,c,h,i,l,f,A;r=Z,e=Z,(a=gt())!==n?(123===t.charCodeAt(Z)?(c="{",Z++):(c=n,0===et&&st(u)),c!==n&&(h=gt())!==n?(e,e=a={}):(Z=e,e=n)):(Z=e,e=n);if(e!==n){if(a=Z,c=Z,(h=ft())!==n&&(i=At())!==n&&(l=lt())!==n?(c,c=h=o(e,h,l)):(Z=c,c=n),c!==n){for(h=[],i=Z,(l=pt())!==n&&(f=ft())!==n&&At()!==n&&(A=lt())!==n?(i,i=l=o(e,f,A)):(Z=i,i=n);i!==n;)h.push(i),i=Z,(l=pt())!==n&&(f=ft())!==n&&At()!==n&&(A=lt())!==n?(i,i=l=o(e,f,A)):(Z=i,i=n);h!==n?((i=pt())===n&&(i=null),i!==n?a=c=[c,h,i]:(Z=a,a=n)):(Z=a,a=n)}else Z=a,a=n;a===n&&(a=null),a!==n&&(c=gt())!==n?(125===t.charCodeAt(Z)?(h="}",Z++):(h=n,0===et&&st(s)),h!==n&&(i=gt())!==n?(r,r=e=e):(Z=r,r=n)):(Z=r,r=n)}else Z=r,r=n;return r}())===n&&(r=function(){var r,e,a,c,u,o,s;r=Z,e=Z,(a=gt())!==n?(91===t.charCodeAt(Z)?(c="[",Z++):(c=n,0===et&&st(h)),c!==n&&(u=gt())!==n?(e,e=a=[]):(Z=e,e=n)):(Z=e,e=n);if(e!==n){if(a=Z,c=Z,(u=lt())!==n&&(c,u=i(e,u)),(c=u)!==n){for(u=[],o=Z,pt()!==n&&(s=lt())!==n?(o,o=i(e,s)):(Z=o,o=n);o!==n;)u.push(o),o=Z,pt()!==n&&(s=lt())!==n?(o,o=i(e,s)):(Z=o,o=n);u!==n?((o=pt())===n&&(o=null),o!==n?a=c=[c,u,o]:(Z=a,a=n)):(Z=a,a=n)}else Z=a,a=n;a===n&&(a=null),a!==n&&(c=gt())!==n?(93===t.charCodeAt(Z)?(u="]",Z++):(u=n,0===et&&st(l)),u!==n&&(o=gt())!==n?(r,r=e=e):(Z=r,r=n)):(Z=r,r=n)}else Z=r,r=n;return r}())===n&&(r=function(){var r,e;r=Z,t.substr(Z,4)===J?(e=J,Z+=4):(e=n,0===et&&st(O));e!==n&&(r,e=null);return r=e}())===n&&(r=function(){var r,e;r=Z,t.substr(Z,4)===U?(e=U,Z+=4):(e=n,0===et&&st(q));e!==n&&(r,e=!0);return r=e}())===n&&(r=function(){var r,e;r=Z,t.substr(Z,5)===z?(e=z,Z+=5):(e=n,0===et&&st(B));e!==n&&(r,e=!1);return r=e}())===n&&(r=function(){var r,e,a,c,u,o,s,h,i,l,v;r=Z,e=Z,a=Z,f.test(t.charAt(Z))?(c=t.charAt(Z),Z++):(c=n,0===et&&st(A));c===n&&(c=null);if(c!==n){if(u=[],p.test(t.charAt(Z))?(o=t.charAt(Z),Z++):(o=n,0===et&&st(g)),o!==n)for(;o!==n;)u.push(o),p.test(t.charAt(Z))?(o=t.charAt(Z),Z++):(o=n,0===et&&st(g));else u=n;if(u!==n){if(o=Z,46===t.charCodeAt(Z)?(s=".",Z++):(s=n,0===et&&st(d)),s!==n){if(h=[],p.test(t.charAt(Z))?(i=t.charAt(Z),Z++):(i=n,0===et&&st(g)),i!==n)for(;i!==n;)h.push(i),p.test(t.charAt(Z))?(i=t.charAt(Z),Z++):(i=n,0===et&&st(g));else h=n;h!==n?o=s=[s,h]:(Z=o,o=n)}else Z=o,o=n;if(o===n&&(o=null),o!==n){if(s=Z,101===t.charCodeAt(Z)?(h="e",Z++):(h=n,0===et&&st(C)),h!==n)if(f.test(t.charAt(Z))?(i=t.charAt(Z),Z++):(i=n,0===et&&st(A)),i===n&&(i=null),i!==n){if(l=[],p.test(t.charAt(Z))?(v=t.charAt(Z),Z++):(v=n,0===et&&st(g)),v!==n)for(;v!==n;)l.push(v),p.test(t.charAt(Z))?(v=t.charAt(Z),Z++):(v=n,0===et&&st(g));else l=n;l!==n?s=h=[h,i,l]:(Z=s,s=n)}else Z=s,s=n;else Z=s,s=n;s===n&&(s=null),s!==n?a=c=[c,u,o,s]:(Z=a,a=n)}else Z=a,a=n}else Z=a,a=n}else Z=a,a=n;e=a!==n?t.substring(e,Z):a;e!==n&&(r,e=Number(e));return r=e}())===n&&(r=ft()),r}function ft(){var r,e,a,c,u,o,s,h,i,l,f,A,p;if(et++,r=Z,34===t.charCodeAt(Z)?(e=x,Z++):(e=n,0===et&&st(b)),e!==n){for(a=[],c=Z,92===t.charCodeAt(Z)?(u=y,Z++):(u=n,0===et&&st(m)),u!==n?(34===t.charCodeAt(Z)?(o=x,Z++):(o=n,0===et&&st(b)),o===n&&(92===t.charCodeAt(Z)?(o=y,Z++):(o=n,0===et&&st(m)),o===n&&(47===t.charCodeAt(Z)?(o="/",Z++):(o=n,0===et&&st(E)),o===n&&(o=Z,110===t.charCodeAt(Z)?(s="n",Z++):(s=n,0===et&&st(S)),s!==n&&(o,s="\n"),(o=s)===n&&(o=Z,114===t.charCodeAt(Z)?(s="r",Z++):(s=n,0===et&&st($)),s!==n&&(o,s="\r"),(o=s)===n&&(o=Z,116===t.charCodeAt(Z)?(s="t",Z++):(s=n,0===et&&st(F)),s!==n&&(o,s="\t"),(o=s)===n&&(o=Z,98===t.charCodeAt(Z)?(s="b",Z++):(s=n,0===et&&st(w)),s!==n&&(o,s="\b"),(o=s)===n&&(o=Z,102===t.charCodeAt(Z)?(s="f",Z++):(s=n,0===et&&st(R)),s!==n&&(o,s="\f"),(o=s)===n&&(o=Z,117===t.charCodeAt(Z)?(s="u",Z++):(s=n,0===et&&st(j)),s!==n?(h=Z,i=Z,k.test(t.charAt(Z))?(l=t.charAt(Z),Z++):(l=n,0===et&&st(M)),l!==n?(k.test(t.charAt(Z))?(f=t.charAt(Z),Z++):(f=n,0===et&&st(M)),f!==n?(k.test(t.charAt(Z))?(A=t.charAt(Z),Z++):(A=n,0===et&&st(M)),A!==n?(k.test(t.charAt(Z))?(p=t.charAt(Z),Z++):(p=n,0===et&&st(M)),p!==n?i=l=[l,f,A,p]:(Z=i,i=n)):(Z=i,i=n)):(Z=i,i=n)):(Z=i,i=n),(h=i!==n?t.substring(h,Z):i)!==n?(o,o=s=N(h)):(Z=o,o=n)):(Z=o,o=n))))))))),o!==n?(c,c=u=o):(Z=c,c=n)):(Z=c,c=n),c===n&&(T.test(t.charAt(Z))?(c=t.charAt(Z),Z++):(c=n,0===et&&st(I)));c!==n;)a.push(c),c=Z,92===t.charCodeAt(Z)?(u=y,Z++):(u=n,0===et&&st(m)),u!==n?(34===t.charCodeAt(Z)?(o=x,Z++):(o=n,0===et&&st(b)),o===n&&(92===t.charCodeAt(Z)?(o=y,Z++):(o=n,0===et&&st(m)),o===n&&(47===t.charCodeAt(Z)?(o="/",Z++):(o=n,0===et&&st(E)),o===n&&(o=Z,110===t.charCodeAt(Z)?(s="n",Z++):(s=n,0===et&&st(S)),s!==n&&(o,s="\n"),(o=s)===n&&(o=Z,114===t.charCodeAt(Z)?(s="r",Z++):(s=n,0===et&&st($)),s!==n&&(o,s="\r"),(o=s)===n&&(o=Z,116===t.charCodeAt(Z)?(s="t",Z++):(s=n,0===et&&st(F)),s!==n&&(o,s="\t"),(o=s)===n&&(o=Z,98===t.charCodeAt(Z)?(s="b",Z++):(s=n,0===et&&st(w)),s!==n&&(o,s="\b"),(o=s)===n&&(o=Z,102===t.charCodeAt(Z)?(s="f",Z++):(s=n,0===et&&st(R)),s!==n&&(o,s="\f"),(o=s)===n&&(o=Z,117===t.charCodeAt(Z)?(s="u",Z++):(s=n,0===et&&st(j)),s!==n?(h=Z,i=Z,k.test(t.charAt(Z))?(l=t.charAt(Z),Z++):(l=n,0===et&&st(M)),l!==n?(k.test(t.charAt(Z))?(f=t.charAt(Z),Z++):(f=n,0===et&&st(M)),f!==n?(k.test(t.charAt(Z))?(A=t.charAt(Z),Z++):(A=n,0===et&&st(M)),A!==n?(k.test(t.charAt(Z))?(p=t.charAt(Z),Z++):(p=n,0===et&&st(M)),p!==n?i=l=[l,f,A,p]:(Z=i,i=n)):(Z=i,i=n)):(Z=i,i=n)):(Z=i,i=n),(h=i!==n?t.substring(h,Z):i)!==n?(o,o=s=N(h)):(Z=o,o=n)):(Z=o,o=n))))))))),o!==n?(c,c=u=o):(Z=c,c=n)):(Z=c,c=n),c===n&&(T.test(t.charAt(Z))?(c=t.charAt(Z),Z++):(c=n,0===et&&st(I)));a!==n?(34===t.charCodeAt(Z)?(c=x,Z++):(c=n,0===et&&st(b)),c!==n?(r,r=e=a.join("")):(Z=r,r=n)):(Z=r,r=n)}else Z=r,r=n;return et--,r===n&&(e=n,0===et&&st(v)),r}function At(){var r,e;return r=Z,gt()!==n?(58===t.charCodeAt(Z)?(e=":",Z++):(e=n,0===et&&st(D)),e!==n&&gt()!==n?(r,r=void 0):(Z=r,r=n)):(Z=r,r=n),r}function pt(){var r,e;return r=Z,gt()!==n?(44===t.charCodeAt(Z)?(e=",",Z++):(e=n,0===et&&st(G)),e!==n&&gt()!==n?(r,r=void 0):(Z=r,r=n)):(Z=r,r=n),r}function gt(){var r,e,a;for(r=Z,e=[],H.test(t.charAt(Z))?(a=t.charAt(Z),Z++):(a=n,0===et&&st(K)),a===n&&(a=dt())===n&&(a=Ct());a!==n;)e.push(a),H.test(t.charAt(Z))?(a=t.charAt(Z),Z++):(a=n,0===et&&st(K)),a===n&&(a=dt())===n&&(a=Ct());return e!==n&&(r,e=void 0),r=e}function dt(){var r,e,a,c,u,o,s;if(r=Z,e=Z,"//"===t.substr(Z,2)?(a="//",Z+=2):(a=n,0===et&&st(L)),a!==n){for(c=[],u=Z,o=Z,et++,P.test(t.charAt(Z))?(s=t.charAt(Z),Z++):(s=n,0===et&&st(Q)),et--,s===n?o=void 0:(Z=o,o=n),o!==n?(t.length>Z?(s=t.charAt(Z),Z++):(s=n,0===et&&st(V)),s!==n?u=o=[o,s]:(Z=u,u=n)):(Z=u,u=n);u!==n;)c.push(u),u=Z,o=Z,et++,P.test(t.charAt(Z))?(s=t.charAt(Z),Z++):(s=n,0===et&&st(Q)),et--,s===n?o=void 0:(Z=o,o=n),o!==n?(t.length>Z?(s=t.charAt(Z),Z++):(s=n,0===et&&st(V)),s!==n?u=o=[o,s]:(Z=u,u=n)):(Z=u,u=n);c!==n?e=a=[a,c]:(Z=e,e=n)}else Z=e,e=n;return r=e!==n?t.substring(r,Z):e}function Ct(){var r,e,a,c,u,o,s;if(r=Z,e=Z,"/*"===t.substr(Z,2)?(a="/*",Z+=2):(a=n,0===et&&st(W)),a!==n){for(c=[],u=Z,o=Z,et++,t.substr(Z,2)===X?(s=X,Z+=2):(s=n,0===et&&st(Y)),et--,s===n?o=void 0:(Z=o,o=n),o!==n?(t.length>Z?(s=t.charAt(Z),Z++):(s=n,0===et&&st(V)),s!==n?u=o=[o,s]:(Z=u,u=n)):(Z=u,u=n);u!==n;)c.push(u),u=Z,o=Z,et++,t.substr(Z,2)===X?(s=X,Z+=2):(s=n,0===et&&st(Y)),et--,s===n?o=void 0:(Z=o,o=n),o!==n?(t.length>Z?(s=t.charAt(Z),Z++):(s=n,0===et&&st(V)),s!==n?u=o=[o,s]:(Z=u,u=n)):(Z=u,u=n);c!==n?(t.substr(Z,2)===X?(u=X,Z+=2):(u=n,0===et&&st(Y)),u!==n?e=a=[a,c,u]:(Z=e,e=n)):(Z=e,e=n)}else Z=e,e=n;return r=e!==n?t.substring(r,Z):e}if((e=c())!==n&&Z===t.length)return e;throw e!==n&&Z<t.length&&st({type:"end"}),ht(rt,tt<t.length?t.charAt(tt):null,tt<t.length?ot(tt,tt+1):ot(tt,tt))}peg$subclass(peg$SyntaxError,Error),peg$SyntaxError.buildMessage=function(t,r){var e={literal:function(t){return'"'+a(t.text)+'"'},class:function(t){var r,e="";for(r=0;r<t.parts.length;r++)e+=t.parts[r]instanceof Array?c(t.parts[r][0])+"-"+c(t.parts[r][1]):c(t.parts[r]);return"["+(t.inverted?"^":"")+e+"]"},any:function(t){return"any character"},end:function(t){return"end of input"},other:function(t){return t.description}};function n(t){return t.charCodeAt(0).toString(16).toUpperCase()}function a(t){return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(t){return"\\x0"+n(t)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(t){return"\\x"+n(t)}))}function c(t){return t.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(t){return"\\x0"+n(t)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(t){return"\\x"+n(t)}))}return"Expected "+function(t){var r,n,a,c=new Array(t.length);for(r=0;r<t.length;r++)c[r]=(a=t[r],e[a.type](a));if(c.sort(),c.length>0){for(r=1,n=1;r<c.length;r++)c[r-1]!==c[r]&&(c[n]=c[r],n++);c.length=n}switch(c.length){case 1:return c[0];case 2:return c[0]+" or "+c[1];default:return c.slice(0,-1).join(", ")+", or "+c[c.length-1]}}(t)+" but "+function(t){return t?'"'+a(t)+'"':"end of input"}(r)+" found."},module.exports={SyntaxError:peg$SyntaxError,parse:peg$parse};
1
+ "use strict";function peg$subclass(t,r){function e(){this.constructor=t}e.prototype=r.prototype,t.prototype=new e}function peg$SyntaxError(t,r,e,n){this.message=t,this.expected=r,this.found=e,this.location=n,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,peg$SyntaxError)}function peg$parse(t,r){r=void 0!==r?r:{};var e,n={},c={JSON:Lt},u=Lt,a=function(t){return t},o="{",s=qt("{",!1),i=function(){return{}},h=function(t,r,e){t[r]=e},f="}",l=qt("}",!1),A=function(t){return t},p="[",g=qt("[",!1),d=function(){return[]},C=function(t,r){t.push(r)},x="]",v=qt("]",!1),y=function(t){return t},b=/^[+\-]/,E=zt(["+","-"],!1,!1),m=/^[0-9]/,S=zt([["0","9"]],!1,!1),$=".",F=qt(".",!1),w=/^[eE]/,R=zt(["e","E"],!1,!1),j=function(t){return Number(t)},k=Bt("string"),M='"',N=qt('"',!1),T="\\",I=qt("\\",!1),J="/",O=qt("/",!1),U="n",q=qt("n",!1),z=function(){return"\n"},B="r",D=qt("r",!1),G=function(){return"\r"},H="t",K=qt("t",!1),L=function(){return"\t"},P="b",Q=qt("b",!1),V=function(){return"\b"},W="f",X=qt("f",!1),Y=function(){return"\f"},Z="u",_=qt("u",!1),tt=/^[0-9a-fA-F]/,rt=zt([["0","9"],["a","f"],["A","F"]],!1,!1),et=function(t){return String.fromCharCode(parseInt(t,16))},nt=function(t){return t},ct=/^[^"]/,ut=zt(['"'],!0,!1),at=function(t){return t.join("")},ot="null",st=qt("null",!1),it=function(){return null},ht="true",ft=qt("true",!1),lt=function(){return!0},At="false",pt=qt("false",!1),gt=function(){return!1},dt=":",Ct=qt(":",!1),xt=function(){},vt=",",yt=qt(",",!1),bt=/^[ \t\n\r]/,Et=zt([" ","\t","\n","\r"],!1,!1),mt=function(){},St="//",$t=qt("//",!1),Ft=/^[\n\r\u2028\u2029]/,wt=zt(["\n","\r","\u2028","\u2029"],!1,!1),Rt={type:"any"},jt="/*",kt=qt("/*",!1),Mt="*/",Nt=qt("*/",!1),Tt=0,It=[{line:1,column:1}],Jt=0,Ot=[],Ut=0;if("startRule"in r){if(!(r.startRule in c))throw new Error("Can't start parsing from rule \""+r.startRule+'".');u=c[r.startRule]}function qt(t,r){return{type:"literal",text:t,ignoreCase:r}}function zt(t,r,e){return{type:"class",parts:t,inverted:r,ignoreCase:e}}function Bt(t){return{type:"other",description:t}}function Dt(r){var e,n=It[r];if(n)return n;for(e=r-1;!It[e];)e--;for(n={line:(n=It[e]).line,column:n.column};e<r;)10===t.charCodeAt(e)?(n.line++,n.column=1):n.column++,e++;return It[r]=n,n}function Gt(t,r){var e=Dt(t),n=Dt(r);return{start:{offset:t,line:e.line,column:e.column},end:{offset:r,line:n.line,column:n.column}}}function Ht(t){Tt<Jt||(Tt>Jt&&(Jt=Tt,Ot=[]),Ot.push(t))}function Kt(t,r,e){return new peg$SyntaxError(peg$SyntaxError.buildMessage(t,r),t,r,e)}function Lt(){var t,r;return t=Tt,Xt()!==n&&(r=Pt())!==n&&Xt()!==n?t=a(r):(Tt=t,t=n),t}function Pt(){var r;return(r=function(){var r,e,c,u,a,p,g,d,C;r=Tt,e=Tt,(c=Xt())!==n?(123===t.charCodeAt(Tt)?(u=o,Tt++):(u=n,0===Ut&&Ht(s)),u!==n&&(a=Xt())!==n?e=c=i():(Tt=e,e=n)):(Tt=e,e=n);if(e!==n){if(c=Tt,u=Tt,(a=Qt())!==n&&(p=Vt())!==n&&(g=Pt())!==n?u=a=h(e,a,g):(Tt=u,u=n),u!==n){for(a=[],p=Tt,(g=Wt())!==n&&(d=Qt())!==n&&Vt()!==n&&(C=Pt())!==n?p=g=h(e,d,C):(Tt=p,p=n);p!==n;)a.push(p),p=Tt,(g=Wt())!==n&&(d=Qt())!==n&&Vt()!==n&&(C=Pt())!==n?p=g=h(e,d,C):(Tt=p,p=n);a!==n?((p=Wt())===n&&(p=null),p!==n?c=u=[u,a,p]:(Tt=c,c=n)):(Tt=c,c=n)}else Tt=c,c=n;c===n&&(c=null),c!==n&&(u=Xt())!==n?(125===t.charCodeAt(Tt)?(a=f,Tt++):(a=n,0===Ut&&Ht(l)),a!==n&&(p=Xt())!==n?r=e=A(e):(Tt=r,r=n)):(Tt=r,r=n)}else Tt=r,r=n;return r}())===n&&(r=function(){var r,e,c,u,a,o,s;r=Tt,e=Tt,(c=Xt())!==n?(91===t.charCodeAt(Tt)?(u=p,Tt++):(u=n,0===Ut&&Ht(g)),u!==n&&(a=Xt())!==n?e=c=d():(Tt=e,e=n)):(Tt=e,e=n);if(e!==n){if(c=Tt,u=Tt,(a=Pt())!==n&&(a=C(e,a)),(u=a)!==n){for(a=[],o=Tt,Wt()!==n&&(s=Pt())!==n?o=C(e,s):(Tt=o,o=n);o!==n;)a.push(o),o=Tt,Wt()!==n&&(s=Pt())!==n?o=C(e,s):(Tt=o,o=n);a!==n?((o=Wt())===n&&(o=null),o!==n?c=u=[u,a,o]:(Tt=c,c=n)):(Tt=c,c=n)}else Tt=c,c=n;c===n&&(c=null),c!==n&&(u=Xt())!==n?(93===t.charCodeAt(Tt)?(a=x,Tt++):(a=n,0===Ut&&Ht(v)),a!==n&&(o=Xt())!==n?r=e=y(e):(Tt=r,r=n)):(Tt=r,r=n)}else Tt=r,r=n;return r}())===n&&(r=function(){var r,e;r=Tt,t.substr(Tt,4)===ot?(e=ot,Tt+=4):(e=n,0===Ut&&Ht(st));e!==n&&(e=it());return r=e,r}())===n&&(r=function(){var r,e;r=Tt,t.substr(Tt,4)===ht?(e=ht,Tt+=4):(e=n,0===Ut&&Ht(ft));e!==n&&(e=lt());return r=e,r}())===n&&(r=function(){var r,e;r=Tt,t.substr(Tt,5)===At?(e=At,Tt+=5):(e=n,0===Ut&&Ht(pt));e!==n&&(e=gt());return r=e,r}())===n&&(r=function(){var r,e,c,u,a,o,s,i,h,f,l;r=Tt,e=Tt,c=Tt,b.test(t.charAt(Tt))?(u=t.charAt(Tt),Tt++):(u=n,0===Ut&&Ht(E));u===n&&(u=null);if(u!==n){if(a=[],m.test(t.charAt(Tt))?(o=t.charAt(Tt),Tt++):(o=n,0===Ut&&Ht(S)),o!==n)for(;o!==n;)a.push(o),m.test(t.charAt(Tt))?(o=t.charAt(Tt),Tt++):(o=n,0===Ut&&Ht(S));else a=n;if(a!==n){if(o=Tt,46===t.charCodeAt(Tt)?(s=$,Tt++):(s=n,0===Ut&&Ht(F)),s!==n){if(i=[],m.test(t.charAt(Tt))?(h=t.charAt(Tt),Tt++):(h=n,0===Ut&&Ht(S)),h!==n)for(;h!==n;)i.push(h),m.test(t.charAt(Tt))?(h=t.charAt(Tt),Tt++):(h=n,0===Ut&&Ht(S));else i=n;i!==n?o=s=[s,i]:(Tt=o,o=n)}else Tt=o,o=n;if(o===n&&(o=null),o!==n){if(s=Tt,w.test(t.charAt(Tt))?(i=t.charAt(Tt),Tt++):(i=n,0===Ut&&Ht(R)),i!==n)if(b.test(t.charAt(Tt))?(h=t.charAt(Tt),Tt++):(h=n,0===Ut&&Ht(E)),h===n&&(h=null),h!==n){if(f=[],m.test(t.charAt(Tt))?(l=t.charAt(Tt),Tt++):(l=n,0===Ut&&Ht(S)),l!==n)for(;l!==n;)f.push(l),m.test(t.charAt(Tt))?(l=t.charAt(Tt),Tt++):(l=n,0===Ut&&Ht(S));else f=n;f!==n?s=i=[i,h,f]:(Tt=s,s=n)}else Tt=s,s=n;else Tt=s,s=n;s===n&&(s=null),s!==n?c=u=[u,a,o,s]:(Tt=c,c=n)}else Tt=c,c=n}else Tt=c,c=n}else Tt=c,c=n;e=c!==n?t.substring(e,Tt):c;e!==n&&(e=j(e));return r=e,r}())===n&&(r=Qt()),r}function Qt(){var r,e,c,u,a,o,s,i,h,f,l,A,p;if(Ut++,r=Tt,34===t.charCodeAt(Tt)?(e=M,Tt++):(e=n,0===Ut&&Ht(N)),e!==n){for(c=[],u=Tt,92===t.charCodeAt(Tt)?(a=T,Tt++):(a=n,0===Ut&&Ht(I)),a!==n?(34===t.charCodeAt(Tt)?(o=M,Tt++):(o=n,0===Ut&&Ht(N)),o===n&&(92===t.charCodeAt(Tt)?(o=T,Tt++):(o=n,0===Ut&&Ht(I)),o===n&&(47===t.charCodeAt(Tt)?(o=J,Tt++):(o=n,0===Ut&&Ht(O)),o===n&&(o=Tt,110===t.charCodeAt(Tt)?(s=U,Tt++):(s=n,0===Ut&&Ht(q)),s!==n&&(s=z()),(o=s)===n&&(o=Tt,114===t.charCodeAt(Tt)?(s=B,Tt++):(s=n,0===Ut&&Ht(D)),s!==n&&(s=G()),(o=s)===n&&(o=Tt,116===t.charCodeAt(Tt)?(s=H,Tt++):(s=n,0===Ut&&Ht(K)),s!==n&&(s=L()),(o=s)===n&&(o=Tt,98===t.charCodeAt(Tt)?(s=P,Tt++):(s=n,0===Ut&&Ht(Q)),s!==n&&(s=V()),(o=s)===n&&(o=Tt,102===t.charCodeAt(Tt)?(s=W,Tt++):(s=n,0===Ut&&Ht(X)),s!==n&&(s=Y()),(o=s)===n&&(o=Tt,117===t.charCodeAt(Tt)?(s=Z,Tt++):(s=n,0===Ut&&Ht(_)),s!==n?(i=Tt,h=Tt,tt.test(t.charAt(Tt))?(f=t.charAt(Tt),Tt++):(f=n,0===Ut&&Ht(rt)),f!==n?(tt.test(t.charAt(Tt))?(l=t.charAt(Tt),Tt++):(l=n,0===Ut&&Ht(rt)),l!==n?(tt.test(t.charAt(Tt))?(A=t.charAt(Tt),Tt++):(A=n,0===Ut&&Ht(rt)),A!==n?(tt.test(t.charAt(Tt))?(p=t.charAt(Tt),Tt++):(p=n,0===Ut&&Ht(rt)),p!==n?h=f=[f,l,A,p]:(Tt=h,h=n)):(Tt=h,h=n)):(Tt=h,h=n)):(Tt=h,h=n),(i=h!==n?t.substring(i,Tt):h)!==n?o=s=et(i):(Tt=o,o=n)):(Tt=o,o=n))))))))),o!==n?u=a=nt(o):(Tt=u,u=n)):(Tt=u,u=n),u===n&&(ct.test(t.charAt(Tt))?(u=t.charAt(Tt),Tt++):(u=n,0===Ut&&Ht(ut)));u!==n;)c.push(u),u=Tt,92===t.charCodeAt(Tt)?(a=T,Tt++):(a=n,0===Ut&&Ht(I)),a!==n?(34===t.charCodeAt(Tt)?(o=M,Tt++):(o=n,0===Ut&&Ht(N)),o===n&&(92===t.charCodeAt(Tt)?(o=T,Tt++):(o=n,0===Ut&&Ht(I)),o===n&&(47===t.charCodeAt(Tt)?(o=J,Tt++):(o=n,0===Ut&&Ht(O)),o===n&&(o=Tt,110===t.charCodeAt(Tt)?(s=U,Tt++):(s=n,0===Ut&&Ht(q)),s!==n&&(s=z()),(o=s)===n&&(o=Tt,114===t.charCodeAt(Tt)?(s=B,Tt++):(s=n,0===Ut&&Ht(D)),s!==n&&(s=G()),(o=s)===n&&(o=Tt,116===t.charCodeAt(Tt)?(s=H,Tt++):(s=n,0===Ut&&Ht(K)),s!==n&&(s=L()),(o=s)===n&&(o=Tt,98===t.charCodeAt(Tt)?(s=P,Tt++):(s=n,0===Ut&&Ht(Q)),s!==n&&(s=V()),(o=s)===n&&(o=Tt,102===t.charCodeAt(Tt)?(s=W,Tt++):(s=n,0===Ut&&Ht(X)),s!==n&&(s=Y()),(o=s)===n&&(o=Tt,117===t.charCodeAt(Tt)?(s=Z,Tt++):(s=n,0===Ut&&Ht(_)),s!==n?(i=Tt,h=Tt,tt.test(t.charAt(Tt))?(f=t.charAt(Tt),Tt++):(f=n,0===Ut&&Ht(rt)),f!==n?(tt.test(t.charAt(Tt))?(l=t.charAt(Tt),Tt++):(l=n,0===Ut&&Ht(rt)),l!==n?(tt.test(t.charAt(Tt))?(A=t.charAt(Tt),Tt++):(A=n,0===Ut&&Ht(rt)),A!==n?(tt.test(t.charAt(Tt))?(p=t.charAt(Tt),Tt++):(p=n,0===Ut&&Ht(rt)),p!==n?h=f=[f,l,A,p]:(Tt=h,h=n)):(Tt=h,h=n)):(Tt=h,h=n)):(Tt=h,h=n),(i=h!==n?t.substring(i,Tt):h)!==n?o=s=et(i):(Tt=o,o=n)):(Tt=o,o=n))))))))),o!==n?u=a=nt(o):(Tt=u,u=n)):(Tt=u,u=n),u===n&&(ct.test(t.charAt(Tt))?(u=t.charAt(Tt),Tt++):(u=n,0===Ut&&Ht(ut)));c!==n?(34===t.charCodeAt(Tt)?(u=M,Tt++):(u=n,0===Ut&&Ht(N)),u!==n?r=e=at(c):(Tt=r,r=n)):(Tt=r,r=n)}else Tt=r,r=n;return Ut--,r===n&&(e=n,0===Ut&&Ht(k)),r}function Vt(){var r,e;return r=Tt,Xt()!==n?(58===t.charCodeAt(Tt)?(e=dt,Tt++):(e=n,0===Ut&&Ht(Ct)),e!==n&&Xt()!==n?r=xt():(Tt=r,r=n)):(Tt=r,r=n),r}function Wt(){var r,e;return r=Tt,Xt()!==n?(44===t.charCodeAt(Tt)?(e=vt,Tt++):(e=n,0===Ut&&Ht(yt)),e!==n&&Xt()!==n?r=xt():(Tt=r,r=n)):(Tt=r,r=n),r}function Xt(){var r,e,c;for(r=Tt,e=[],bt.test(t.charAt(Tt))?(c=t.charAt(Tt),Tt++):(c=n,0===Ut&&Ht(Et)),c===n&&(c=Yt())===n&&(c=Zt());c!==n;)e.push(c),bt.test(t.charAt(Tt))?(c=t.charAt(Tt),Tt++):(c=n,0===Ut&&Ht(Et)),c===n&&(c=Yt())===n&&(c=Zt());return e!==n&&(e=mt()),r=e}function Yt(){var r,e,c,u,a,o,s;if(r=Tt,e=Tt,t.substr(Tt,2)===St?(c=St,Tt+=2):(c=n,0===Ut&&Ht($t)),c!==n){for(u=[],a=Tt,o=Tt,Ut++,Ft.test(t.charAt(Tt))?(s=t.charAt(Tt),Tt++):(s=n,0===Ut&&Ht(wt)),Ut--,s===n?o=void 0:(Tt=o,o=n),o!==n?(t.length>Tt?(s=t.charAt(Tt),Tt++):(s=n,0===Ut&&Ht(Rt)),s!==n?a=o=[o,s]:(Tt=a,a=n)):(Tt=a,a=n);a!==n;)u.push(a),a=Tt,o=Tt,Ut++,Ft.test(t.charAt(Tt))?(s=t.charAt(Tt),Tt++):(s=n,0===Ut&&Ht(wt)),Ut--,s===n?o=void 0:(Tt=o,o=n),o!==n?(t.length>Tt?(s=t.charAt(Tt),Tt++):(s=n,0===Ut&&Ht(Rt)),s!==n?a=o=[o,s]:(Tt=a,a=n)):(Tt=a,a=n);u!==n?e=c=[c,u]:(Tt=e,e=n)}else Tt=e,e=n;return r=e!==n?t.substring(r,Tt):e}function Zt(){var r,e,c,u,a,o,s;if(r=Tt,e=Tt,t.substr(Tt,2)===jt?(c=jt,Tt+=2):(c=n,0===Ut&&Ht(kt)),c!==n){for(u=[],a=Tt,o=Tt,Ut++,t.substr(Tt,2)===Mt?(s=Mt,Tt+=2):(s=n,0===Ut&&Ht(Nt)),Ut--,s===n?o=void 0:(Tt=o,o=n),o!==n?(t.length>Tt?(s=t.charAt(Tt),Tt++):(s=n,0===Ut&&Ht(Rt)),s!==n?a=o=[o,s]:(Tt=a,a=n)):(Tt=a,a=n);a!==n;)u.push(a),a=Tt,o=Tt,Ut++,t.substr(Tt,2)===Mt?(s=Mt,Tt+=2):(s=n,0===Ut&&Ht(Nt)),Ut--,s===n?o=void 0:(Tt=o,o=n),o!==n?(t.length>Tt?(s=t.charAt(Tt),Tt++):(s=n,0===Ut&&Ht(Rt)),s!==n?a=o=[o,s]:(Tt=a,a=n)):(Tt=a,a=n);u!==n?(t.substr(Tt,2)===Mt?(a=Mt,Tt+=2):(a=n,0===Ut&&Ht(Nt)),a!==n?e=c=[c,u,a]:(Tt=e,e=n)):(Tt=e,e=n)}else Tt=e,e=n;return r=e!==n?t.substring(r,Tt):e}if((e=u())!==n&&Tt===t.length)return e;throw e!==n&&Tt<t.length&&Ht({type:"end"}),Kt(Ot,Jt<t.length?t.charAt(Jt):null,Jt<t.length?Gt(Jt,Jt+1):Gt(Jt,Jt))}peg$subclass(peg$SyntaxError,Error),peg$SyntaxError.buildMessage=function(t,r){var e={literal:function(t){return'"'+c(t.text)+'"'},class:function(t){var r,e="";for(r=0;r<t.parts.length;r++)e+=t.parts[r]instanceof Array?u(t.parts[r][0])+"-"+u(t.parts[r][1]):u(t.parts[r]);return"["+(t.inverted?"^":"")+e+"]"},any:function(t){return"any character"},end:function(t){return"end of input"},other:function(t){return t.description}};function n(t){return t.charCodeAt(0).toString(16).toUpperCase()}function c(t){return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(t){return"\\x0"+n(t)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(t){return"\\x"+n(t)}))}function u(t){return t.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(t){return"\\x0"+n(t)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(t){return"\\x"+n(t)}))}return"Expected "+function(t){var r,n,c,u=new Array(t.length);for(r=0;r<t.length;r++)u[r]=(c=t[r],e[c.type](c));if(u.sort(),u.length>0){for(r=1,n=1;r<u.length;r++)u[r-1]!==u[r]&&(u[n]=u[r],n++);u.length=n}switch(u.length){case 1:return u[0];case 2:return u[0]+" or "+u[1];default:return u.slice(0,-1).join(", ")+", or "+u[u.length-1]}}(t)+" but "+function(t){return t?'"'+c(t)+'"':"end of input"}(r)+" found."},module.exports={SyntaxError:peg$SyntaxError,parse:peg$parse};
@@ -1,3 +1,7 @@
1
+ // Generate via:
2
+ // npm i -g pegjs terser
3
+ // pegjs < ./lib/util/jsonc.pegjs | terser -cm > ./lib/util/jsonc.js
4
+
1
5
  JSON = _ v:value _ { return v }
2
6
  value = object / array / null / true / false / number / string
3
7
 
@@ -16,7 +20,7 @@ array
16
20
  { return a }
17
21
 
18
22
  number
19
- = x:$( [+-]? [0-9]+ ("." [0-9]+)? ("e" [+-]? [0-9]+)? )
23
+ = x:$( [+-]? [0-9]+ ("." [0-9]+)? ([eE] [+-]? [0-9]+)? )
20
24
  { return Number(x) }
21
25
 
22
26
  string "string"
@@ -27,7 +31,7 @@ string "string"
27
31
  / "t" { return "\t" }
28
32
  / "b" { return "\b" }
29
33
  / "f" { return "\f" }
30
- / "u" u:$([0-9a-f][0-9a-f][0-9a-f][0-9a-f]) {
34
+ / "u" u:$([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]) {
31
35
  return String.fromCharCode(parseInt(u,16))
32
36
  }
33
37
  ) {return x}) / [^"]