@cchistory/lite 0.4.5 → 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 +32 -25
- 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 +147 -66
- package/apps/lite-cli/dist/index.js.map +1 -1
- package/apps/lite-cli/dist/index.test.js +76 -60
- 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 -46
- package/docs/guide/lite.md +49 -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 +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 -142
- 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 +21 -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 -41
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.test.js +266 -57
- 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 -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,645 @@
|
|
|
1
|
+
(function(root, factory) {
|
|
2
|
+
if (typeof define === 'function' && define.amd) {
|
|
3
|
+
define([], factory) /* global define */
|
|
4
|
+
} else if (typeof module === 'object' && module.exports) {
|
|
5
|
+
module.exports = factory()
|
|
6
|
+
} else {
|
|
7
|
+
root.moo = factory()
|
|
8
|
+
}
|
|
9
|
+
}(this, function() {
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty
|
|
13
|
+
var toString = Object.prototype.toString
|
|
14
|
+
var hasSticky = typeof new RegExp().sticky === 'boolean'
|
|
15
|
+
|
|
16
|
+
/***************************************************************************/
|
|
17
|
+
|
|
18
|
+
function isRegExp(o) { return o && toString.call(o) === '[object RegExp]' }
|
|
19
|
+
function isObject(o) { return o && typeof o === 'object' && !isRegExp(o) && !Array.isArray(o) }
|
|
20
|
+
|
|
21
|
+
function reEscape(s) {
|
|
22
|
+
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, function(x) {
|
|
23
|
+
if (x === '-') return '\\x2d'
|
|
24
|
+
return '\\' + x
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
function reGroups(s) {
|
|
28
|
+
var re = new RegExp('|' + s)
|
|
29
|
+
return re.exec('').length - 1
|
|
30
|
+
}
|
|
31
|
+
function reCapture(s) {
|
|
32
|
+
return '(' + s + ')'
|
|
33
|
+
}
|
|
34
|
+
function reUnion(regexps) {
|
|
35
|
+
if (!regexps.length) return '(?!)'
|
|
36
|
+
var source = regexps.map(function(s) {
|
|
37
|
+
return "(?:" + s + ")"
|
|
38
|
+
}).join('|')
|
|
39
|
+
return "(?:" + source + ")"
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function regexpOrLiteral(obj) {
|
|
43
|
+
if (typeof obj === 'string') {
|
|
44
|
+
return '(?:' + reEscape(obj) + ')'
|
|
45
|
+
|
|
46
|
+
} else if (isRegExp(obj)) {
|
|
47
|
+
// TODO: consider /u support
|
|
48
|
+
if (obj.ignoreCase) throw new Error('RegExp /i flag not allowed')
|
|
49
|
+
if (obj.global) throw new Error('RegExp /g flag is implied')
|
|
50
|
+
if (obj.sticky) throw new Error('RegExp /y flag is implied')
|
|
51
|
+
if (obj.multiline) throw new Error('RegExp /m flag is implied')
|
|
52
|
+
return obj.source
|
|
53
|
+
|
|
54
|
+
} else {
|
|
55
|
+
throw new Error('Not a pattern: ' + obj)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function pad(s, length) {
|
|
60
|
+
if (s.length > length) {
|
|
61
|
+
return s
|
|
62
|
+
}
|
|
63
|
+
return Array(length - s.length + 1).join(" ") + s
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function lastNLines(string, numLines) {
|
|
67
|
+
var position = string.length
|
|
68
|
+
var lineBreaks = 0;
|
|
69
|
+
while (true) {
|
|
70
|
+
var idx = string.lastIndexOf("\n", position - 1)
|
|
71
|
+
if (idx === -1) {
|
|
72
|
+
break;
|
|
73
|
+
} else {
|
|
74
|
+
lineBreaks++
|
|
75
|
+
}
|
|
76
|
+
position = idx
|
|
77
|
+
if (lineBreaks === numLines) {
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
if (position === 0) {
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
var startPosition =
|
|
85
|
+
lineBreaks < numLines ?
|
|
86
|
+
0 :
|
|
87
|
+
position + 1
|
|
88
|
+
return string.substring(startPosition).split("\n")
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function objectToRules(object) {
|
|
92
|
+
var keys = Object.getOwnPropertyNames(object)
|
|
93
|
+
var result = []
|
|
94
|
+
for (var i = 0; i < keys.length; i++) {
|
|
95
|
+
var key = keys[i]
|
|
96
|
+
var thing = object[key]
|
|
97
|
+
var rules = [].concat(thing)
|
|
98
|
+
if (key === 'include') {
|
|
99
|
+
for (var j = 0; j < rules.length; j++) {
|
|
100
|
+
result.push({include: rules[j]})
|
|
101
|
+
}
|
|
102
|
+
continue
|
|
103
|
+
}
|
|
104
|
+
var match = []
|
|
105
|
+
rules.forEach(function(rule) {
|
|
106
|
+
if (isObject(rule)) {
|
|
107
|
+
if (match.length) result.push(ruleOptions(key, match))
|
|
108
|
+
result.push(ruleOptions(key, rule))
|
|
109
|
+
match = []
|
|
110
|
+
} else {
|
|
111
|
+
match.push(rule)
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
if (match.length) result.push(ruleOptions(key, match))
|
|
115
|
+
}
|
|
116
|
+
return result
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function arrayToRules(array) {
|
|
120
|
+
var result = []
|
|
121
|
+
for (var i = 0; i < array.length; i++) {
|
|
122
|
+
var obj = array[i]
|
|
123
|
+
if (obj.include) {
|
|
124
|
+
var include = [].concat(obj.include)
|
|
125
|
+
for (var j = 0; j < include.length; j++) {
|
|
126
|
+
result.push({include: include[j]})
|
|
127
|
+
}
|
|
128
|
+
continue
|
|
129
|
+
}
|
|
130
|
+
if (!obj.type) {
|
|
131
|
+
throw new Error('Rule has no type: ' + JSON.stringify(obj))
|
|
132
|
+
}
|
|
133
|
+
result.push(ruleOptions(obj.type, obj))
|
|
134
|
+
}
|
|
135
|
+
return result
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function ruleOptions(type, obj) {
|
|
139
|
+
if (!isObject(obj)) {
|
|
140
|
+
obj = { match: obj }
|
|
141
|
+
}
|
|
142
|
+
if (obj.include) {
|
|
143
|
+
throw new Error('Matching rules cannot also include states')
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// nb. error and fallback imply lineBreaks
|
|
147
|
+
var options = {
|
|
148
|
+
defaultType: type,
|
|
149
|
+
lineBreaks: !!obj.error || !!obj.fallback,
|
|
150
|
+
pop: false,
|
|
151
|
+
next: null,
|
|
152
|
+
push: null,
|
|
153
|
+
error: false,
|
|
154
|
+
fallback: false,
|
|
155
|
+
value: null,
|
|
156
|
+
type: null,
|
|
157
|
+
shouldThrow: false,
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Avoid Object.assign(), so we support IE9+
|
|
161
|
+
for (var key in obj) {
|
|
162
|
+
if (hasOwnProperty.call(obj, key)) {
|
|
163
|
+
options[key] = obj[key]
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// type transform cannot be a string
|
|
168
|
+
if (typeof options.type === 'string' && type !== options.type) {
|
|
169
|
+
throw new Error("Type transform cannot be a string (type '" + options.type + "' for token '" + type + "')")
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// convert to array
|
|
173
|
+
var match = options.match
|
|
174
|
+
options.match = Array.isArray(match) ? match : match ? [match] : []
|
|
175
|
+
options.match.sort(function(a, b) {
|
|
176
|
+
return isRegExp(a) && isRegExp(b) ? 0
|
|
177
|
+
: isRegExp(b) ? -1 : isRegExp(a) ? +1 : b.length - a.length
|
|
178
|
+
})
|
|
179
|
+
return options
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function toRules(spec) {
|
|
183
|
+
return Array.isArray(spec) ? arrayToRules(spec) : objectToRules(spec)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
var defaultErrorRule = ruleOptions('error', {lineBreaks: true, shouldThrow: true})
|
|
187
|
+
function compileRules(rules, hasStates) {
|
|
188
|
+
var errorRule = null
|
|
189
|
+
var fast = Object.create(null)
|
|
190
|
+
var fastAllowed = true
|
|
191
|
+
var unicodeFlag = null
|
|
192
|
+
var groups = []
|
|
193
|
+
var parts = []
|
|
194
|
+
|
|
195
|
+
// If there is a fallback rule, then disable fast matching
|
|
196
|
+
for (var i = 0; i < rules.length; i++) {
|
|
197
|
+
if (rules[i].fallback) {
|
|
198
|
+
fastAllowed = false
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
for (var i = 0; i < rules.length; i++) {
|
|
203
|
+
var options = rules[i]
|
|
204
|
+
|
|
205
|
+
if (options.include) {
|
|
206
|
+
// all valid inclusions are removed by states() preprocessor
|
|
207
|
+
throw new Error('Inheritance is not allowed in stateless lexers')
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (options.error || options.fallback) {
|
|
211
|
+
// errorRule can only be set once
|
|
212
|
+
if (errorRule) {
|
|
213
|
+
if (!options.fallback === !errorRule.fallback) {
|
|
214
|
+
throw new Error("Multiple " + (options.fallback ? "fallback" : "error") + " rules not allowed (for token '" + options.defaultType + "')")
|
|
215
|
+
} else {
|
|
216
|
+
throw new Error("fallback and error are mutually exclusive (for token '" + options.defaultType + "')")
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
errorRule = options
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
var match = options.match.slice()
|
|
223
|
+
if (fastAllowed) {
|
|
224
|
+
while (match.length && typeof match[0] === 'string' && match[0].length === 1) {
|
|
225
|
+
var word = match.shift()
|
|
226
|
+
fast[word.charCodeAt(0)] = options
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// Warn about inappropriate state-switching options
|
|
231
|
+
if (options.pop || options.push || options.next) {
|
|
232
|
+
if (!hasStates) {
|
|
233
|
+
throw new Error("State-switching options are not allowed in stateless lexers (for token '" + options.defaultType + "')")
|
|
234
|
+
}
|
|
235
|
+
if (options.fallback) {
|
|
236
|
+
throw new Error("State-switching options are not allowed on fallback tokens (for token '" + options.defaultType + "')")
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Only rules with a .match are included in the RegExp
|
|
241
|
+
if (match.length === 0) {
|
|
242
|
+
continue
|
|
243
|
+
}
|
|
244
|
+
fastAllowed = false
|
|
245
|
+
|
|
246
|
+
groups.push(options)
|
|
247
|
+
|
|
248
|
+
// Check unicode flag is used everywhere or nowhere
|
|
249
|
+
for (var j = 0; j < match.length; j++) {
|
|
250
|
+
var obj = match[j]
|
|
251
|
+
if (!isRegExp(obj)) {
|
|
252
|
+
continue
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (unicodeFlag === null) {
|
|
256
|
+
unicodeFlag = obj.unicode
|
|
257
|
+
} else if (unicodeFlag !== obj.unicode && options.fallback === false) {
|
|
258
|
+
throw new Error('If one rule is /u then all must be')
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// convert to RegExp
|
|
263
|
+
var pat = reUnion(match.map(regexpOrLiteral))
|
|
264
|
+
|
|
265
|
+
// validate
|
|
266
|
+
var regexp = new RegExp(pat)
|
|
267
|
+
if (regexp.test("")) {
|
|
268
|
+
throw new Error("RegExp matches empty string: " + regexp)
|
|
269
|
+
}
|
|
270
|
+
var groupCount = reGroups(pat)
|
|
271
|
+
if (groupCount > 0) {
|
|
272
|
+
throw new Error("RegExp has capture groups: " + regexp + "\nUse (?: … ) instead")
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// try and detect rules matching newlines
|
|
276
|
+
if (!options.lineBreaks && regexp.test('\n')) {
|
|
277
|
+
throw new Error('Rule should declare lineBreaks: ' + regexp)
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// store regex
|
|
281
|
+
parts.push(reCapture(pat))
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
// If there's no fallback rule, use the sticky flag so we only look for
|
|
286
|
+
// matches at the current index.
|
|
287
|
+
//
|
|
288
|
+
// If we don't support the sticky flag, then fake it using an irrefutable
|
|
289
|
+
// match (i.e. an empty pattern).
|
|
290
|
+
var fallbackRule = errorRule && errorRule.fallback
|
|
291
|
+
var flags = hasSticky && !fallbackRule ? 'ym' : 'gm'
|
|
292
|
+
var suffix = hasSticky || fallbackRule ? '' : '|'
|
|
293
|
+
|
|
294
|
+
if (unicodeFlag === true) flags += "u"
|
|
295
|
+
var combined = new RegExp(reUnion(parts) + suffix, flags)
|
|
296
|
+
return {regexp: combined, groups: groups, fast: fast, error: errorRule || defaultErrorRule}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function compile(rules) {
|
|
300
|
+
var result = compileRules(toRules(rules))
|
|
301
|
+
return new Lexer({start: result}, 'start')
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function checkStateGroup(g, name, map) {
|
|
305
|
+
var state = g && (g.push || g.next)
|
|
306
|
+
if (state && !map[state]) {
|
|
307
|
+
throw new Error("Missing state '" + state + "' (in token '" + g.defaultType + "' of state '" + name + "')")
|
|
308
|
+
}
|
|
309
|
+
if (g && g.pop && +g.pop !== 1) {
|
|
310
|
+
throw new Error("pop must be 1 (in token '" + g.defaultType + "' of state '" + name + "')")
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
function compileStates(states, start) {
|
|
314
|
+
var all = states.$all ? toRules(states.$all) : []
|
|
315
|
+
delete states.$all
|
|
316
|
+
|
|
317
|
+
var keys = Object.getOwnPropertyNames(states)
|
|
318
|
+
if (!start) start = keys[0]
|
|
319
|
+
|
|
320
|
+
var ruleMap = Object.create(null)
|
|
321
|
+
for (var i = 0; i < keys.length; i++) {
|
|
322
|
+
var key = keys[i]
|
|
323
|
+
ruleMap[key] = toRules(states[key]).concat(all)
|
|
324
|
+
}
|
|
325
|
+
for (var i = 0; i < keys.length; i++) {
|
|
326
|
+
var key = keys[i]
|
|
327
|
+
var rules = ruleMap[key]
|
|
328
|
+
var included = Object.create(null)
|
|
329
|
+
for (var j = 0; j < rules.length; j++) {
|
|
330
|
+
var rule = rules[j]
|
|
331
|
+
if (!rule.include) continue
|
|
332
|
+
var splice = [j, 1]
|
|
333
|
+
if (rule.include !== key && !included[rule.include]) {
|
|
334
|
+
included[rule.include] = true
|
|
335
|
+
var newRules = ruleMap[rule.include]
|
|
336
|
+
if (!newRules) {
|
|
337
|
+
throw new Error("Cannot include nonexistent state '" + rule.include + "' (in state '" + key + "')")
|
|
338
|
+
}
|
|
339
|
+
for (var k = 0; k < newRules.length; k++) {
|
|
340
|
+
var newRule = newRules[k]
|
|
341
|
+
if (rules.indexOf(newRule) !== -1) continue
|
|
342
|
+
splice.push(newRule)
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
rules.splice.apply(rules, splice)
|
|
346
|
+
j--
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
var map = Object.create(null)
|
|
351
|
+
for (var i = 0; i < keys.length; i++) {
|
|
352
|
+
var key = keys[i]
|
|
353
|
+
map[key] = compileRules(ruleMap[key], true)
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
for (var i = 0; i < keys.length; i++) {
|
|
357
|
+
var name = keys[i]
|
|
358
|
+
var state = map[name]
|
|
359
|
+
var groups = state.groups
|
|
360
|
+
for (var j = 0; j < groups.length; j++) {
|
|
361
|
+
checkStateGroup(groups[j], name, map)
|
|
362
|
+
}
|
|
363
|
+
var fastKeys = Object.getOwnPropertyNames(state.fast)
|
|
364
|
+
for (var j = 0; j < fastKeys.length; j++) {
|
|
365
|
+
checkStateGroup(state.fast[fastKeys[j]], name, map)
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
return new Lexer(map, start)
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function keywordTransform(map) {
|
|
373
|
+
|
|
374
|
+
// Use a JavaScript Map to map keywords to their corresponding token type
|
|
375
|
+
// unless Map is unsupported, then fall back to using an Object:
|
|
376
|
+
var isMap = typeof Map !== 'undefined'
|
|
377
|
+
var reverseMap = isMap ? new Map : Object.create(null)
|
|
378
|
+
|
|
379
|
+
var types = Object.getOwnPropertyNames(map)
|
|
380
|
+
for (var i = 0; i < types.length; i++) {
|
|
381
|
+
var tokenType = types[i]
|
|
382
|
+
var item = map[tokenType]
|
|
383
|
+
var keywordList = Array.isArray(item) ? item : [item]
|
|
384
|
+
keywordList.forEach(function(keyword) {
|
|
385
|
+
if (typeof keyword !== 'string') {
|
|
386
|
+
throw new Error("keyword must be string (in keyword '" + tokenType + "')")
|
|
387
|
+
}
|
|
388
|
+
if (isMap) {
|
|
389
|
+
reverseMap.set(keyword, tokenType)
|
|
390
|
+
} else {
|
|
391
|
+
reverseMap[keyword] = tokenType
|
|
392
|
+
}
|
|
393
|
+
})
|
|
394
|
+
}
|
|
395
|
+
return function(k) {
|
|
396
|
+
return isMap ? reverseMap.get(k) : reverseMap[k]
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/***************************************************************************/
|
|
401
|
+
|
|
402
|
+
var Lexer = function(states, state) {
|
|
403
|
+
this.startState = state
|
|
404
|
+
this.states = states
|
|
405
|
+
this.buffer = ''
|
|
406
|
+
this.stack = []
|
|
407
|
+
this.reset()
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
Lexer.prototype.reset = function(data, info) {
|
|
411
|
+
this.buffer = data || ''
|
|
412
|
+
this.index = 0
|
|
413
|
+
this.line = info ? info.line : 1
|
|
414
|
+
this.col = info ? info.col : 1
|
|
415
|
+
this.queuedToken = info ? info.queuedToken : null
|
|
416
|
+
this.queuedText = info ? info.queuedText: "";
|
|
417
|
+
this.queuedThrow = info ? info.queuedThrow : null
|
|
418
|
+
this.setState(info ? info.state : this.startState)
|
|
419
|
+
this.stack = info && info.stack ? info.stack.slice() : []
|
|
420
|
+
return this
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
Lexer.prototype.save = function() {
|
|
424
|
+
return {
|
|
425
|
+
line: this.line,
|
|
426
|
+
col: this.col,
|
|
427
|
+
state: this.state,
|
|
428
|
+
stack: this.stack.slice(),
|
|
429
|
+
queuedToken: this.queuedToken,
|
|
430
|
+
queuedText: this.queuedText,
|
|
431
|
+
queuedThrow: this.queuedThrow,
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
Lexer.prototype.setState = function(state) {
|
|
436
|
+
if (!state || this.state === state) return
|
|
437
|
+
this.state = state
|
|
438
|
+
var info = this.states[state]
|
|
439
|
+
this.groups = info.groups
|
|
440
|
+
this.error = info.error
|
|
441
|
+
this.re = info.regexp
|
|
442
|
+
this.fast = info.fast
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
Lexer.prototype.popState = function() {
|
|
446
|
+
this.setState(this.stack.pop())
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
Lexer.prototype.pushState = function(state) {
|
|
450
|
+
this.stack.push(this.state)
|
|
451
|
+
this.setState(state)
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
var eat = hasSticky ? function(re, buffer) { // assume re is /y
|
|
455
|
+
return re.exec(buffer)
|
|
456
|
+
} : function(re, buffer) { // assume re is /g
|
|
457
|
+
var match = re.exec(buffer)
|
|
458
|
+
// will always match, since we used the |(?:) trick
|
|
459
|
+
if (match[0].length === 0) {
|
|
460
|
+
return null
|
|
461
|
+
}
|
|
462
|
+
return match
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
Lexer.prototype._getGroup = function(match) {
|
|
466
|
+
var groupCount = this.groups.length
|
|
467
|
+
for (var i = 0; i < groupCount; i++) {
|
|
468
|
+
if (match[i + 1] !== undefined) {
|
|
469
|
+
return this.groups[i]
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
throw new Error('Cannot find token type for matched text')
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
function tokenToString() {
|
|
476
|
+
return this.value
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
Lexer.prototype.next = function() {
|
|
480
|
+
var index = this.index
|
|
481
|
+
|
|
482
|
+
// If a fallback token matched, we don't need to re-run the RegExp
|
|
483
|
+
if (this.queuedGroup) {
|
|
484
|
+
var token = this._token(this.queuedGroup, this.queuedText, index)
|
|
485
|
+
this.queuedGroup = null
|
|
486
|
+
this.queuedText = ""
|
|
487
|
+
return token
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
var buffer = this.buffer
|
|
491
|
+
if (index === buffer.length) {
|
|
492
|
+
return // EOF
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
// Fast matching for single characters
|
|
496
|
+
var group = this.fast[buffer.charCodeAt(index)]
|
|
497
|
+
if (group) {
|
|
498
|
+
return this._token(group, buffer.charAt(index), index)
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
// Execute RegExp
|
|
502
|
+
var re = this.re
|
|
503
|
+
re.lastIndex = index
|
|
504
|
+
var match = eat(re, buffer)
|
|
505
|
+
|
|
506
|
+
// Error tokens match the remaining buffer
|
|
507
|
+
var error = this.error
|
|
508
|
+
if (match == null) {
|
|
509
|
+
return this._token(error, buffer.slice(index, buffer.length), index)
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
var group = this._getGroup(match)
|
|
513
|
+
var text = match[0]
|
|
514
|
+
|
|
515
|
+
if (error.fallback && match.index !== index) {
|
|
516
|
+
this.queuedGroup = group
|
|
517
|
+
this.queuedText = text
|
|
518
|
+
|
|
519
|
+
// Fallback tokens contain the unmatched portion of the buffer
|
|
520
|
+
return this._token(error, buffer.slice(index, match.index), index)
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
return this._token(group, text, index)
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
Lexer.prototype._token = function(group, text, offset) {
|
|
527
|
+
// count line breaks
|
|
528
|
+
var lineBreaks = 0
|
|
529
|
+
if (group.lineBreaks) {
|
|
530
|
+
var matchNL = /\n/g
|
|
531
|
+
var nl = 1
|
|
532
|
+
if (text === '\n') {
|
|
533
|
+
lineBreaks = 1
|
|
534
|
+
} else {
|
|
535
|
+
while (matchNL.exec(text)) { lineBreaks++; nl = matchNL.lastIndex }
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
var token = {
|
|
540
|
+
type: (typeof group.type === 'function' && group.type(text)) || group.defaultType,
|
|
541
|
+
value: typeof group.value === 'function' ? group.value(text) : text,
|
|
542
|
+
text: text,
|
|
543
|
+
toString: tokenToString,
|
|
544
|
+
offset: offset,
|
|
545
|
+
lineBreaks: lineBreaks,
|
|
546
|
+
line: this.line,
|
|
547
|
+
col: this.col,
|
|
548
|
+
}
|
|
549
|
+
// nb. adding more props to token object will make V8 sad!
|
|
550
|
+
|
|
551
|
+
var size = text.length
|
|
552
|
+
this.index += size
|
|
553
|
+
this.line += lineBreaks
|
|
554
|
+
if (lineBreaks !== 0) {
|
|
555
|
+
this.col = size - nl + 1
|
|
556
|
+
} else {
|
|
557
|
+
this.col += size
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// throw, if no rule with {error: true}
|
|
561
|
+
if (group.shouldThrow) {
|
|
562
|
+
var err = new Error(this.formatError(token, "invalid syntax"))
|
|
563
|
+
throw err;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
if (group.pop) this.popState()
|
|
567
|
+
else if (group.push) this.pushState(group.push)
|
|
568
|
+
else if (group.next) this.setState(group.next)
|
|
569
|
+
|
|
570
|
+
return token
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
if (typeof Symbol !== 'undefined' && Symbol.iterator) {
|
|
574
|
+
var LexerIterator = function(lexer) {
|
|
575
|
+
this.lexer = lexer
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
LexerIterator.prototype.next = function() {
|
|
579
|
+
var token = this.lexer.next()
|
|
580
|
+
return {value: token, done: !token}
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
LexerIterator.prototype[Symbol.iterator] = function() {
|
|
584
|
+
return this
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
Lexer.prototype[Symbol.iterator] = function() {
|
|
588
|
+
return new LexerIterator(this)
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
Lexer.prototype.formatError = function(token, message) {
|
|
593
|
+
if (token == null) {
|
|
594
|
+
// An undefined token indicates EOF
|
|
595
|
+
var text = this.buffer.slice(this.index)
|
|
596
|
+
var token = {
|
|
597
|
+
text: text,
|
|
598
|
+
offset: this.index,
|
|
599
|
+
lineBreaks: text.indexOf('\n') === -1 ? 0 : 1,
|
|
600
|
+
line: this.line,
|
|
601
|
+
col: this.col,
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
var numLinesAround = 2
|
|
606
|
+
var firstDisplayedLine = Math.max(token.line - numLinesAround, 1)
|
|
607
|
+
var lastDisplayedLine = token.line + numLinesAround
|
|
608
|
+
var lastLineDigits = String(lastDisplayedLine).length
|
|
609
|
+
var displayedLines = lastNLines(
|
|
610
|
+
this.buffer,
|
|
611
|
+
(this.line - token.line) + numLinesAround + 1
|
|
612
|
+
)
|
|
613
|
+
.slice(0, 5)
|
|
614
|
+
var errorLines = []
|
|
615
|
+
errorLines.push(message + " at line " + token.line + " col " + token.col + ":")
|
|
616
|
+
errorLines.push("")
|
|
617
|
+
for (var i = 0; i < displayedLines.length; i++) {
|
|
618
|
+
var line = displayedLines[i]
|
|
619
|
+
var lineNo = firstDisplayedLine + i
|
|
620
|
+
errorLines.push(pad(String(lineNo), lastLineDigits) + " " + line);
|
|
621
|
+
if (lineNo === token.line) {
|
|
622
|
+
errorLines.push(pad("", lastLineDigits + token.col + 1) + "^")
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
return errorLines.join("\n")
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
Lexer.prototype.clone = function() {
|
|
629
|
+
return new Lexer(this.states, this.state)
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
Lexer.prototype.has = function(tokenType) {
|
|
633
|
+
return true
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
return {
|
|
638
|
+
compile: compile,
|
|
639
|
+
states: compileStates,
|
|
640
|
+
error: Object.freeze({error: true}),
|
|
641
|
+
fallback: Object.freeze({fallback: true}),
|
|
642
|
+
keywords: keywordTransform,
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
}));
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "moo",
|
|
3
|
+
"version": "0.5.3",
|
|
4
|
+
"description": "Optimised tokenizer/lexer generator! 🐄 Much performance. Moo!",
|
|
5
|
+
"main": "moo.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"moo.js"
|
|
8
|
+
],
|
|
9
|
+
"repository": "https://github.com/tjvr/moo.git",
|
|
10
|
+
"author": "Tim Radvan <tim@tjvr.org>",
|
|
11
|
+
"contributors": [
|
|
12
|
+
"Nathan"
|
|
13
|
+
],
|
|
14
|
+
"license": "BSD-3-Clause",
|
|
15
|
+
"scripts": {
|
|
16
|
+
"test": "jest .",
|
|
17
|
+
"benchmark": "benchr test/benchmark.js",
|
|
18
|
+
"moo": "echo 'Mooooo!'"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"benchr": "^3.2.0",
|
|
22
|
+
"chevrotain": "4.2.0",
|
|
23
|
+
"jest": "24.7.1",
|
|
24
|
+
"lex": "^1.7.9",
|
|
25
|
+
"lexing": "^0.8.0",
|
|
26
|
+
"remix": "^0.1.4",
|
|
27
|
+
"tokenizer2": "^2.0.0"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014, 2015, 2016, 2017, 2018, 2019 Kartik Chandra, Tim Radvan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|