@cchistory/lite 0.4.4 → 0.5.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.
- package/INSTALL.md +1 -1
- package/apps/lite-cli/dist/agent-contract.d.ts +4 -5
- package/apps/lite-cli/dist/agent-contract.d.ts.map +1 -1
- package/apps/lite-cli/dist/agent-contract.js +35 -28
- package/apps/lite-cli/dist/agent-contract.js.map +1 -1
- package/apps/lite-cli/dist/bin.js +3 -3
- package/apps/lite-cli/dist/bin.js.map +1 -1
- package/apps/lite-cli/dist/index.d.ts.map +1 -1
- package/apps/lite-cli/dist/index.js +155 -81
- package/apps/lite-cli/dist/index.js.map +1 -1
- package/apps/lite-cli/dist/index.test.js +87 -63
- package/apps/lite-cli/dist/index.test.js.map +1 -1
- package/apps/lite-cli/dist/query.d.ts +4 -1
- package/apps/lite-cli/dist/query.d.ts.map +1 -1
- package/apps/lite-cli/dist/query.js +45 -29
- package/apps/lite-cli/dist/query.js.map +1 -1
- package/apps/lite-cli/dist/resource-errors.d.ts +3 -0
- package/apps/lite-cli/dist/resource-errors.d.ts.map +1 -0
- package/apps/lite-cli/dist/resource-errors.js +17 -0
- package/apps/lite-cli/dist/resource-errors.js.map +1 -0
- package/apps/lite-cli/dist/shell.d.ts +12 -2
- package/apps/lite-cli/dist/shell.d.ts.map +1 -1
- package/apps/lite-cli/dist/shell.js +129 -57
- package/apps/lite-cli/dist/shell.js.map +1 -1
- package/apps/lite-cli/dist/sql-query.test.d.ts +2 -0
- package/apps/lite-cli/dist/sql-query.test.d.ts.map +1 -0
- package/apps/lite-cli/dist/sql-query.test.js +290 -0
- package/apps/lite-cli/dist/sql-query.test.js.map +1 -0
- package/apps/lite-cli/dist/version.d.ts +1 -1
- package/apps/lite-cli/dist/version.js +1 -1
- package/apps/lite-tui/dist/bin.js +3 -3
- package/apps/lite-tui/dist/bin.js.map +1 -1
- package/apps/lite-tui/dist/index.d.ts.map +1 -1
- package/apps/lite-tui/dist/index.js +2 -2
- package/apps/lite-tui/dist/index.js.map +1 -1
- package/apps/lite-tui/dist/index.test.js +5 -3
- package/apps/lite-tui/dist/index.test.js.map +1 -1
- package/apps/lite-tui/dist/render.d.ts +1 -1
- package/apps/lite-tui/dist/version.d.ts +1 -1
- package/apps/lite-tui/dist/version.js +1 -1
- package/bin/cchistory-lite-tui.mjs +3 -3
- package/bin/cchistory-lite.mjs +3 -3
- package/docs/guide/for-agents.md +65 -42
- package/docs/guide/lite.md +64 -24
- package/docs/guide/queries/latest-sessions.sql +4 -0
- package/docs/guide/queries/latest-turns.sql +1 -0
- package/docs/guide/queries/list-sessions.sql +2 -0
- package/docs/guide/query.md +153 -0
- package/node_modules/@cchistory/canonical/dist/directory-scope.d.ts +7 -0
- package/node_modules/@cchistory/canonical/dist/directory-scope.d.ts.map +1 -1
- package/node_modules/@cchistory/canonical/dist/directory-scope.js +11 -0
- package/node_modules/@cchistory/canonical/dist/directory-scope.js.map +1 -1
- package/node_modules/@cchistory/canonical/dist/index.d.ts +5 -1
- package/node_modules/@cchistory/canonical/dist/index.d.ts.map +1 -1
- package/node_modules/@cchistory/canonical/dist/index.js +5 -1
- package/node_modules/@cchistory/canonical/dist/index.js.map +1 -1
- package/node_modules/@cchistory/canonical/dist/query.d.ts +15 -0
- package/node_modules/@cchistory/canonical/dist/query.d.ts.map +1 -0
- package/node_modules/@cchistory/canonical/dist/query.js +208 -0
- package/node_modules/@cchistory/canonical/dist/query.js.map +1 -0
- package/node_modules/@cchistory/canonical/dist/session-family.d.ts +1 -0
- package/node_modules/@cchistory/canonical/dist/session-family.d.ts.map +1 -1
- package/node_modules/@cchistory/canonical/dist/session-family.js +3 -0
- package/node_modules/@cchistory/canonical/dist/session-family.js.map +1 -1
- package/node_modules/@cchistory/canonical/dist/session-family.test.js +61 -0
- package/node_modules/@cchistory/canonical/dist/session-family.test.js.map +1 -1
- package/node_modules/@cchistory/canonical/dist/session-interpreter.d.ts +30 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.d.ts.map +1 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.js +713 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.js.map +1 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.test.d.ts +2 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.test.d.ts.map +1 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.test.js +56 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.test.js.map +1 -0
- package/node_modules/@cchistory/canonical/package.json +1 -1
- package/node_modules/@cchistory/domain/dist/evidence-atoms.d.ts +7 -0
- package/node_modules/@cchistory/domain/dist/evidence-atoms.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/evidence-atoms.js +36 -0
- package/node_modules/@cchistory/domain/dist/evidence-atoms.js.map +1 -0
- package/node_modules/@cchistory/domain/dist/evidence-values.d.ts +26 -0
- package/node_modules/@cchistory/domain/dist/evidence-values.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/evidence-values.js +80 -0
- package/node_modules/@cchistory/domain/dist/evidence-values.js.map +1 -0
- package/node_modules/@cchistory/domain/dist/index.d.ts +6 -0
- package/node_modules/@cchistory/domain/dist/index.d.ts.map +1 -1
- package/node_modules/@cchistory/domain/dist/index.js +5 -0
- package/node_modules/@cchistory/domain/dist/index.js.map +1 -1
- package/node_modules/@cchistory/domain/dist/masks.d.ts +31 -0
- package/node_modules/@cchistory/domain/dist/masks.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/masks.js +342 -0
- package/node_modules/@cchistory/domain/dist/masks.js.map +1 -0
- package/node_modules/@cchistory/domain/dist/parsed-session.d.ts +58 -0
- package/node_modules/@cchistory/domain/dist/parsed-session.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/parsed-session.js +2 -0
- package/node_modules/@cchistory/domain/dist/parsed-session.js.map +1 -0
- package/node_modules/@cchistory/domain/dist/query.d.ts +67 -0
- package/node_modules/@cchistory/domain/dist/query.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/query.js +2 -0
- package/node_modules/@cchistory/domain/dist/query.js.map +1 -0
- package/node_modules/@cchistory/domain/dist/token-evidence.d.ts +14 -0
- package/node_modules/@cchistory/domain/dist/token-evidence.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/token-evidence.js +247 -0
- package/node_modules/@cchistory/domain/dist/token-evidence.js.map +1 -0
- package/node_modules/@cchistory/domain/package.json +1 -1
- package/node_modules/@cchistory/live-runtime/dist/bootstrap.d.ts +0 -1
- package/node_modules/@cchistory/live-runtime/dist/bootstrap.d.ts.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/bootstrap.js +0 -1
- package/node_modules/@cchistory/live-runtime/dist/bootstrap.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/index.d.ts +30 -9
- package/node_modules/@cchistory/live-runtime/dist/index.d.ts.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/index.js +263 -58
- package/node_modules/@cchistory/live-runtime/dist/index.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/index.test.js +177 -20
- package/node_modules/@cchistory/live-runtime/dist/index.test.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.d.ts +16 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.js +55 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.js +192 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.d.ts +32 -23
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.d.ts.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.js +65 -45
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.test.js +363 -59
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.test.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/selective-query.d.ts +47 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.js +15 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.test.js +166 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.d.ts +37 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.js +301 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.test.js +67 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-worker.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-worker.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-worker.js +14 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-worker.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/system-memory.d.ts +13 -10
- package/node_modules/@cchistory/live-runtime/dist/system-memory.d.ts.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/system-memory.js +61 -34
- package/node_modules/@cchistory/live-runtime/dist/system-memory.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/system-memory.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/system-memory.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/system-memory.test.js +76 -0
- package/node_modules/@cchistory/live-runtime/dist/system-memory.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/package.json +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/discovery.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/core/discovery.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/factories.d.ts +2 -4
- package/node_modules/@cchistory/source-adapters/dist/core/factories.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/factories.js +1 -23
- package/node_modules/@cchistory/source-adapters/dist/core/factories.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.d.ts +25 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.js +80 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.d.ts +2 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.js +122 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/git-project.d.ts +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/git-project.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/git-project.js +2 -11
- package/node_modules/@cchistory/source-adapters/dist/core/git-project.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts +2 -1
- package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/parser.js +4 -4
- package/node_modules/@cchistory/source-adapters/dist/core/parser.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/probe.d.ts +8 -6
- package/node_modules/@cchistory/source-adapters/dist/core/probe.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/probe.js +54 -36
- package/node_modules/@cchistory/source-adapters/dist/core/probe.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/projections.d.ts +2 -28
- package/node_modules/@cchistory/source-adapters/dist/core/projections.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/projections.js +2 -695
- package/node_modules/@cchistory/source-adapters/dist/core/projections.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/projections.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/core/projections.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.d.ts +18 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.js +27 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.d.ts +2 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.js +75 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.d.ts +6 -0
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/source-identity.d.ts +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/source-identity.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/token-usage.d.ts +1 -13
- package/node_modules/@cchistory/source-adapters/dist/core/token-usage.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/token-usage.js +1 -246
- package/node_modules/@cchistory/source-adapters/dist/core/token-usage.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/tokens.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/tokens.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/type-guards.d.ts +1 -25
- package/node_modules/@cchistory/source-adapters/dist/core/type-guards.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/type-guards.js +1 -79
- package/node_modules/@cchistory/source-adapters/dist/core/type-guards.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/types.d.ts +6 -35
- package/node_modules/@cchistory/source-adapters/dist/core/types.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.d.ts +2 -1
- package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.js +14 -10
- package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/index.d.ts +6 -0
- package/node_modules/@cchistory/source-adapters/dist/index.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/index.js +4 -0
- package/node_modules/@cchistory/source-adapters/dist/index.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts +2 -0
- package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/index.test.js +2 -0
- package/node_modules/@cchistory/source-adapters/dist/index.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/masks.d.ts +1 -30
- package/node_modules/@cchistory/source-adapters/dist/masks.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/masks.js +1 -341
- package/node_modules/@cchistory/source-adapters/dist/masks.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/accio.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/accio.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/amp.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/amp.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/claude.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/claude.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/codebuddy.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/codebuddy.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.d.ts +14 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.js +103 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.d.ts +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.js +5 -3
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/factory-droid.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/factory-droid.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/gemini.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/gemini.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok.js +24 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/kimi.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/kimi.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/lobechat.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/lobechat.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/openclaw.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/openclaw.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.d.ts +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.js +11 -9
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.d.ts +8 -0
- package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.js +7 -0
- package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/test-helpers.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/package.json +1 -1
- package/node_modules/commander/LICENSE +22 -0
- package/node_modules/commander/Readme.md +428 -0
- package/node_modules/commander/index.js +1224 -0
- package/node_modules/commander/package.json +38 -0
- package/node_modules/commander/typings/index.d.ts +310 -0
- package/node_modules/discontinuous-range/.npmignore +28 -0
- package/node_modules/discontinuous-range/.travis.yml +4 -0
- package/node_modules/discontinuous-range/LICENSE +21 -0
- package/node_modules/discontinuous-range/README.md +23 -0
- package/node_modules/discontinuous-range/index.js +144 -0
- package/node_modules/discontinuous-range/package.json +27 -0
- package/node_modules/discontinuous-range/test/main-test.js +96 -0
- package/node_modules/moo/LICENSE +29 -0
- package/node_modules/moo/README.md +385 -0
- package/node_modules/moo/moo.js +645 -0
- package/node_modules/moo/package.json +29 -0
- package/node_modules/nearley/LICENSE.txt +21 -0
- package/node_modules/nearley/README.md +80 -0
- package/node_modules/nearley/bin/nearley-railroad.js +121 -0
- package/node_modules/nearley/bin/nearley-test.js +64 -0
- package/node_modules/nearley/bin/nearley-unparse.js +29 -0
- package/node_modules/nearley/bin/nearleyc.js +38 -0
- package/node_modules/nearley/builtin/cow.ne +2 -0
- package/node_modules/nearley/builtin/number.ne +51 -0
- package/node_modules/nearley/builtin/postprocessors.ne +36 -0
- package/node_modules/nearley/builtin/string.ne +26 -0
- package/node_modules/nearley/builtin/whitespace.ne +5 -0
- package/node_modules/nearley/lib/compile.js +307 -0
- package/node_modules/nearley/lib/generate.js +244 -0
- package/node_modules/nearley/lib/lint.js +28 -0
- package/node_modules/nearley/lib/nearley-language-bootstrapped.js +132 -0
- package/node_modules/nearley/lib/nearley-language-bootstrapped.ne +126 -0
- package/node_modules/nearley/lib/nearley.js +564 -0
- package/node_modules/nearley/lib/stream.js +18 -0
- package/node_modules/nearley/lib/unparse.js +139 -0
- package/node_modules/nearley/package.json +63 -0
- package/node_modules/pgsql-ast-parser/ast-mapper.d.ts +237 -0
- package/node_modules/pgsql-ast-parser/ast-mapper.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/ast-mapper.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/ast-mapper.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/ast-visitor.d.ts +33 -0
- package/node_modules/pgsql-ast-parser/ast-visitor.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/ast-visitor.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/ast-visitor.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/index.d.ts +11 -0
- package/node_modules/pgsql-ast-parser/index.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/index.js +6484 -0
- package/node_modules/pgsql-ast-parser/index.js.map +1 -0
- package/node_modules/pgsql-ast-parser/interfaces.d.ts +1 -0
- package/node_modules/pgsql-ast-parser/interfaces.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/keywords.d.ts +2 -0
- package/node_modules/pgsql-ast-parser/keywords.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/lexer.d.ts +15 -0
- package/node_modules/pgsql-ast-parser/lexer.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/lexer.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/lexer.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array-lexer.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array-lexer.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array.ne.d.ts +29 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array.ne.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric-lexer.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric-lexer.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.ne.d.ts +29 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.ne.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-builder.d.ts +10 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-builder.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso-lexer.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso-lexer.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso.ne.d.ts +29 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso.ne.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-lexer.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-lexer.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.ne.d.ts +29 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.ne.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/package.json +69 -0
- package/node_modules/pgsql-ast-parser/parser.d.ts +33 -0
- package/node_modules/pgsql-ast-parser/parser.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/pg-escape.d.ts +2 -0
- package/node_modules/pgsql-ast-parser/pg-escape.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/readme.md +255 -0
- package/node_modules/pgsql-ast-parser/src/ast-mapper.spec.ts +296 -0
- package/node_modules/pgsql-ast-parser/src/ast-mapper.ts +1378 -0
- package/node_modules/pgsql-ast-parser/src/ast-visitor.spec.ts +57 -0
- package/node_modules/pgsql-ast-parser/src/ast-visitor.ts +101 -0
- package/node_modules/pgsql-ast-parser/src/index.ts +10 -0
- package/node_modules/pgsql-ast-parser/src/interfaces.ts +0 -0
- package/node_modules/pgsql-ast-parser/src/keywords.ts +8 -0
- package/node_modules/pgsql-ast-parser/src/lexer.spec.ts +245 -0
- package/node_modules/pgsql-ast-parser/src/lexer.ts +267 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/array-lexer.ts +27 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/array.ne +18 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/array.spec.ts +55 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/geometric-lexer.ts +26 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/geometric.ne +88 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/geometric.spec.ts +131 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-builder.ts +148 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-iso-lexer.ts +17 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-iso.ne +53 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-lexer.ts +26 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval.ne +54 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval.spec.ts +106 -0
- package/node_modules/pgsql-ast-parser/src/parser.ts +142 -0
- package/node_modules/pgsql-ast-parser/src/pg-escape.ts +14 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-index.ne +29 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-index.spec.ts +35 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-table.ne +123 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-table.spec.ts +476 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-type.ne +33 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-type.spec.ts +29 -0
- package/node_modules/pgsql-ast-parser/src/syntax/ast.ts +1150 -0
- package/node_modules/pgsql-ast-parser/src/syntax/base.ne +369 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-extension.ne +17 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-extension.spec.ts +37 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-index.ne +62 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-index.spec.ts +245 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-table.ne +174 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-table.spec.ts +761 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-type.ne +40 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-type.spec.ts +32 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-view.ne +68 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-view.spec.ts +187 -0
- package/node_modules/pgsql-ast-parser/src/syntax/deallocate.ne +13 -0
- package/node_modules/pgsql-ast-parser/src/syntax/deallocate.spec.ts +19 -0
- package/node_modules/pgsql-ast-parser/src/syntax/delete.ne +36 -0
- package/node_modules/pgsql-ast-parser/src/syntax/delete.spec.ts +71 -0
- package/node_modules/pgsql-ast-parser/src/syntax/drop.ne +28 -0
- package/node_modules/pgsql-ast-parser/src/syntax/drop.spec.ts +77 -0
- package/node_modules/pgsql-ast-parser/src/syntax/edge-cases.spec.ts +41 -0
- package/node_modules/pgsql-ast-parser/src/syntax/expr.ne +350 -0
- package/node_modules/pgsql-ast-parser/src/syntax/expr.spec.ts +1638 -0
- package/node_modules/pgsql-ast-parser/src/syntax/functions.ne +114 -0
- package/node_modules/pgsql-ast-parser/src/syntax/functions.spec.ts +235 -0
- package/node_modules/pgsql-ast-parser/src/syntax/insert.ne +63 -0
- package/node_modules/pgsql-ast-parser/src/syntax/insert.spec.ts +292 -0
- package/node_modules/pgsql-ast-parser/src/syntax/main.ne +77 -0
- package/node_modules/pgsql-ast-parser/src/syntax/nearley.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/src/syntax/prepare.ne +8 -0
- package/node_modules/pgsql-ast-parser/src/syntax/prepare.spec.ts +44 -0
- package/node_modules/pgsql-ast-parser/src/syntax/refresh-materialized-view.ne +19 -0
- package/node_modules/pgsql-ast-parser/src/syntax/refresh-materialized-view.spec.ts +42 -0
- package/node_modules/pgsql-ast-parser/src/syntax/select.ne +223 -0
- package/node_modules/pgsql-ast-parser/src/syntax/select.spec.ts +1063 -0
- package/node_modules/pgsql-ast-parser/src/syntax/sequence.ne +101 -0
- package/node_modules/pgsql-ast-parser/src/syntax/sequence.spec.ts +103 -0
- package/node_modules/pgsql-ast-parser/src/syntax/simple-statements.ne +168 -0
- package/node_modules/pgsql-ast-parser/src/syntax/simple-statements.spec.ts +327 -0
- package/node_modules/pgsql-ast-parser/src/syntax/spec-utils.ts +333 -0
- package/node_modules/pgsql-ast-parser/src/syntax/union.ne +18 -0
- package/node_modules/pgsql-ast-parser/src/syntax/union.spec.ts +125 -0
- package/node_modules/pgsql-ast-parser/src/syntax/update.ne +56 -0
- package/node_modules/pgsql-ast-parser/src/syntax/update.spec.ts +87 -0
- package/node_modules/pgsql-ast-parser/src/syntax/with.ne +41 -0
- package/node_modules/pgsql-ast-parser/src/syntax/with.spec.ts +155 -0
- package/node_modules/pgsql-ast-parser/src/to-sql.spec.ts +85 -0
- package/node_modules/pgsql-ast-parser/src/to-sql.ts +1555 -0
- package/node_modules/pgsql-ast-parser/src/utils.ts +47 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-index.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-index.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-table.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-table.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-type.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-type.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/ast.d.ts +826 -0
- package/node_modules/pgsql-ast-parser/syntax/ast.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/create-extension.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/create-extension.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/create-index.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/create-index.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/create-table.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/create-table.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/create-type.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/create-type.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/create-view.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/create-view.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/deallocate.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/deallocate.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/delete.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/delete.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/drop.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/drop.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/edge-cases.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/edge-cases.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/expr.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/expr.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/functions.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/functions.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/insert.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/insert.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/main.ne.d.ts +29 -0
- package/node_modules/pgsql-ast-parser/syntax/main.ne.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/prepare.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/prepare.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/refresh-materialized-view.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/refresh-materialized-view.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/select.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/select.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/sequence.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/sequence.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/simple-statements.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/simple-statements.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/spec-utils.d.ts +35 -0
- package/node_modules/pgsql-ast-parser/syntax/spec-utils.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/union.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/union.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/update.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/update.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/with.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/with.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/to-sql.d.ts +7 -0
- package/node_modules/pgsql-ast-parser/to-sql.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/to-sql.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/to-sql.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/utils.d.ts +16 -0
- package/node_modules/pgsql-ast-parser/utils.d.ts.map +1 -0
- package/node_modules/railroad-diagrams/.gitattributes +22 -0
- package/node_modules/railroad-diagrams/.npmignore +163 -0
- package/node_modules/railroad-diagrams/README.md +86 -0
- package/node_modules/railroad-diagrams/css-example.py-js +183 -0
- package/node_modules/railroad-diagrams/example.html +141 -0
- package/node_modules/railroad-diagrams/generator.html +59 -0
- package/node_modules/railroad-diagrams/package.json +23 -0
- package/node_modules/railroad-diagrams/railroad-diagrams.css +23 -0
- package/node_modules/railroad-diagrams/railroad-diagrams.js +524 -0
- package/node_modules/railroad-diagrams/railroad_diagrams.py +427 -0
- package/node_modules/randexp/LICENSE +19 -0
- package/node_modules/randexp/README.md +134 -0
- package/node_modules/randexp/lib/randexp.js +245 -0
- package/node_modules/randexp/package.json +48 -0
- package/node_modules/ret/LICENSE +19 -0
- package/node_modules/ret/README.md +183 -0
- package/node_modules/ret/lib/index.js +282 -0
- package/node_modules/ret/lib/positions.js +17 -0
- package/node_modules/ret/lib/sets.js +82 -0
- package/node_modules/ret/lib/types.js +10 -0
- package/node_modules/ret/lib/util.js +111 -0
- package/node_modules/ret/package.json +35 -0
- package/package.json +22 -6
- package/schemas/cchistory-lite-agent-v1.schema.json +6 -7
- package/schemas/cchistory-lite-error-v1.schema.json +58 -8
- package/schemas/cchistory-lite-query-result-v2.schema.json +66 -11
- package/schemas/cchistory-lite-query-result-v3.schema.json +219 -0
- package/schemas/cchistory-lite-query-v3.schema.json +57 -0
- package/schemas/cchistory-lite-source-inventory-v1.schema.json +72 -0
- package/skills/using-cchistory-lite/SKILL.md +125 -53
- package/node_modules/@cchistory/live-runtime/dist/node-memory.d.ts +0 -8
- package/node_modules/@cchistory/live-runtime/dist/node-memory.d.ts.map +0 -1
- package/node_modules/@cchistory/live-runtime/dist/node-memory.js +0 -110
- package/node_modules/@cchistory/live-runtime/dist/node-memory.js.map +0 -1
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
(function(root, factory) {
|
|
2
|
+
if (typeof module === 'object' && module.exports) {
|
|
3
|
+
module.exports = factory(require('./nearley'));
|
|
4
|
+
} else {
|
|
5
|
+
root.Compile = factory(root.nearley);
|
|
6
|
+
}
|
|
7
|
+
}(this, function(nearley) {
|
|
8
|
+
|
|
9
|
+
function Compile(structure, opts) {
|
|
10
|
+
var unique = uniquer();
|
|
11
|
+
if (!opts.alreadycompiled) {
|
|
12
|
+
opts.alreadycompiled = [];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
var result = {
|
|
16
|
+
rules: [],
|
|
17
|
+
body: [], // @directives list
|
|
18
|
+
customTokens: [], // %tokens
|
|
19
|
+
config: {}, // @config value
|
|
20
|
+
macros: {},
|
|
21
|
+
start: '',
|
|
22
|
+
version: opts.version || 'unknown'
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
for (var i = 0; i < structure.length; i++) {
|
|
26
|
+
var productionRule = structure[i];
|
|
27
|
+
if (productionRule.body) {
|
|
28
|
+
// This isn't a rule, it's an @directive.
|
|
29
|
+
if (!opts.nojs) {
|
|
30
|
+
result.body.push(productionRule.body);
|
|
31
|
+
}
|
|
32
|
+
} else if (productionRule.include) {
|
|
33
|
+
// Include file
|
|
34
|
+
var path;
|
|
35
|
+
if (!productionRule.builtin) {
|
|
36
|
+
path = require('path').resolve(
|
|
37
|
+
opts.args[0] ? require('path').dirname(opts.args[0]) : process.cwd(),
|
|
38
|
+
productionRule.include
|
|
39
|
+
);
|
|
40
|
+
} else {
|
|
41
|
+
path = require('path').resolve(
|
|
42
|
+
__dirname,
|
|
43
|
+
'../builtin/',
|
|
44
|
+
productionRule.include
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
if (opts.alreadycompiled.indexOf(path) === -1) {
|
|
48
|
+
opts.alreadycompiled.push(path);
|
|
49
|
+
var f = require('fs').readFileSync(path).toString();
|
|
50
|
+
var parserGrammar = nearley.Grammar.fromCompiled(require('./nearley-language-bootstrapped.js'));
|
|
51
|
+
var parser = new nearley.Parser(parserGrammar);
|
|
52
|
+
parser.feed(f);
|
|
53
|
+
var c = Compile(parser.results[0], {args: [path], __proto__:opts});
|
|
54
|
+
result.rules = result.rules.concat(c.rules);
|
|
55
|
+
result.body = result.body.concat(c.body);
|
|
56
|
+
result.customTokens = result.customTokens.concat(c.customTokens);
|
|
57
|
+
Object.keys(c.config).forEach(function(k) {
|
|
58
|
+
result.config[k] = c.config[k];
|
|
59
|
+
});
|
|
60
|
+
Object.keys(c.macros).forEach(function(k) {
|
|
61
|
+
result.macros[k] = c.macros[k];
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
} else if (productionRule.macro) {
|
|
65
|
+
result.macros[productionRule.macro] = {
|
|
66
|
+
'args': productionRule.args,
|
|
67
|
+
'exprs': productionRule.exprs
|
|
68
|
+
};
|
|
69
|
+
} else if (productionRule.config) {
|
|
70
|
+
// This isn't a rule, it's an @config.
|
|
71
|
+
result.config[productionRule.config] = productionRule.value
|
|
72
|
+
} else {
|
|
73
|
+
produceRules(productionRule.name, productionRule.rules, {});
|
|
74
|
+
if (!result.start) {
|
|
75
|
+
result.start = productionRule.name;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return result;
|
|
81
|
+
|
|
82
|
+
function produceRules(name, rules, env) {
|
|
83
|
+
for (var i = 0; i < rules.length; i++) {
|
|
84
|
+
var rule = buildRule(name, rules[i], env);
|
|
85
|
+
if (opts.nojs) {
|
|
86
|
+
rule.postprocess = null;
|
|
87
|
+
}
|
|
88
|
+
result.rules.push(rule);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function buildRule(ruleName, rule, env) {
|
|
93
|
+
var tokens = [];
|
|
94
|
+
for (var i = 0; i < rule.tokens.length; i++) {
|
|
95
|
+
var token = buildToken(ruleName, rule.tokens[i], env);
|
|
96
|
+
if (token !== null) {
|
|
97
|
+
tokens.push(token);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return new nearley.Rule(
|
|
101
|
+
ruleName,
|
|
102
|
+
tokens,
|
|
103
|
+
rule.postprocess
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function buildToken(ruleName, token, env) {
|
|
108
|
+
if (typeof token === 'string') {
|
|
109
|
+
if (token === 'null') {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
return token;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (token instanceof RegExp) {
|
|
116
|
+
return token;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (token.literal) {
|
|
120
|
+
if (!token.literal.length) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
if (token.literal.length === 1 || result.config.lexer) {
|
|
124
|
+
return token;
|
|
125
|
+
}
|
|
126
|
+
return buildStringToken(ruleName, token, env);
|
|
127
|
+
}
|
|
128
|
+
if (token.token) {
|
|
129
|
+
if (result.config.lexer) {
|
|
130
|
+
var name = token.token;
|
|
131
|
+
if (result.customTokens.indexOf(name) === -1) {
|
|
132
|
+
result.customTokens.push(name);
|
|
133
|
+
}
|
|
134
|
+
var expr = result.config.lexer + ".has(" + JSON.stringify(name) + ") ? {type: " + JSON.stringify(name) + "} : " + name;
|
|
135
|
+
return {token: "(" + expr + ")"};
|
|
136
|
+
}
|
|
137
|
+
return token;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (token.subexpression) {
|
|
141
|
+
return buildSubExpressionToken(ruleName, token, env);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (token.ebnf) {
|
|
145
|
+
return buildEBNFToken(ruleName, token, env);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (token.macrocall) {
|
|
149
|
+
return buildMacroCallToken(ruleName, token, env);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (token.mixin) {
|
|
153
|
+
if (env[token.mixin]) {
|
|
154
|
+
return buildToken(ruleName, env[token.mixin], env);
|
|
155
|
+
} else {
|
|
156
|
+
throw new Error("Unbound variable: " + token.mixin);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
throw new Error("unrecognized token: " + JSON.stringify(token));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function buildStringToken(ruleName, token, env) {
|
|
164
|
+
var newname = unique(ruleName + "$string");
|
|
165
|
+
produceRules(newname, [
|
|
166
|
+
{
|
|
167
|
+
tokens: token.literal.split("").map(function charLiteral(d) {
|
|
168
|
+
return {
|
|
169
|
+
literal: d
|
|
170
|
+
};
|
|
171
|
+
}),
|
|
172
|
+
postprocess: {builtin: "joiner"}
|
|
173
|
+
}
|
|
174
|
+
], env);
|
|
175
|
+
return newname;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function buildSubExpressionToken(ruleName, token, env) {
|
|
179
|
+
var data = token.subexpression;
|
|
180
|
+
var name = unique(ruleName + "$subexpression");
|
|
181
|
+
//structure.push({"name": name, "rules": data});
|
|
182
|
+
produceRules(name, data, env);
|
|
183
|
+
return name;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function buildEBNFToken(ruleName, token, env) {
|
|
187
|
+
switch (token.modifier) {
|
|
188
|
+
case ":+":
|
|
189
|
+
return buildEBNFPlus(ruleName, token, env);
|
|
190
|
+
case ":*":
|
|
191
|
+
return buildEBNFStar(ruleName, token, env);
|
|
192
|
+
case ":?":
|
|
193
|
+
return buildEBNFOpt(ruleName, token, env);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function buildEBNFPlus(ruleName, token, env) {
|
|
198
|
+
var name = unique(ruleName + "$ebnf");
|
|
199
|
+
/*
|
|
200
|
+
structure.push({
|
|
201
|
+
name: name,
|
|
202
|
+
rules: [{
|
|
203
|
+
tokens: [token.ebnf],
|
|
204
|
+
}, {
|
|
205
|
+
tokens: [token.ebnf, name],
|
|
206
|
+
postprocess: {builtin: "arrconcat"}
|
|
207
|
+
}]
|
|
208
|
+
});
|
|
209
|
+
*/
|
|
210
|
+
produceRules(name,
|
|
211
|
+
[{
|
|
212
|
+
tokens: [token.ebnf],
|
|
213
|
+
}, {
|
|
214
|
+
tokens: [name, token.ebnf],
|
|
215
|
+
postprocess: {builtin: "arrpush"}
|
|
216
|
+
}],
|
|
217
|
+
env
|
|
218
|
+
);
|
|
219
|
+
return name;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function buildEBNFStar(ruleName, token, env) {
|
|
223
|
+
var name = unique(ruleName + "$ebnf");
|
|
224
|
+
/*
|
|
225
|
+
structure.push({
|
|
226
|
+
name: name,
|
|
227
|
+
rules: [{
|
|
228
|
+
tokens: [],
|
|
229
|
+
}, {
|
|
230
|
+
tokens: [token.ebnf, name],
|
|
231
|
+
postprocess: {builtin: "arrconcat"}
|
|
232
|
+
}]
|
|
233
|
+
});
|
|
234
|
+
*/
|
|
235
|
+
produceRules(name,
|
|
236
|
+
[{
|
|
237
|
+
tokens: [],
|
|
238
|
+
}, {
|
|
239
|
+
tokens: [name, token.ebnf],
|
|
240
|
+
postprocess: {builtin: "arrpush"}
|
|
241
|
+
}],
|
|
242
|
+
env
|
|
243
|
+
);
|
|
244
|
+
return name;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function buildEBNFOpt(ruleName, token, env) {
|
|
248
|
+
var name = unique(ruleName + "$ebnf");
|
|
249
|
+
/*
|
|
250
|
+
structure.push({
|
|
251
|
+
name: name,
|
|
252
|
+
rules: [{
|
|
253
|
+
tokens: [token.ebnf],
|
|
254
|
+
postprocess: {builtin: "id"}
|
|
255
|
+
}, {
|
|
256
|
+
tokens: [],
|
|
257
|
+
postprocess: {builtin: "nuller"}
|
|
258
|
+
}]
|
|
259
|
+
});
|
|
260
|
+
*/
|
|
261
|
+
produceRules(name,
|
|
262
|
+
[{
|
|
263
|
+
tokens: [token.ebnf],
|
|
264
|
+
postprocess: {builtin: "id"}
|
|
265
|
+
}, {
|
|
266
|
+
tokens: [],
|
|
267
|
+
postprocess: {builtin: "nuller"}
|
|
268
|
+
}],
|
|
269
|
+
env
|
|
270
|
+
);
|
|
271
|
+
return name;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function buildMacroCallToken(ruleName, token, env) {
|
|
275
|
+
var name = unique(ruleName + "$macrocall");
|
|
276
|
+
var macro = result.macros[token.macrocall];
|
|
277
|
+
if (!macro) {
|
|
278
|
+
throw new Error("Unkown macro: "+token.macrocall);
|
|
279
|
+
}
|
|
280
|
+
if (macro.args.length !== token.args.length) {
|
|
281
|
+
throw new Error("Argument count mismatch.");
|
|
282
|
+
}
|
|
283
|
+
var newenv = {__proto__: env};
|
|
284
|
+
for (var i=0; i<macro.args.length; i++) {
|
|
285
|
+
var argrulename = unique(ruleName + "$macrocall");
|
|
286
|
+
newenv[macro.args[i]] = argrulename;
|
|
287
|
+
produceRules(argrulename, [token.args[i]], env);
|
|
288
|
+
//structure.push({"name": argrulename, "rules":[token.args[i]]});
|
|
289
|
+
//buildRule(name, token.args[i], env);
|
|
290
|
+
}
|
|
291
|
+
produceRules(name, macro.exprs, newenv);
|
|
292
|
+
return name;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function uniquer() {
|
|
297
|
+
var uns = {};
|
|
298
|
+
return unique;
|
|
299
|
+
function unique(name) {
|
|
300
|
+
var un = uns[name] = (uns[name] || 0) + 1;
|
|
301
|
+
return name + '$' + un;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return Compile;
|
|
306
|
+
|
|
307
|
+
}));
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
(function(root, factory) {
|
|
2
|
+
if (typeof module === 'object' && module.exports) {
|
|
3
|
+
module.exports = factory(require('./nearley'));
|
|
4
|
+
} else {
|
|
5
|
+
root.generate = factory(root.nearley);
|
|
6
|
+
}
|
|
7
|
+
}(this, function(nearley) {
|
|
8
|
+
|
|
9
|
+
function serializeRules(rules, builtinPostprocessors, extraIndent) {
|
|
10
|
+
if (extraIndent == null) {
|
|
11
|
+
extraIndent = ''
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return '[\n ' + rules.map(function(rule) {
|
|
15
|
+
return serializeRule(rule, builtinPostprocessors);
|
|
16
|
+
}).join(',\n ') + '\n' + extraIndent + ']';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function dedentFunc(func) {
|
|
20
|
+
var lines = func.toString().split(/\n/);
|
|
21
|
+
|
|
22
|
+
if (lines.length === 1) {
|
|
23
|
+
return [lines[0].replace(/^\s+|\s+$/g, '')];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var indent = null;
|
|
27
|
+
var tail = lines.slice(1);
|
|
28
|
+
for (var i = 0; i < tail.length; i++) {
|
|
29
|
+
var match = /^\s*/.exec(tail[i]);
|
|
30
|
+
if (match && match[0].length !== tail[i].length) {
|
|
31
|
+
if (indent === null ||
|
|
32
|
+
match[0].length < indent.length) {
|
|
33
|
+
indent = match[0];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (indent === null) {
|
|
39
|
+
return lines;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return lines.map(function dedent(line) {
|
|
43
|
+
if (line.slice(0, indent.length) === indent) {
|
|
44
|
+
return line.slice(indent.length);
|
|
45
|
+
}
|
|
46
|
+
return line;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function tabulateString(string, indent, options) {
|
|
51
|
+
var lines;
|
|
52
|
+
if(Array.isArray(string)) {
|
|
53
|
+
lines = string;
|
|
54
|
+
} else {
|
|
55
|
+
lines = string.toString().split('\n');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
options = options || {};
|
|
59
|
+
var tabulated = lines.map(function addIndent(line, i) {
|
|
60
|
+
var shouldIndent = true;
|
|
61
|
+
|
|
62
|
+
if(i == 0 && !options.indentFirst) {
|
|
63
|
+
shouldIndent = false;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if(shouldIndent) {
|
|
67
|
+
return indent + line;
|
|
68
|
+
} else {
|
|
69
|
+
return line;
|
|
70
|
+
}
|
|
71
|
+
}).join('\n');
|
|
72
|
+
|
|
73
|
+
return tabulated;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function serializeSymbol(s) {
|
|
77
|
+
if (s instanceof RegExp) {
|
|
78
|
+
return s.toString();
|
|
79
|
+
} else if (s.token) {
|
|
80
|
+
return s.token;
|
|
81
|
+
} else {
|
|
82
|
+
return JSON.stringify(s);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function serializeRule(rule, builtinPostprocessors) {
|
|
87
|
+
var ret = '{';
|
|
88
|
+
ret += '"name": ' + JSON.stringify(rule.name);
|
|
89
|
+
ret += ', "symbols": [' + rule.symbols.map(serializeSymbol).join(', ') + ']';
|
|
90
|
+
if (rule.postprocess) {
|
|
91
|
+
if(rule.postprocess.builtin) {
|
|
92
|
+
rule.postprocess = builtinPostprocessors[rule.postprocess.builtin];
|
|
93
|
+
}
|
|
94
|
+
ret += ', "postprocess": ' + tabulateString(dedentFunc(rule.postprocess), ' ', {indentFirst: false});
|
|
95
|
+
}
|
|
96
|
+
ret += '}';
|
|
97
|
+
return ret;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
var generate = function (parser, exportName) {
|
|
101
|
+
if(!parser.config.preprocessor) {
|
|
102
|
+
parser.config.preprocessor = "_default";
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if(!generate[parser.config.preprocessor]) {
|
|
106
|
+
throw new Error("No such preprocessor: " + parser.config.preprocessor)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return generate[parser.config.preprocessor](parser, exportName);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
generate.js = generate._default = generate.javascript = function (parser, exportName) {
|
|
113
|
+
var output = "// Generated automatically by nearley, version " + parser.version + "\n";
|
|
114
|
+
output += "// http://github.com/Hardmath123/nearley\n";
|
|
115
|
+
output += "(function () {\n";
|
|
116
|
+
output += "function id(x) { return x[0]; }\n";
|
|
117
|
+
output += parser.body.join('\n');
|
|
118
|
+
output += "var grammar = {\n";
|
|
119
|
+
output += " Lexer: " + parser.config.lexer + ",\n";
|
|
120
|
+
output += " ParserRules: " +
|
|
121
|
+
serializeRules(parser.rules, generate.javascript.builtinPostprocessors)
|
|
122
|
+
+ "\n";
|
|
123
|
+
output += " , ParserStart: " + JSON.stringify(parser.start) + "\n";
|
|
124
|
+
output += "}\n";
|
|
125
|
+
output += "if (typeof module !== 'undefined'"
|
|
126
|
+
+ "&& typeof module.exports !== 'undefined') {\n";
|
|
127
|
+
output += " module.exports = grammar;\n";
|
|
128
|
+
output += "} else {\n";
|
|
129
|
+
output += " window." + exportName + " = grammar;\n";
|
|
130
|
+
output += "}\n";
|
|
131
|
+
output += "})();\n";
|
|
132
|
+
return output;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
generate.javascript.builtinPostprocessors = {
|
|
136
|
+
"joiner": "function joiner(d) {return d.join('');}",
|
|
137
|
+
"arrconcat": "function arrconcat(d) {return [d[0]].concat(d[1]);}",
|
|
138
|
+
"arrpush": "function arrpush(d) {return d[0].concat([d[1]]);}",
|
|
139
|
+
"nuller": "function(d) {return null;}",
|
|
140
|
+
"id": "id"
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
generate.module = generate.esmodule = function (parser, exportName) {
|
|
144
|
+
var output = "// Generated automatically by nearley, version " + parser.version + "\n";
|
|
145
|
+
output += "// http://github.com/Hardmath123/nearley\n";
|
|
146
|
+
output += "function id(x) { return x[0]; }\n";
|
|
147
|
+
output += parser.body.join('\n');
|
|
148
|
+
output += "let Lexer = " + parser.config.lexer + ";\n";
|
|
149
|
+
output += "let ParserRules = " + serializeRules(parser.rules, generate.javascript.builtinPostprocessors) + ";\n";
|
|
150
|
+
output += "let ParserStart = " + JSON.stringify(parser.start) + ";\n";
|
|
151
|
+
output += "export default { Lexer, ParserRules, ParserStart };\n";
|
|
152
|
+
return output;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
generate.cs = generate.coffee = generate.coffeescript = function (parser, exportName) {
|
|
156
|
+
var output = "# Generated automatically by nearley, version " + parser.version + "\n";
|
|
157
|
+
output += "# http://github.com/Hardmath123/nearley\n";
|
|
158
|
+
output += "do ->\n";
|
|
159
|
+
output += " id = (d) -> d[0]\n";
|
|
160
|
+
output += tabulateString(dedentFunc(parser.body.join('\n')), ' ') + '\n';
|
|
161
|
+
output += " grammar = {\n";
|
|
162
|
+
output += " Lexer: " + parser.config.lexer + ",\n";
|
|
163
|
+
output += " ParserRules: " +
|
|
164
|
+
tabulateString(
|
|
165
|
+
serializeRules(parser.rules, generate.coffeescript.builtinPostprocessors),
|
|
166
|
+
' ',
|
|
167
|
+
{indentFirst: false})
|
|
168
|
+
+ ",\n";
|
|
169
|
+
output += " ParserStart: " + JSON.stringify(parser.start) + "\n";
|
|
170
|
+
output += " }\n";
|
|
171
|
+
output += " if typeof module != 'undefined' "
|
|
172
|
+
+ "&& typeof module.exports != 'undefined'\n";
|
|
173
|
+
output += " module.exports = grammar;\n";
|
|
174
|
+
output += " else\n";
|
|
175
|
+
output += " window." + exportName + " = grammar;\n";
|
|
176
|
+
return output;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
generate.coffeescript.builtinPostprocessors = {
|
|
180
|
+
"joiner": "(d) -> d.join('')",
|
|
181
|
+
"arrconcat": "(d) -> [d[0]].concat(d[1])",
|
|
182
|
+
"arrpush": "(d) -> d[0].concat([d[1]])",
|
|
183
|
+
"nuller": "() -> null",
|
|
184
|
+
"id": "id"
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
generate.ts = generate.typescript = function (parser, exportName) {
|
|
188
|
+
var output = "// Generated automatically by nearley, version " + parser.version + "\n";
|
|
189
|
+
output += "// http://github.com/Hardmath123/nearley\n";
|
|
190
|
+
output += "// Bypasses TS6133. Allow declared but unused functions.\n";
|
|
191
|
+
output += "// @ts-ignore\n";
|
|
192
|
+
output += "function id(d: any[]): any { return d[0]; }\n";
|
|
193
|
+
output += parser.customTokens.map(function (token) { return "declare var " + token + ": any;\n" }).join("")
|
|
194
|
+
output += parser.body.join('\n');
|
|
195
|
+
output += "\n";
|
|
196
|
+
output += "interface NearleyToken {\n";
|
|
197
|
+
output += " value: any;\n";
|
|
198
|
+
output += " [key: string]: any;\n";
|
|
199
|
+
output += "};\n";
|
|
200
|
+
output += "\n";
|
|
201
|
+
output += "interface NearleyLexer {\n";
|
|
202
|
+
output += " reset: (chunk: string, info: any) => void;\n";
|
|
203
|
+
output += " next: () => NearleyToken | undefined;\n";
|
|
204
|
+
output += " save: () => any;\n";
|
|
205
|
+
output += " formatError: (token: never) => string;\n";
|
|
206
|
+
output += " has: (tokenType: string) => boolean;\n";
|
|
207
|
+
output += "};\n";
|
|
208
|
+
output += "\n";
|
|
209
|
+
output += "interface NearleyRule {\n";
|
|
210
|
+
output += " name: string;\n";
|
|
211
|
+
output += " symbols: NearleySymbol[];\n";
|
|
212
|
+
output += " postprocess?: (d: any[], loc?: number, reject?: {}) => any;\n";
|
|
213
|
+
output += "};\n";
|
|
214
|
+
output += "\n";
|
|
215
|
+
output += "type NearleySymbol = string | { literal: any } | { test: (token: any) => boolean };\n";
|
|
216
|
+
output += "\n";
|
|
217
|
+
output += "interface Grammar {\n";
|
|
218
|
+
output += " Lexer: NearleyLexer | undefined;\n";
|
|
219
|
+
output += " ParserRules: NearleyRule[];\n";
|
|
220
|
+
output += " ParserStart: string;\n";
|
|
221
|
+
output += "};\n";
|
|
222
|
+
output += "\n";
|
|
223
|
+
output += "const grammar: Grammar = {\n";
|
|
224
|
+
output += " Lexer: " + parser.config.lexer + ",\n";
|
|
225
|
+
output += " ParserRules: " + serializeRules(parser.rules, generate.typescript.builtinPostprocessors, " ") + ",\n";
|
|
226
|
+
output += " ParserStart: " + JSON.stringify(parser.start) + ",\n";
|
|
227
|
+
output += "};\n";
|
|
228
|
+
output += "\n";
|
|
229
|
+
output += "export default grammar;\n";
|
|
230
|
+
|
|
231
|
+
return output;
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
generate.typescript.builtinPostprocessors = {
|
|
235
|
+
"joiner": "(d) => d.join('')",
|
|
236
|
+
"arrconcat": "(d) => [d[0]].concat(d[1])",
|
|
237
|
+
"arrpush": "(d) => d[0].concat([d[1]])",
|
|
238
|
+
"nuller": "() => null",
|
|
239
|
+
"id": "id"
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
return generate;
|
|
243
|
+
|
|
244
|
+
}));
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Node-only
|
|
2
|
+
|
|
3
|
+
var warn = function (opts, str) {
|
|
4
|
+
opts.out.write("WARN"+"\t" + str + "\n");
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function lintNames(grm, opts) {
|
|
8
|
+
var all = [];
|
|
9
|
+
grm.rules.forEach(function(rule) {
|
|
10
|
+
all.push(rule.name);
|
|
11
|
+
});
|
|
12
|
+
grm.rules.forEach(function(rule) {
|
|
13
|
+
rule.symbols.forEach(function(symbol) {
|
|
14
|
+
if (!symbol.literal && !symbol.token && symbol.constructor !== RegExp) {
|
|
15
|
+
if (all.indexOf(symbol) === -1) {
|
|
16
|
+
warn(opts,"Undefined symbol `" + symbol + "` used.");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function lint(grm, opts) {
|
|
24
|
+
if (!opts.out) opts.out = process.stderr;
|
|
25
|
+
lintNames(grm, opts);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = lint;
|