@cchistory/lite 0.4.5 → 0.6.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 +7 -5
- package/apps/lite-cli/dist/agent-contract.d.ts.map +1 -1
- package/apps/lite-cli/dist/agent-contract.js +36 -25
- package/apps/lite-cli/dist/agent-contract.js.map +1 -1
- package/apps/lite-cli/dist/bin.js +2 -2
- 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 +151 -66
- package/apps/lite-cli/dist/index.js.map +1 -1
- package/apps/lite-cli/dist/index.test.js +59 -89
- 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 +2 -2
- 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 +6 -2
- package/apps/lite-tui/dist/index.js.map +1 -1
- package/apps/lite-tui/dist/index.test.js +10 -8
- 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 +2 -2
- package/bin/cchistory-lite.mjs +2 -2
- package/docs/guide/for-agents.md +66 -46
- package/docs/guide/lite.md +53 -11
- 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 +1 -1
- package/node_modules/@cchistory/live-runtime/dist/bootstrap.d.ts.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/bootstrap.js +1 -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 +314 -143
- 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/launcher-memory.d.ts +12 -0
- package/node_modules/@cchistory/live-runtime/dist/launcher-memory.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/launcher-memory.js +44 -0
- package/node_modules/@cchistory/live-runtime/dist/launcher-memory.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/launcher-memory.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/launcher-memory.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/launcher-memory.test.js +20 -0
- package/node_modules/@cchistory/live-runtime/dist/launcher-memory.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/live-read-recovery.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/live-read-recovery.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/live-read-recovery.test.js +92 -0
- package/node_modules/@cchistory/live-runtime/dist/live-read-recovery.test.js.map +1 -0
- 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 +22 -22
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.d.ts.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.js +53 -47
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.test.js +287 -83
- 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 +171 -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 +81 -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/jsonl-records.test.js +31 -1
- package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts +4 -3
- package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/parser.js +32 -13
- 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 +46 -45
- 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 +76 -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 +126 -55
- 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,564 @@
|
|
|
1
|
+
(function(root, factory) {
|
|
2
|
+
if (typeof module === 'object' && module.exports) {
|
|
3
|
+
module.exports = factory();
|
|
4
|
+
} else {
|
|
5
|
+
root.nearley = factory();
|
|
6
|
+
}
|
|
7
|
+
}(this, function() {
|
|
8
|
+
|
|
9
|
+
function Rule(name, symbols, postprocess) {
|
|
10
|
+
this.id = ++Rule.highestId;
|
|
11
|
+
this.name = name;
|
|
12
|
+
this.symbols = symbols; // a list of literal | regex class | nonterminal
|
|
13
|
+
this.postprocess = postprocess;
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
Rule.highestId = 0;
|
|
17
|
+
|
|
18
|
+
Rule.prototype.toString = function(withCursorAt) {
|
|
19
|
+
var symbolSequence = (typeof withCursorAt === "undefined")
|
|
20
|
+
? this.symbols.map(getSymbolShortDisplay).join(' ')
|
|
21
|
+
: ( this.symbols.slice(0, withCursorAt).map(getSymbolShortDisplay).join(' ')
|
|
22
|
+
+ " ● "
|
|
23
|
+
+ this.symbols.slice(withCursorAt).map(getSymbolShortDisplay).join(' ') );
|
|
24
|
+
return this.name + " → " + symbolSequence;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
// a State is a rule at a position from a given starting point in the input stream (reference)
|
|
29
|
+
function State(rule, dot, reference, wantedBy) {
|
|
30
|
+
this.rule = rule;
|
|
31
|
+
this.dot = dot;
|
|
32
|
+
this.reference = reference;
|
|
33
|
+
this.data = [];
|
|
34
|
+
this.wantedBy = wantedBy;
|
|
35
|
+
this.isComplete = this.dot === rule.symbols.length;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
State.prototype.toString = function() {
|
|
39
|
+
return "{" + this.rule.toString(this.dot) + "}, from: " + (this.reference || 0);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
State.prototype.nextState = function(child) {
|
|
43
|
+
var state = new State(this.rule, this.dot + 1, this.reference, this.wantedBy);
|
|
44
|
+
state.left = this;
|
|
45
|
+
state.right = child;
|
|
46
|
+
if (state.isComplete) {
|
|
47
|
+
state.data = state.build();
|
|
48
|
+
// Having right set here will prevent the right state and its children
|
|
49
|
+
// form being garbage collected
|
|
50
|
+
state.right = undefined;
|
|
51
|
+
}
|
|
52
|
+
return state;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
State.prototype.build = function() {
|
|
56
|
+
var children = [];
|
|
57
|
+
var node = this;
|
|
58
|
+
do {
|
|
59
|
+
children.push(node.right.data);
|
|
60
|
+
node = node.left;
|
|
61
|
+
} while (node.left);
|
|
62
|
+
children.reverse();
|
|
63
|
+
return children;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
State.prototype.finish = function() {
|
|
67
|
+
if (this.rule.postprocess) {
|
|
68
|
+
this.data = this.rule.postprocess(this.data, this.reference, Parser.fail);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
function Column(grammar, index) {
|
|
74
|
+
this.grammar = grammar;
|
|
75
|
+
this.index = index;
|
|
76
|
+
this.states = [];
|
|
77
|
+
this.wants = {}; // states indexed by the non-terminal they expect
|
|
78
|
+
this.scannable = []; // list of states that expect a token
|
|
79
|
+
this.completed = {}; // states that are nullable
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
Column.prototype.process = function(nextColumn) {
|
|
84
|
+
var states = this.states;
|
|
85
|
+
var wants = this.wants;
|
|
86
|
+
var completed = this.completed;
|
|
87
|
+
|
|
88
|
+
for (var w = 0; w < states.length; w++) { // nb. we push() during iteration
|
|
89
|
+
var state = states[w];
|
|
90
|
+
|
|
91
|
+
if (state.isComplete) {
|
|
92
|
+
state.finish();
|
|
93
|
+
if (state.data !== Parser.fail) {
|
|
94
|
+
// complete
|
|
95
|
+
var wantedBy = state.wantedBy;
|
|
96
|
+
for (var i = wantedBy.length; i--; ) { // this line is hot
|
|
97
|
+
var left = wantedBy[i];
|
|
98
|
+
this.complete(left, state);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// special-case nullables
|
|
102
|
+
if (state.reference === this.index) {
|
|
103
|
+
// make sure future predictors of this rule get completed.
|
|
104
|
+
var exp = state.rule.name;
|
|
105
|
+
(this.completed[exp] = this.completed[exp] || []).push(state);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
} else {
|
|
110
|
+
// queue scannable states
|
|
111
|
+
var exp = state.rule.symbols[state.dot];
|
|
112
|
+
if (typeof exp !== 'string') {
|
|
113
|
+
this.scannable.push(state);
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// predict
|
|
118
|
+
if (wants[exp]) {
|
|
119
|
+
wants[exp].push(state);
|
|
120
|
+
|
|
121
|
+
if (completed.hasOwnProperty(exp)) {
|
|
122
|
+
var nulls = completed[exp];
|
|
123
|
+
for (var i = 0; i < nulls.length; i++) {
|
|
124
|
+
var right = nulls[i];
|
|
125
|
+
this.complete(state, right);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
wants[exp] = [state];
|
|
130
|
+
this.predict(exp);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
Column.prototype.predict = function(exp) {
|
|
137
|
+
var rules = this.grammar.byName[exp] || [];
|
|
138
|
+
|
|
139
|
+
for (var i = 0; i < rules.length; i++) {
|
|
140
|
+
var r = rules[i];
|
|
141
|
+
var wantedBy = this.wants[exp];
|
|
142
|
+
var s = new State(r, 0, this.index, wantedBy);
|
|
143
|
+
this.states.push(s);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
Column.prototype.complete = function(left, right) {
|
|
148
|
+
var copy = left.nextState(right);
|
|
149
|
+
this.states.push(copy);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
function Grammar(rules, start) {
|
|
154
|
+
this.rules = rules;
|
|
155
|
+
this.start = start || this.rules[0].name;
|
|
156
|
+
var byName = this.byName = {};
|
|
157
|
+
this.rules.forEach(function(rule) {
|
|
158
|
+
if (!byName.hasOwnProperty(rule.name)) {
|
|
159
|
+
byName[rule.name] = [];
|
|
160
|
+
}
|
|
161
|
+
byName[rule.name].push(rule);
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// So we can allow passing (rules, start) directly to Parser for backwards compatibility
|
|
166
|
+
Grammar.fromCompiled = function(rules, start) {
|
|
167
|
+
var lexer = rules.Lexer;
|
|
168
|
+
if (rules.ParserStart) {
|
|
169
|
+
start = rules.ParserStart;
|
|
170
|
+
rules = rules.ParserRules;
|
|
171
|
+
}
|
|
172
|
+
var rules = rules.map(function (r) { return (new Rule(r.name, r.symbols, r.postprocess)); });
|
|
173
|
+
var g = new Grammar(rules, start);
|
|
174
|
+
g.lexer = lexer; // nb. storing lexer on Grammar is iffy, but unavoidable
|
|
175
|
+
return g;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
function StreamLexer() {
|
|
180
|
+
this.reset("");
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
StreamLexer.prototype.reset = function(data, state) {
|
|
184
|
+
this.buffer = data;
|
|
185
|
+
this.index = 0;
|
|
186
|
+
this.line = state ? state.line : 1;
|
|
187
|
+
this.lastLineBreak = state ? -state.col : 0;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
StreamLexer.prototype.next = function() {
|
|
191
|
+
if (this.index < this.buffer.length) {
|
|
192
|
+
var ch = this.buffer[this.index++];
|
|
193
|
+
if (ch === '\n') {
|
|
194
|
+
this.line += 1;
|
|
195
|
+
this.lastLineBreak = this.index;
|
|
196
|
+
}
|
|
197
|
+
return {value: ch};
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
StreamLexer.prototype.save = function() {
|
|
202
|
+
return {
|
|
203
|
+
line: this.line,
|
|
204
|
+
col: this.index - this.lastLineBreak,
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
StreamLexer.prototype.formatError = function(token, message) {
|
|
209
|
+
// nb. this gets called after consuming the offending token,
|
|
210
|
+
// so the culprit is index-1
|
|
211
|
+
var buffer = this.buffer;
|
|
212
|
+
if (typeof buffer === 'string') {
|
|
213
|
+
var lines = buffer
|
|
214
|
+
.split("\n")
|
|
215
|
+
.slice(
|
|
216
|
+
Math.max(0, this.line - 5),
|
|
217
|
+
this.line
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
var nextLineBreak = buffer.indexOf('\n', this.index);
|
|
221
|
+
if (nextLineBreak === -1) nextLineBreak = buffer.length;
|
|
222
|
+
var col = this.index - this.lastLineBreak;
|
|
223
|
+
var lastLineDigits = String(this.line).length;
|
|
224
|
+
message += " at line " + this.line + " col " + col + ":\n\n";
|
|
225
|
+
message += lines
|
|
226
|
+
.map(function(line, i) {
|
|
227
|
+
return pad(this.line - lines.length + i + 1, lastLineDigits) + " " + line;
|
|
228
|
+
}, this)
|
|
229
|
+
.join("\n");
|
|
230
|
+
message += "\n" + pad("", lastLineDigits + col) + "^\n";
|
|
231
|
+
return message;
|
|
232
|
+
} else {
|
|
233
|
+
return message + " at index " + (this.index - 1);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function pad(n, length) {
|
|
237
|
+
var s = String(n);
|
|
238
|
+
return Array(length - s.length + 1).join(" ") + s;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function Parser(rules, start, options) {
|
|
243
|
+
if (rules instanceof Grammar) {
|
|
244
|
+
var grammar = rules;
|
|
245
|
+
var options = start;
|
|
246
|
+
} else {
|
|
247
|
+
var grammar = Grammar.fromCompiled(rules, start);
|
|
248
|
+
}
|
|
249
|
+
this.grammar = grammar;
|
|
250
|
+
|
|
251
|
+
// Read options
|
|
252
|
+
this.options = {
|
|
253
|
+
keepHistory: false,
|
|
254
|
+
lexer: grammar.lexer || new StreamLexer,
|
|
255
|
+
};
|
|
256
|
+
for (var key in (options || {})) {
|
|
257
|
+
this.options[key] = options[key];
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Setup lexer
|
|
261
|
+
this.lexer = this.options.lexer;
|
|
262
|
+
this.lexerState = undefined;
|
|
263
|
+
|
|
264
|
+
// Setup a table
|
|
265
|
+
var column = new Column(grammar, 0);
|
|
266
|
+
var table = this.table = [column];
|
|
267
|
+
|
|
268
|
+
// I could be expecting anything.
|
|
269
|
+
column.wants[grammar.start] = [];
|
|
270
|
+
column.predict(grammar.start);
|
|
271
|
+
// TODO what if start rule is nullable?
|
|
272
|
+
column.process();
|
|
273
|
+
this.current = 0; // token index
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// create a reserved token for indicating a parse fail
|
|
277
|
+
Parser.fail = {};
|
|
278
|
+
|
|
279
|
+
Parser.prototype.feed = function(chunk) {
|
|
280
|
+
var lexer = this.lexer;
|
|
281
|
+
lexer.reset(chunk, this.lexerState);
|
|
282
|
+
|
|
283
|
+
var token;
|
|
284
|
+
while (true) {
|
|
285
|
+
try {
|
|
286
|
+
token = lexer.next();
|
|
287
|
+
if (!token) {
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
} catch (e) {
|
|
291
|
+
// Create the next column so that the error reporter
|
|
292
|
+
// can display the correctly predicted states.
|
|
293
|
+
var nextColumn = new Column(this.grammar, this.current + 1);
|
|
294
|
+
this.table.push(nextColumn);
|
|
295
|
+
var err = new Error(this.reportLexerError(e));
|
|
296
|
+
err.offset = this.current;
|
|
297
|
+
err.token = e.token;
|
|
298
|
+
throw err;
|
|
299
|
+
}
|
|
300
|
+
// We add new states to table[current+1]
|
|
301
|
+
var column = this.table[this.current];
|
|
302
|
+
|
|
303
|
+
// GC unused states
|
|
304
|
+
if (!this.options.keepHistory) {
|
|
305
|
+
delete this.table[this.current - 1];
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
var n = this.current + 1;
|
|
309
|
+
var nextColumn = new Column(this.grammar, n);
|
|
310
|
+
this.table.push(nextColumn);
|
|
311
|
+
|
|
312
|
+
// Advance all tokens that expect the symbol
|
|
313
|
+
var literal = token.text !== undefined ? token.text : token.value;
|
|
314
|
+
var value = lexer.constructor === StreamLexer ? token.value : token;
|
|
315
|
+
var scannable = column.scannable;
|
|
316
|
+
for (var w = scannable.length; w--; ) {
|
|
317
|
+
var state = scannable[w];
|
|
318
|
+
var expect = state.rule.symbols[state.dot];
|
|
319
|
+
// Try to consume the token
|
|
320
|
+
// either regex or literal
|
|
321
|
+
if (expect.test ? expect.test(value) :
|
|
322
|
+
expect.type ? expect.type === token.type
|
|
323
|
+
: expect.literal === literal) {
|
|
324
|
+
// Add it
|
|
325
|
+
var next = state.nextState({data: value, token: token, isToken: true, reference: n - 1});
|
|
326
|
+
nextColumn.states.push(next);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// Next, for each of the rules, we either
|
|
331
|
+
// (a) complete it, and try to see if the reference row expected that
|
|
332
|
+
// rule
|
|
333
|
+
// (b) predict the next nonterminal it expects by adding that
|
|
334
|
+
// nonterminal's start state
|
|
335
|
+
// To prevent duplication, we also keep track of rules we have already
|
|
336
|
+
// added
|
|
337
|
+
|
|
338
|
+
nextColumn.process();
|
|
339
|
+
|
|
340
|
+
// If needed, throw an error:
|
|
341
|
+
if (nextColumn.states.length === 0) {
|
|
342
|
+
// No states at all! This is not good.
|
|
343
|
+
var err = new Error(this.reportError(token));
|
|
344
|
+
err.offset = this.current;
|
|
345
|
+
err.token = token;
|
|
346
|
+
throw err;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// maybe save lexer state
|
|
350
|
+
if (this.options.keepHistory) {
|
|
351
|
+
column.lexerState = lexer.save()
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
this.current++;
|
|
355
|
+
}
|
|
356
|
+
if (column) {
|
|
357
|
+
this.lexerState = lexer.save()
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// Incrementally keep track of results
|
|
361
|
+
this.results = this.finish();
|
|
362
|
+
|
|
363
|
+
// Allow chaining, for whatever it's worth
|
|
364
|
+
return this;
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
Parser.prototype.reportLexerError = function(lexerError) {
|
|
368
|
+
var tokenDisplay, lexerMessage;
|
|
369
|
+
// Planning to add a token property to moo's thrown error
|
|
370
|
+
// even on erroring tokens to be used in error display below
|
|
371
|
+
var token = lexerError.token;
|
|
372
|
+
if (token) {
|
|
373
|
+
tokenDisplay = "input " + JSON.stringify(token.text[0]) + " (lexer error)";
|
|
374
|
+
lexerMessage = this.lexer.formatError(token, "Syntax error");
|
|
375
|
+
} else {
|
|
376
|
+
tokenDisplay = "input (lexer error)";
|
|
377
|
+
lexerMessage = lexerError.message;
|
|
378
|
+
}
|
|
379
|
+
return this.reportErrorCommon(lexerMessage, tokenDisplay);
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
Parser.prototype.reportError = function(token) {
|
|
383
|
+
var tokenDisplay = (token.type ? token.type + " token: " : "") + JSON.stringify(token.value !== undefined ? token.value : token);
|
|
384
|
+
var lexerMessage = this.lexer.formatError(token, "Syntax error");
|
|
385
|
+
return this.reportErrorCommon(lexerMessage, tokenDisplay);
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
Parser.prototype.reportErrorCommon = function(lexerMessage, tokenDisplay) {
|
|
389
|
+
var lines = [];
|
|
390
|
+
lines.push(lexerMessage);
|
|
391
|
+
var lastColumnIndex = this.table.length - 2;
|
|
392
|
+
var lastColumn = this.table[lastColumnIndex];
|
|
393
|
+
var expectantStates = lastColumn.states
|
|
394
|
+
.filter(function(state) {
|
|
395
|
+
var nextSymbol = state.rule.symbols[state.dot];
|
|
396
|
+
return nextSymbol && typeof nextSymbol !== "string";
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
if (expectantStates.length === 0) {
|
|
400
|
+
lines.push('Unexpected ' + tokenDisplay + '. I did not expect any more input. Here is the state of my parse table:\n');
|
|
401
|
+
this.displayStateStack(lastColumn.states, lines);
|
|
402
|
+
} else {
|
|
403
|
+
lines.push('Unexpected ' + tokenDisplay + '. Instead, I was expecting to see one of the following:\n');
|
|
404
|
+
// Display a "state stack" for each expectant state
|
|
405
|
+
// - which shows you how this state came to be, step by step.
|
|
406
|
+
// If there is more than one derivation, we only display the first one.
|
|
407
|
+
var stateStacks = expectantStates
|
|
408
|
+
.map(function(state) {
|
|
409
|
+
return this.buildFirstStateStack(state, []) || [state];
|
|
410
|
+
}, this);
|
|
411
|
+
// Display each state that is expecting a terminal symbol next.
|
|
412
|
+
stateStacks.forEach(function(stateStack) {
|
|
413
|
+
var state = stateStack[0];
|
|
414
|
+
var nextSymbol = state.rule.symbols[state.dot];
|
|
415
|
+
var symbolDisplay = this.getSymbolDisplay(nextSymbol);
|
|
416
|
+
lines.push('A ' + symbolDisplay + ' based on:');
|
|
417
|
+
this.displayStateStack(stateStack, lines);
|
|
418
|
+
}, this);
|
|
419
|
+
}
|
|
420
|
+
lines.push("");
|
|
421
|
+
return lines.join("\n");
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
Parser.prototype.displayStateStack = function(stateStack, lines) {
|
|
425
|
+
var lastDisplay;
|
|
426
|
+
var sameDisplayCount = 0;
|
|
427
|
+
for (var j = 0; j < stateStack.length; j++) {
|
|
428
|
+
var state = stateStack[j];
|
|
429
|
+
var display = state.rule.toString(state.dot);
|
|
430
|
+
if (display === lastDisplay) {
|
|
431
|
+
sameDisplayCount++;
|
|
432
|
+
} else {
|
|
433
|
+
if (sameDisplayCount > 0) {
|
|
434
|
+
lines.push(' ^ ' + sameDisplayCount + ' more lines identical to this');
|
|
435
|
+
}
|
|
436
|
+
sameDisplayCount = 0;
|
|
437
|
+
lines.push(' ' + display);
|
|
438
|
+
}
|
|
439
|
+
lastDisplay = display;
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
Parser.prototype.getSymbolDisplay = function(symbol) {
|
|
444
|
+
return getSymbolLongDisplay(symbol);
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
/*
|
|
448
|
+
Builds a the first state stack. You can think of a state stack as the call stack
|
|
449
|
+
of the recursive-descent parser which the Nearley parse algorithm simulates.
|
|
450
|
+
A state stack is represented as an array of state objects. Within a
|
|
451
|
+
state stack, the first item of the array will be the starting
|
|
452
|
+
state, with each successive item in the array going further back into history.
|
|
453
|
+
|
|
454
|
+
This function needs to be given a starting state and an empty array representing
|
|
455
|
+
the visited states, and it returns an single state stack.
|
|
456
|
+
|
|
457
|
+
*/
|
|
458
|
+
Parser.prototype.buildFirstStateStack = function(state, visited) {
|
|
459
|
+
if (visited.indexOf(state) !== -1) {
|
|
460
|
+
// Found cycle, return null
|
|
461
|
+
// to eliminate this path from the results, because
|
|
462
|
+
// we don't know how to display it meaningfully
|
|
463
|
+
return null;
|
|
464
|
+
}
|
|
465
|
+
if (state.wantedBy.length === 0) {
|
|
466
|
+
return [state];
|
|
467
|
+
}
|
|
468
|
+
var prevState = state.wantedBy[0];
|
|
469
|
+
var childVisited = [state].concat(visited);
|
|
470
|
+
var childResult = this.buildFirstStateStack(prevState, childVisited);
|
|
471
|
+
if (childResult === null) {
|
|
472
|
+
return null;
|
|
473
|
+
}
|
|
474
|
+
return [state].concat(childResult);
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
Parser.prototype.save = function() {
|
|
478
|
+
var column = this.table[this.current];
|
|
479
|
+
column.lexerState = this.lexerState;
|
|
480
|
+
return column;
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
Parser.prototype.restore = function(column) {
|
|
484
|
+
var index = column.index;
|
|
485
|
+
this.current = index;
|
|
486
|
+
this.table[index] = column;
|
|
487
|
+
this.table.splice(index + 1);
|
|
488
|
+
this.lexerState = column.lexerState;
|
|
489
|
+
|
|
490
|
+
// Incrementally keep track of results
|
|
491
|
+
this.results = this.finish();
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
// nb. deprecated: use save/restore instead!
|
|
495
|
+
Parser.prototype.rewind = function(index) {
|
|
496
|
+
if (!this.options.keepHistory) {
|
|
497
|
+
throw new Error('set option `keepHistory` to enable rewinding')
|
|
498
|
+
}
|
|
499
|
+
// nb. recall column (table) indicies fall between token indicies.
|
|
500
|
+
// col 0 -- token 0 -- col 1
|
|
501
|
+
this.restore(this.table[index]);
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
Parser.prototype.finish = function() {
|
|
505
|
+
// Return the possible parsings
|
|
506
|
+
var considerations = [];
|
|
507
|
+
var start = this.grammar.start;
|
|
508
|
+
var column = this.table[this.table.length - 1]
|
|
509
|
+
column.states.forEach(function (t) {
|
|
510
|
+
if (t.rule.name === start
|
|
511
|
+
&& t.dot === t.rule.symbols.length
|
|
512
|
+
&& t.reference === 0
|
|
513
|
+
&& t.data !== Parser.fail) {
|
|
514
|
+
considerations.push(t);
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
return considerations.map(function(c) {return c.data; });
|
|
518
|
+
};
|
|
519
|
+
|
|
520
|
+
function getSymbolLongDisplay(symbol) {
|
|
521
|
+
var type = typeof symbol;
|
|
522
|
+
if (type === "string") {
|
|
523
|
+
return symbol;
|
|
524
|
+
} else if (type === "object") {
|
|
525
|
+
if (symbol.literal) {
|
|
526
|
+
return JSON.stringify(symbol.literal);
|
|
527
|
+
} else if (symbol instanceof RegExp) {
|
|
528
|
+
return 'character matching ' + symbol;
|
|
529
|
+
} else if (symbol.type) {
|
|
530
|
+
return symbol.type + ' token';
|
|
531
|
+
} else if (symbol.test) {
|
|
532
|
+
return 'token matching ' + String(symbol.test);
|
|
533
|
+
} else {
|
|
534
|
+
throw new Error('Unknown symbol type: ' + symbol);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
function getSymbolShortDisplay(symbol) {
|
|
540
|
+
var type = typeof symbol;
|
|
541
|
+
if (type === "string") {
|
|
542
|
+
return symbol;
|
|
543
|
+
} else if (type === "object") {
|
|
544
|
+
if (symbol.literal) {
|
|
545
|
+
return JSON.stringify(symbol.literal);
|
|
546
|
+
} else if (symbol instanceof RegExp) {
|
|
547
|
+
return symbol.toString();
|
|
548
|
+
} else if (symbol.type) {
|
|
549
|
+
return '%' + symbol.type;
|
|
550
|
+
} else if (symbol.test) {
|
|
551
|
+
return '<' + String(symbol.test) + '>';
|
|
552
|
+
} else {
|
|
553
|
+
throw new Error('Unknown symbol type: ' + symbol);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
return {
|
|
559
|
+
Parser: Parser,
|
|
560
|
+
Grammar: Grammar,
|
|
561
|
+
Rule: Rule,
|
|
562
|
+
};
|
|
563
|
+
|
|
564
|
+
}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Node-only
|
|
2
|
+
|
|
3
|
+
var Writable = require('stream').Writable;
|
|
4
|
+
var util = require('util');
|
|
5
|
+
|
|
6
|
+
function StreamWrapper(parser) {
|
|
7
|
+
Writable.call(this);
|
|
8
|
+
this._parser = parser;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
util.inherits(StreamWrapper, Writable);
|
|
12
|
+
|
|
13
|
+
StreamWrapper.prototype._write = function write(chunk, encoding, callback) {
|
|
14
|
+
this._parser.feed(chunk.toString());
|
|
15
|
+
callback();
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
module.exports = StreamWrapper;
|