@azx-pbc/axiom-compiler 0.0.0-stage → 0.0.1
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/LICENSE +21 -0
- package/README.md +415 -2
- package/dist/article.d.ts +12 -0
- package/dist/article.d.ts.map +1 -0
- package/dist/article.js +16 -0
- package/dist/article.js.map +1 -0
- package/dist/cli/args.d.ts +101 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +158 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/check.d.ts +2 -0
- package/dist/cli/check.d.ts.map +1 -0
- package/dist/cli/check.js +33 -0
- package/dist/cli/check.js.map +1 -0
- package/dist/cli/compile.d.ts +2 -0
- package/dist/cli/compile.d.ts.map +1 -0
- package/dist/cli/compile.js +43 -0
- package/dist/cli/compile.js.map +1 -0
- package/dist/cli/count.d.ts +15 -0
- package/dist/cli/count.d.ts.map +1 -0
- package/dist/cli/count.js +21 -0
- package/dist/cli/count.js.map +1 -0
- package/dist/cli/dataset.d.ts +28 -0
- package/dist/cli/dataset.d.ts.map +1 -0
- package/dist/cli/dataset.js +115 -0
- package/dist/cli/dataset.js.map +1 -0
- package/dist/cli/diff.d.ts +2 -0
- package/dist/cli/diff.d.ts.map +1 -0
- package/dist/cli/diff.js +297 -0
- package/dist/cli/diff.js.map +1 -0
- package/dist/cli/explain.d.ts +2 -0
- package/dist/cli/explain.d.ts.map +1 -0
- package/dist/cli/explain.js +95 -0
- package/dist/cli/explain.js.map +1 -0
- package/dist/cli/fields.d.ts +11 -0
- package/dist/cli/fields.d.ts.map +1 -0
- package/dist/cli/fields.js +13 -0
- package/dist/cli/fields.js.map +1 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/main.js +40 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/cli/read.d.ts +56 -0
- package/dist/cli/read.d.ts.map +1 -0
- package/dist/cli/read.js +179 -0
- package/dist/cli/read.js.map +1 -0
- package/dist/cli/render.d.ts +58 -0
- package/dist/cli/render.d.ts.map +1 -0
- package/dist/cli/render.js +422 -0
- package/dist/cli/render.js.map +1 -0
- package/dist/cli/schema.d.ts +28 -0
- package/dist/cli/schema.d.ts.map +1 -0
- package/dist/cli/schema.js +46 -0
- package/dist/cli/schema.js.map +1 -0
- package/dist/cli/suite-report.d.ts +18 -0
- package/dist/cli/suite-report.d.ts.map +1 -0
- package/dist/cli/suite-report.js +58 -0
- package/dist/cli/suite-report.js.map +1 -0
- package/dist/cli/suites.d.ts +25 -0
- package/dist/cli/suites.d.ts.map +1 -0
- package/dist/cli/suites.js +67 -0
- package/dist/cli/suites.js.map +1 -0
- package/dist/cli/terminal.d.ts +45 -0
- package/dist/cli/terminal.d.ts.map +1 -0
- package/dist/cli/terminal.js +119 -0
- package/dist/cli/terminal.js.map +1 -0
- package/dist/cli/test.d.ts +12 -0
- package/dist/cli/test.d.ts.map +1 -0
- package/dist/cli/test.js +199 -0
- package/dist/cli/test.js.map +1 -0
- package/dist/cli/usage.d.ts +15 -0
- package/dist/cli/usage.d.ts.map +1 -0
- package/dist/cli/usage.js +95 -0
- package/dist/cli/usage.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +51 -0
- package/dist/cli.js.map +1 -0
- package/dist/compile/artifact-members.d.ts +57 -0
- package/dist/compile/artifact-members.d.ts.map +1 -0
- package/dist/compile/artifact-members.js +130 -0
- package/dist/compile/artifact-members.js.map +1 -0
- package/dist/compile/artifact.d.ts +20 -0
- package/dist/compile/artifact.d.ts.map +1 -0
- package/dist/compile/artifact.js +87 -0
- package/dist/compile/artifact.js.map +1 -0
- package/dist/compile/compilation.d.ts +46 -0
- package/dist/compile/compilation.d.ts.map +1 -0
- package/dist/compile/compilation.js +4 -0
- package/dist/compile/compilation.js.map +1 -0
- package/dist/compile/computed.d.ts +22 -0
- package/dist/compile/computed.d.ts.map +1 -0
- package/dist/compile/computed.js +245 -0
- package/dist/compile/computed.js.map +1 -0
- package/dist/compile/condition-warnings.d.ts +12 -0
- package/dist/compile/condition-warnings.d.ts.map +1 -0
- package/dist/compile/condition-warnings.js +26 -0
- package/dist/compile/condition-warnings.js.map +1 -0
- package/dist/compile/conditions.d.ts +18 -0
- package/dist/compile/conditions.d.ts.map +1 -0
- package/dist/compile/conditions.js +22 -0
- package/dist/compile/conditions.js.map +1 -0
- package/dist/compile/cross-checks.d.ts +67 -0
- package/dist/compile/cross-checks.d.ts.map +1 -0
- package/dist/compile/cross-checks.js +238 -0
- package/dist/compile/cross-checks.js.map +1 -0
- package/dist/compile/datasets.d.ts +52 -0
- package/dist/compile/datasets.d.ts.map +1 -0
- package/dist/compile/datasets.js +183 -0
- package/dist/compile/datasets.js.map +1 -0
- package/dist/compile/dead-weight.d.ts +26 -0
- package/dist/compile/dead-weight.d.ts.map +1 -0
- package/dist/compile/dead-weight.js +244 -0
- package/dist/compile/dead-weight.js.map +1 -0
- package/dist/compile/declaration-rules.d.ts +54 -0
- package/dist/compile/declaration-rules.d.ts.map +1 -0
- package/dist/compile/declaration-rules.js +510 -0
- package/dist/compile/declaration-rules.js.map +1 -0
- package/dist/compile/declarations.d.ts +44 -0
- package/dist/compile/declarations.d.ts.map +1 -0
- package/dist/compile/declarations.js +160 -0
- package/dist/compile/declarations.js.map +1 -0
- package/dist/compile/document.d.ts +4 -0
- package/dist/compile/document.d.ts.map +1 -0
- package/dist/compile/document.js +13 -0
- package/dist/compile/document.js.map +1 -0
- package/dist/compile/expression.d.ts +38 -0
- package/dist/compile/expression.d.ts.map +1 -0
- package/dist/compile/expression.js +288 -0
- package/dist/compile/expression.js.map +1 -0
- package/dist/compile/hashes.d.ts +26 -0
- package/dist/compile/hashes.d.ts.map +1 -0
- package/dist/compile/hashes.js +96 -0
- package/dist/compile/hashes.js.map +1 -0
- package/dist/compile/item-targets.d.ts +12 -0
- package/dist/compile/item-targets.d.ts.map +1 -0
- package/dist/compile/item-targets.js +287 -0
- package/dist/compile/item-targets.js.map +1 -0
- package/dist/compile/messages.d.ts +8 -0
- package/dist/compile/messages.d.ts.map +1 -0
- package/dist/compile/messages.js +62 -0
- package/dist/compile/messages.js.map +1 -0
- package/dist/compile/option-availability.d.ts +51 -0
- package/dist/compile/option-availability.d.ts.map +1 -0
- package/dist/compile/option-availability.js +171 -0
- package/dist/compile/option-availability.js.map +1 -0
- package/dist/compile/option-codes.d.ts +27 -0
- package/dist/compile/option-codes.d.ts.map +1 -0
- package/dist/compile/option-codes.js +212 -0
- package/dist/compile/option-codes.js.map +1 -0
- package/dist/compile/references.d.ts +14 -0
- package/dist/compile/references.d.ts.map +1 -0
- package/dist/compile/references.js +126 -0
- package/dist/compile/references.js.map +1 -0
- package/dist/compile/rows-from.d.ts +27 -0
- package/dist/compile/rows-from.d.ts.map +1 -0
- package/dist/compile/rows-from.js +164 -0
- package/dist/compile/rows-from.js.map +1 -0
- package/dist/compile/rules.d.ts +58 -0
- package/dist/compile/rules.d.ts.map +1 -0
- package/dist/compile/rules.js +327 -0
- package/dist/compile/rules.js.map +1 -0
- package/dist/compile/suggestions.d.ts +52 -0
- package/dist/compile/suggestions.d.ts.map +1 -0
- package/dist/compile/suggestions.js +633 -0
- package/dist/compile/suggestions.js.map +1 -0
- package/dist/compile/targets.d.ts +22 -0
- package/dist/compile/targets.d.ts.map +1 -0
- package/dist/compile/targets.js +125 -0
- package/dist/compile/targets.js.map +1 -0
- package/dist/compile/types.d.ts +84 -0
- package/dist/compile/types.d.ts.map +1 -0
- package/dist/compile/types.js +2 -0
- package/dist/compile/types.js.map +1 -0
- package/dist/compile/warning.d.ts +45 -0
- package/dist/compile/warning.d.ts.map +1 -0
- package/dist/compile/warning.js +2 -0
- package/dist/compile/warning.js.map +1 -0
- package/dist/compile-yaml.d.ts +23 -0
- package/dist/compile-yaml.d.ts.map +1 -0
- package/dist/compile-yaml.js +30 -0
- package/dist/compile-yaml.js.map +1 -0
- package/dist/compile.d.ts +78 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +372 -0
- package/dist/compile.js.map +1 -0
- package/dist/csv/limits.d.ts +43 -0
- package/dist/csv/limits.d.ts.map +1 -0
- package/dist/csv/limits.js +51 -0
- package/dist/csv/limits.js.map +1 -0
- package/dist/csv/scalar.d.ts +33 -0
- package/dist/csv/scalar.d.ts.map +1 -0
- package/dist/csv/scalar.js +77 -0
- package/dist/csv/scalar.js.map +1 -0
- package/dist/datasets/csv.d.ts +46 -0
- package/dist/datasets/csv.d.ts.map +1 -0
- package/dist/datasets/csv.js +293 -0
- package/dist/datasets/csv.js.map +1 -0
- package/dist/datasets/declaration.d.ts +16 -0
- package/dist/datasets/declaration.d.ts.map +1 -0
- package/dist/datasets/declaration.js +104 -0
- package/dist/datasets/declaration.js.map +1 -0
- package/dist/datasets/diagnostics.d.ts +65 -0
- package/dist/datasets/diagnostics.d.ts.map +1 -0
- package/dist/datasets/diagnostics.js +2 -0
- package/dist/datasets/diagnostics.js.map +1 -0
- package/dist/datasets/diff.d.ts +46 -0
- package/dist/datasets/diff.d.ts.map +1 -0
- package/dist/datasets/diff.js +84 -0
- package/dist/datasets/diff.js.map +1 -0
- package/dist/datasets/document.d.ts +12 -0
- package/dist/datasets/document.d.ts.map +1 -0
- package/dist/datasets/document.js +382 -0
- package/dist/datasets/document.js.map +1 -0
- package/dist/datasets/index.d.ts +43 -0
- package/dist/datasets/index.d.ts.map +1 -0
- package/dist/datasets/index.js +68 -0
- package/dist/datasets/index.js.map +1 -0
- package/dist/datasets/repair.d.ts +26 -0
- package/dist/datasets/repair.d.ts.map +1 -0
- package/dist/datasets/repair.js +60 -0
- package/dist/datasets/repair.js.map +1 -0
- package/dist/document-path.d.ts +62 -0
- package/dist/document-path.d.ts.map +1 -0
- package/dist/document-path.js +200 -0
- package/dist/document-path.js.map +1 -0
- package/dist/expr/boundary.d.ts +8 -0
- package/dist/expr/boundary.d.ts.map +1 -0
- package/dist/expr/boundary.js +243 -0
- package/dist/expr/boundary.js.map +1 -0
- package/dist/expr/compile-expr.d.ts +35 -0
- package/dist/expr/compile-expr.d.ts.map +1 -0
- package/dist/expr/compile-expr.js +66 -0
- package/dist/expr/compile-expr.js.map +1 -0
- package/dist/expr/deprecation.d.ts +23 -0
- package/dist/expr/deprecation.d.ts.map +1 -0
- package/dist/expr/deprecation.js +28 -0
- package/dist/expr/deprecation.js.map +1 -0
- package/dist/expr/diagnostics.d.ts +31 -0
- package/dist/expr/diagnostics.d.ts.map +1 -0
- package/dist/expr/diagnostics.js +34 -0
- package/dist/expr/diagnostics.js.map +1 -0
- package/dist/expr/lexer.d.ts +49 -0
- package/dist/expr/lexer.d.ts.map +1 -0
- package/dist/expr/lexer.js +277 -0
- package/dist/expr/lexer.js.map +1 -0
- package/dist/expr/lint-warnings.d.ts +11 -0
- package/dist/expr/lint-warnings.d.ts.map +1 -0
- package/dist/expr/lint-warnings.js +20 -0
- package/dist/expr/lint-warnings.js.map +1 -0
- package/dist/expr/lint.d.ts +41 -0
- package/dist/expr/lint.d.ts.map +1 -0
- package/dist/expr/lint.js +1034 -0
- package/dist/expr/lint.js.map +1 -0
- package/dist/expr/parse/aggregates.d.ts +13 -0
- package/dist/expr/parse/aggregates.d.ts.map +1 -0
- package/dist/expr/parse/aggregates.js +48 -0
- package/dist/expr/parse/aggregates.js.map +1 -0
- package/dist/expr/parse/budget.d.ts +11 -0
- package/dist/expr/parse/budget.d.ts.map +1 -0
- package/dist/expr/parse/budget.js +57 -0
- package/dist/expr/parse/budget.js.map +1 -0
- package/dist/expr/parse/grammar.d.ts +9 -0
- package/dist/expr/parse/grammar.d.ts.map +1 -0
- package/dist/expr/parse/grammar.js +699 -0
- package/dist/expr/parse/grammar.js.map +1 -0
- package/dist/expr/parse/literals.d.ts +20 -0
- package/dist/expr/parse/literals.d.ts.map +1 -0
- package/dist/expr/parse/literals.js +132 -0
- package/dist/expr/parse/literals.js.map +1 -0
- package/dist/expr/parse/stream.d.ts +60 -0
- package/dist/expr/parse/stream.d.ts.map +1 -0
- package/dist/expr/parse/stream.js +151 -0
- package/dist/expr/parse/stream.js.map +1 -0
- package/dist/expr/parser.d.ts +45 -0
- package/dist/expr/parser.d.ts.map +1 -0
- package/dist/expr/parser.js +110 -0
- package/dist/expr/parser.js.map +1 -0
- package/dist/expr/print/spell.d.ts +78 -0
- package/dist/expr/print/spell.d.ts.map +1 -0
- package/dist/expr/print/spell.js +592 -0
- package/dist/expr/print/spell.js.map +1 -0
- package/dist/expr/print.d.ts +20 -0
- package/dist/expr/print.d.ts.map +1 -0
- package/dist/expr/print.js +102 -0
- package/dist/expr/print.js.map +1 -0
- package/dist/expr/suggest.d.ts +26 -0
- package/dist/expr/suggest.d.ts.map +1 -0
- package/dist/expr/suggest.js +77 -0
- package/dist/expr/suggest.js.map +1 -0
- package/dist/expr/typecheck/aggregates.d.ts +8 -0
- package/dist/expr/typecheck/aggregates.d.ts.map +1 -0
- package/dist/expr/typecheck/aggregates.js +334 -0
- package/dist/expr/typecheck/aggregates.js.map +1 -0
- package/dist/expr/typecheck/arithmetic.d.ts +6 -0
- package/dist/expr/typecheck/arithmetic.d.ts.map +1 -0
- package/dist/expr/typecheck/arithmetic.js +258 -0
- package/dist/expr/typecheck/arithmetic.js.map +1 -0
- package/dist/expr/typecheck/arity.d.ts +38 -0
- package/dist/expr/typecheck/arity.d.ts.map +1 -0
- package/dist/expr/typecheck/arity.js +173 -0
- package/dist/expr/typecheck/arity.js.map +1 -0
- package/dist/expr/typecheck/calls.d.ts +6 -0
- package/dist/expr/typecheck/calls.d.ts.map +1 -0
- package/dist/expr/typecheck/calls.js +137 -0
- package/dist/expr/typecheck/calls.js.map +1 -0
- package/dist/expr/typecheck/comparison.d.ts +13 -0
- package/dist/expr/typecheck/comparison.d.ts.map +1 -0
- package/dist/expr/typecheck/comparison.js +200 -0
- package/dist/expr/typecheck/comparison.js.map +1 -0
- package/dist/expr/typecheck/compound.d.ts +24 -0
- package/dist/expr/typecheck/compound.d.ts.map +1 -0
- package/dist/expr/typecheck/compound.js +175 -0
- package/dist/expr/typecheck/compound.js.map +1 -0
- package/dist/expr/typecheck/context.d.ts +44 -0
- package/dist/expr/typecheck/context.d.ts.map +1 -0
- package/dist/expr/typecheck/context.js +2 -0
- package/dist/expr/typecheck/context.js.map +1 -0
- package/dist/expr/typecheck/datasets.d.ts +17 -0
- package/dist/expr/typecheck/datasets.d.ts.map +1 -0
- package/dist/expr/typecheck/datasets.js +136 -0
- package/dist/expr/typecheck/datasets.js.map +1 -0
- package/dist/expr/typecheck/digest.d.ts +7 -0
- package/dist/expr/typecheck/digest.d.ts.map +1 -0
- package/dist/expr/typecheck/digest.js +44 -0
- package/dist/expr/typecheck/digest.js.map +1 -0
- package/dist/expr/typecheck/fold.d.ts +41 -0
- package/dist/expr/typecheck/fold.d.ts.map +1 -0
- package/dist/expr/typecheck/fold.js +71 -0
- package/dist/expr/typecheck/fold.js.map +1 -0
- package/dist/expr/typecheck/gate-folds.d.ts +22 -0
- package/dist/expr/typecheck/gate-folds.d.ts.map +1 -0
- package/dist/expr/typecheck/gate-folds.js +40 -0
- package/dist/expr/typecheck/gate-folds.js.map +1 -0
- package/dist/expr/typecheck/guards.d.ts +6 -0
- package/dist/expr/typecheck/guards.d.ts.map +1 -0
- package/dist/expr/typecheck/guards.js +38 -0
- package/dist/expr/typecheck/guards.js.map +1 -0
- package/dist/expr/typecheck/member.d.ts +17 -0
- package/dist/expr/typecheck/member.d.ts.map +1 -0
- package/dist/expr/typecheck/member.js +46 -0
- package/dist/expr/typecheck/member.js.map +1 -0
- package/dist/expr/typecheck/money.d.ts +8 -0
- package/dist/expr/typecheck/money.d.ts.map +1 -0
- package/dist/expr/typecheck/money.js +49 -0
- package/dist/expr/typecheck/money.js.map +1 -0
- package/dist/expr/typecheck/numeric.d.ts +8 -0
- package/dist/expr/typecheck/numeric.d.ts.map +1 -0
- package/dist/expr/typecheck/numeric.js +84 -0
- package/dist/expr/typecheck/numeric.js.map +1 -0
- package/dist/expr/typecheck/operands.d.ts +27 -0
- package/dist/expr/typecheck/operands.d.ts.map +1 -0
- package/dist/expr/typecheck/operands.js +106 -0
- package/dist/expr/typecheck/operands.js.map +1 -0
- package/dist/expr/typecheck/paths.d.ts +21 -0
- package/dist/expr/typecheck/paths.d.ts.map +1 -0
- package/dist/expr/typecheck/paths.js +321 -0
- package/dist/expr/typecheck/paths.js.map +1 -0
- package/dist/expr/typecheck/records.d.ts +24 -0
- package/dist/expr/typecheck/records.d.ts.map +1 -0
- package/dist/expr/typecheck/records.js +53 -0
- package/dist/expr/typecheck/records.js.map +1 -0
- package/dist/expr/typecheck/sequences.d.ts +15 -0
- package/dist/expr/typecheck/sequences.d.ts.map +1 -0
- package/dist/expr/typecheck/sequences.js +55 -0
- package/dist/expr/typecheck/sequences.js.map +1 -0
- package/dist/expr/typecheck/strings.d.ts +8 -0
- package/dist/expr/typecheck/strings.d.ts.map +1 -0
- package/dist/expr/typecheck/strings.js +188 -0
- package/dist/expr/typecheck/strings.js.map +1 -0
- package/dist/expr/typecheck/temporal.d.ts +7 -0
- package/dist/expr/typecheck/temporal.d.ts.map +1 -0
- package/dist/expr/typecheck/temporal.js +80 -0
- package/dist/expr/typecheck/temporal.js.map +1 -0
- package/dist/expr/typecheck/types.d.ts +163 -0
- package/dist/expr/typecheck/types.d.ts.map +1 -0
- package/dist/expr/typecheck/types.js +404 -0
- package/dist/expr/typecheck/types.js.map +1 -0
- package/dist/expr/typecheck.d.ts +75 -0
- package/dist/expr/typecheck.d.ts.map +1 -0
- package/dist/expr/typecheck.js +242 -0
- package/dist/expr/typecheck.js.map +1 -0
- package/dist/expr/undecided.d.ts +13 -0
- package/dist/expr/undecided.d.ts.map +1 -0
- package/dist/expr/undecided.js +58 -0
- package/dist/expr/undecided.js.map +1 -0
- package/dist/expr/values/code-points.d.ts +13 -0
- package/dist/expr/values/code-points.d.ts.map +1 -0
- package/dist/expr/values/code-points.js +25 -0
- package/dist/expr/values/code-points.js.map +1 -0
- package/dist/expr/values/inline.d.ts +77 -0
- package/dist/expr/values/inline.d.ts.map +1 -0
- package/dist/expr/values/inline.js +404 -0
- package/dist/expr/values/inline.js.map +1 -0
- package/dist/expr/values/interval.d.ts +19 -0
- package/dist/expr/values/interval.d.ts.map +1 -0
- package/dist/expr/values/interval.js +1180 -0
- package/dist/expr/values/interval.js.map +1 -0
- package/dist/index.d.ts +163 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +128 -0
- package/dist/index.js.map +1 -0
- package/dist/ingest/document.d.ts +58 -0
- package/dist/ingest/document.d.ts.map +1 -0
- package/dist/ingest/document.js +83 -0
- package/dist/ingest/document.js.map +1 -0
- package/dist/ingest/yaml-document.d.ts +15 -0
- package/dist/ingest/yaml-document.d.ts.map +1 -0
- package/dist/ingest/yaml-document.js +42 -0
- package/dist/ingest/yaml-document.js.map +1 -0
- package/dist/ingest/yaml.d.ts +51 -0
- package/dist/ingest/yaml.d.ts.map +1 -0
- package/dist/ingest/yaml.js +340 -0
- package/dist/ingest/yaml.js.map +1 -0
- package/dist/layout/compile.d.ts +6 -0
- package/dist/layout/compile.d.ts.map +1 -0
- package/dist/layout/compile.js +224 -0
- package/dist/layout/compile.js.map +1 -0
- package/dist/layout/context.d.ts +12 -0
- package/dist/layout/context.d.ts.map +1 -0
- package/dist/layout/context.js +26 -0
- package/dist/layout/context.js.map +1 -0
- package/dist/layout/grammar.d.ts +34 -0
- package/dist/layout/grammar.d.ts.map +1 -0
- package/dist/layout/grammar.js +171 -0
- package/dist/layout/grammar.js.map +1 -0
- package/dist/layout/read.d.ts +54 -0
- package/dist/layout/read.d.ts.map +1 -0
- package/dist/layout/read.js +101 -0
- package/dist/layout/read.js.map +1 -0
- package/dist/layout/shape.d.ts +34 -0
- package/dist/layout/shape.d.ts.map +1 -0
- package/dist/layout/shape.js +149 -0
- package/dist/layout/shape.js.map +1 -0
- package/dist/messages/compile.d.ts +47 -0
- package/dist/messages/compile.d.ts.map +1 -0
- package/dist/messages/compile.js +202 -0
- package/dist/messages/compile.js.map +1 -0
- package/dist/messages/locale.d.ts +18 -0
- package/dist/messages/locale.d.ts.map +1 -0
- package/dist/messages/locale.js +33 -0
- package/dist/messages/locale.js.map +1 -0
- package/dist/messages/slots.d.ts +54 -0
- package/dist/messages/slots.d.ts.map +1 -0
- package/dist/messages/slots.js +137 -0
- package/dist/messages/slots.js.map +1 -0
- package/dist/overlay/compile-overlay.d.ts +29 -0
- package/dist/overlay/compile-overlay.d.ts.map +1 -0
- package/dist/overlay/compile-overlay.js +120 -0
- package/dist/overlay/compile-overlay.js.map +1 -0
- package/dist/overlay/compose.d.ts +26 -0
- package/dist/overlay/compose.d.ts.map +1 -0
- package/dist/overlay/compose.js +674 -0
- package/dist/overlay/compose.js.map +1 -0
- package/dist/overlay/types.d.ts +41 -0
- package/dist/overlay/types.d.ts.map +1 -0
- package/dist/overlay/types.js +2 -0
- package/dist/overlay/types.js.map +1 -0
- package/dist/publish/classify.d.ts +50 -0
- package/dist/publish/classify.d.ts.map +1 -0
- package/dist/publish/classify.js +85 -0
- package/dist/publish/classify.js.map +1 -0
- package/dist/publish/environment.d.ts +15 -0
- package/dist/publish/environment.d.ts.map +1 -0
- package/dist/publish/environment.js +2 -0
- package/dist/publish/environment.js.map +1 -0
- package/dist/publish/migrations.d.ts +108 -0
- package/dist/publish/migrations.d.ts.map +1 -0
- package/dist/publish/migrations.js +166 -0
- package/dist/publish/migrations.js.map +1 -0
- package/dist/publish/observation.d.ts +29 -0
- package/dist/publish/observation.d.ts.map +1 -0
- package/dist/publish/observation.js +43 -0
- package/dist/publish/observation.js.map +1 -0
- package/dist/publish/readiness.d.ts +197 -0
- package/dist/publish/readiness.d.ts.map +1 -0
- package/dist/publish/readiness.js +239 -0
- package/dist/publish/readiness.js.map +1 -0
- package/dist/publish/vectors.d.ts +50 -0
- package/dist/publish/vectors.d.ts.map +1 -0
- package/dist/publish/vectors.js +306 -0
- package/dist/publish/vectors.js.map +1 -0
- package/dist/publish/verify.d.ts +146 -0
- package/dist/publish/verify.d.ts.map +1 -0
- package/dist/publish/verify.js +548 -0
- package/dist/publish/verify.js.map +1 -0
- package/dist/scenarios/branch.d.ts +36 -0
- package/dist/scenarios/branch.d.ts.map +1 -0
- package/dist/scenarios/branch.js +30 -0
- package/dist/scenarios/branch.js.map +1 -0
- package/dist/scenarios/capture.d.ts +89 -0
- package/dist/scenarios/capture.d.ts.map +1 -0
- package/dist/scenarios/capture.js +443 -0
- package/dist/scenarios/capture.js.map +1 -0
- package/dist/scenarios/classifier.d.ts +20 -0
- package/dist/scenarios/classifier.d.ts.map +1 -0
- package/dist/scenarios/classifier.js +88 -0
- package/dist/scenarios/classifier.js.map +1 -0
- package/dist/scenarios/credit.d.ts +33 -0
- package/dist/scenarios/credit.d.ts.map +1 -0
- package/dist/scenarios/credit.js +330 -0
- package/dist/scenarios/credit.js.map +1 -0
- package/dist/scenarios/csv.d.ts +34 -0
- package/dist/scenarios/csv.d.ts.map +1 -0
- package/dist/scenarios/csv.js +1047 -0
- package/dist/scenarios/csv.js.map +1 -0
- package/dist/scenarios/data-identity.d.ts +39 -0
- package/dist/scenarios/data-identity.d.ts.map +1 -0
- package/dist/scenarios/data-identity.js +28 -0
- package/dist/scenarios/data-identity.js.map +1 -0
- package/dist/scenarios/document.d.ts +148 -0
- package/dist/scenarios/document.d.ts.map +1 -0
- package/dist/scenarios/document.js +513 -0
- package/dist/scenarios/document.js.map +1 -0
- package/dist/scenarios/environment.d.ts +64 -0
- package/dist/scenarios/environment.d.ts.map +1 -0
- package/dist/scenarios/environment.js +106 -0
- package/dist/scenarios/environment.js.map +1 -0
- package/dist/scenarios/evidence.d.ts +128 -0
- package/dist/scenarios/evidence.d.ts.map +1 -0
- package/dist/scenarios/evidence.js +179 -0
- package/dist/scenarios/evidence.js.map +1 -0
- package/dist/scenarios/expectations.d.ts +63 -0
- package/dist/scenarios/expectations.d.ts.map +1 -0
- package/dist/scenarios/expectations.js +490 -0
- package/dist/scenarios/expectations.js.map +1 -0
- package/dist/scenarios/references.d.ts +15 -0
- package/dist/scenarios/references.d.ts.map +1 -0
- package/dist/scenarios/references.js +239 -0
- package/dist/scenarios/references.js.map +1 -0
- package/dist/scenarios/report.d.ts +216 -0
- package/dist/scenarios/report.d.ts.map +1 -0
- package/dist/scenarios/report.js +54 -0
- package/dist/scenarios/report.js.map +1 -0
- package/dist/scenarios/runner.d.ts +55 -0
- package/dist/scenarios/runner.d.ts.map +1 -0
- package/dist/scenarios/runner.js +205 -0
- package/dist/scenarios/runner.js.map +1 -0
- package/dist/scenarios/vocabulary.d.ts +19 -0
- package/dist/scenarios/vocabulary.d.ts.map +1 -0
- package/dist/scenarios/vocabulary.js +56 -0
- package/dist/scenarios/vocabulary.js.map +1 -0
- package/dist/schema/catalogue.d.ts +54 -0
- package/dist/schema/catalogue.d.ts.map +1 -0
- package/dist/schema/catalogue.js +221 -0
- package/dist/schema/catalogue.js.map +1 -0
- package/dist/schema/check.d.ts +22 -0
- package/dist/schema/check.d.ts.map +1 -0
- package/dist/schema/check.js +30 -0
- package/dist/schema/check.js.map +1 -0
- package/dist/schema/closed.d.ts +19 -0
- package/dist/schema/closed.d.ts.map +1 -0
- package/dist/schema/closed.js +33 -0
- package/dist/schema/closed.js.map +1 -0
- package/dist/schema/collapse.d.ts +27 -0
- package/dist/schema/collapse.d.ts.map +1 -0
- package/dist/schema/collapse.js +143 -0
- package/dist/schema/collapse.js.map +1 -0
- package/dist/schema/controls.d.ts +46 -0
- package/dist/schema/controls.d.ts.map +1 -0
- package/dist/schema/controls.js +75 -0
- package/dist/schema/controls.js.map +1 -0
- package/dist/schema/dataset-declaration.d.ts +11 -0
- package/dist/schema/dataset-declaration.d.ts.map +1 -0
- package/dist/schema/dataset-declaration.js +11 -0
- package/dist/schema/dataset-declaration.js.map +1 -0
- package/dist/schema/declaration-warnings.d.ts +14 -0
- package/dist/schema/declaration-warnings.d.ts.map +1 -0
- package/dist/schema/declaration-warnings.js +77 -0
- package/dist/schema/declaration-warnings.js.map +1 -0
- package/dist/schema/declarations.d.ts +41 -0
- package/dist/schema/declarations.d.ts.map +1 -0
- package/dist/schema/declarations.js +1299 -0
- package/dist/schema/declarations.js.map +1 -0
- package/dist/schema/diagnostic.d.ts +118 -0
- package/dist/schema/diagnostic.d.ts.map +1 -0
- package/dist/schema/diagnostic.js +39 -0
- package/dist/schema/diagnostic.js.map +1 -0
- package/dist/schema/document.d.ts +93 -0
- package/dist/schema/document.d.ts.map +1 -0
- package/dist/schema/document.js +507 -0
- package/dist/schema/document.js.map +1 -0
- package/dist/schema/fields.d.ts +11 -0
- package/dist/schema/fields.d.ts.map +1 -0
- package/dist/schema/fields.js +265 -0
- package/dist/schema/fields.js.map +1 -0
- package/dist/schema/gates.d.ts +4 -0
- package/dist/schema/gates.d.ts.map +1 -0
- package/dist/schema/gates.js +68 -0
- package/dist/schema/gates.js.map +1 -0
- package/dist/schema/located.d.ts +27 -0
- package/dist/schema/located.d.ts.map +1 -0
- package/dist/schema/located.js +56 -0
- package/dist/schema/located.js.map +1 -0
- package/dist/schema/measurement.d.ts +9 -0
- package/dist/schema/measurement.d.ts.map +1 -0
- package/dist/schema/measurement.js +38 -0
- package/dist/schema/measurement.js.map +1 -0
- package/dist/schema/member-wording.d.ts +35 -0
- package/dist/schema/member-wording.d.ts.map +1 -0
- package/dist/schema/member-wording.js +286 -0
- package/dist/schema/member-wording.js.map +1 -0
- package/dist/schema/metaschema.d.ts +20 -0
- package/dist/schema/metaschema.d.ts.map +1 -0
- package/dist/schema/metaschema.js +476 -0
- package/dist/schema/metaschema.js.map +1 -0
- package/dist/schema/pointer.d.ts +31 -0
- package/dist/schema/pointer.d.ts.map +1 -0
- package/dist/schema/pointer.js +73 -0
- package/dist/schema/pointer.js.map +1 -0
- package/dist/schema/primary.d.ts +29 -0
- package/dist/schema/primary.d.ts.map +1 -0
- package/dist/schema/primary.js +48 -0
- package/dist/schema/primary.js.map +1 -0
- package/dist/schema/publish-vector.d.ts +17 -0
- package/dist/schema/publish-vector.d.ts.map +1 -0
- package/dist/schema/publish-vector.js +34 -0
- package/dist/schema/publish-vector.js.map +1 -0
- package/dist/schema/repair.d.ts +34 -0
- package/dist/schema/repair.d.ts.map +1 -0
- package/dist/schema/repair.js +163 -0
- package/dist/schema/repair.js.map +1 -0
- package/dist/schema/schema-v1.generated.d.ts +14 -0
- package/dist/schema/schema-v1.generated.d.ts.map +1 -0
- package/dist/schema/schema-v1.generated.js +7089 -0
- package/dist/schema/schema-v1.generated.js.map +1 -0
- package/dist/schema/screens.d.ts +4 -0
- package/dist/schema/screens.d.ts.map +1 -0
- package/dist/schema/screens.js +28 -0
- package/dist/schema/screens.js.map +1 -0
- package/dist/schema/test-values.d.ts +12 -0
- package/dist/schema/test-values.d.ts.map +1 -0
- package/dist/schema/test-values.js +97 -0
- package/dist/schema/test-values.js.map +1 -0
- package/dist/schema/unions.d.ts +46 -0
- package/dist/schema/unions.d.ts.map +1 -0
- package/dist/schema/unions.js +131 -0
- package/dist/schema/unions.js.map +1 -0
- package/dist/schema/validate-yaml.d.ts +14 -0
- package/dist/schema/validate-yaml.d.ts.map +1 -0
- package/dist/schema/validate-yaml.js +17 -0
- package/dist/schema/validate-yaml.js.map +1 -0
- package/dist/schema/validate.d.ts +46 -0
- package/dist/schema/validate.d.ts.map +1 -0
- package/dist/schema/validate.js +186 -0
- package/dist/schema/validate.js.map +1 -0
- package/dist/testing.d.ts +21 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +28 -0
- package/dist/testing.js.map +1 -0
- package/dist/vocabulary.d.ts +6 -0
- package/dist/vocabulary.d.ts.map +1 -0
- package/dist/vocabulary.js +26 -0
- package/dist/vocabulary.js.map +1 -0
- package/package.json +66 -3
|
@@ -0,0 +1,592 @@
|
|
|
1
|
+
import { DECIMAL_TEXT_PATTERN, assertNever, isRecord, toMoneyValue } from '@azx-pbc/axiom-runtime';
|
|
2
|
+
import { EXPR_RESERVED_WORDS } from '../lexer.js';
|
|
3
|
+
import { isAggregateBuiltin } from '../parse/aggregates.js';
|
|
4
|
+
import { MAX_AST_NODES } from '../parse/budget.js';
|
|
5
|
+
const CONNECTIVE_LEVEL = {
|
|
6
|
+
and: 'conjunction',
|
|
7
|
+
or: 'disjunction',
|
|
8
|
+
coalesce: 'coalesce',
|
|
9
|
+
};
|
|
10
|
+
const CONNECTIVE_TEXT = {
|
|
11
|
+
and: 'and',
|
|
12
|
+
or: 'or',
|
|
13
|
+
coalesce: '??',
|
|
14
|
+
};
|
|
15
|
+
const PRECEDENCE = {
|
|
16
|
+
coalesce: 1,
|
|
17
|
+
disjunction: 2,
|
|
18
|
+
conjunction: 3,
|
|
19
|
+
comparison: 4,
|
|
20
|
+
additive: 5,
|
|
21
|
+
multiplicative: 6,
|
|
22
|
+
unary: 7,
|
|
23
|
+
primary: 8,
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The source one parsed node spells, without the self-check `printExpr` runs.
|
|
27
|
+
*
|
|
28
|
+
* A refusal is building a sentence about the tree it already parsed, so the tree is known to have
|
|
29
|
+
* a source form: this is the spelling walk alone, and `undefined` means only that the node has no
|
|
30
|
+
* canonical source (a comprehension outside an aggregate, a reserved path segment). A caller that
|
|
31
|
+
* has no source to offer must then keep its plain refusal rather than invent a wrong repair.
|
|
32
|
+
*/
|
|
33
|
+
export function spellSource(node) {
|
|
34
|
+
const malformed = shapeRefusal(node);
|
|
35
|
+
if (malformed !== undefined)
|
|
36
|
+
return undefined;
|
|
37
|
+
const spelled = spell(node, 'typed');
|
|
38
|
+
return 'source' in spelled ? spelled.source : undefined;
|
|
39
|
+
}
|
|
40
|
+
/** One string literal in the language's own canonical spelling, for a repair sentence. */
|
|
41
|
+
export function spellStringLiteral(text) {
|
|
42
|
+
return spellString(text);
|
|
43
|
+
}
|
|
44
|
+
/** Every node kind the closed AST declares; a new kind fails typecheck until it is listed. */
|
|
45
|
+
const EXPRESSION_KIND_TABLE = {
|
|
46
|
+
literal: true,
|
|
47
|
+
path: true,
|
|
48
|
+
list: true,
|
|
49
|
+
and: true,
|
|
50
|
+
or: true,
|
|
51
|
+
not: true,
|
|
52
|
+
compare: true,
|
|
53
|
+
if: true,
|
|
54
|
+
coalesce: true,
|
|
55
|
+
call: true,
|
|
56
|
+
comprehension: true,
|
|
57
|
+
};
|
|
58
|
+
const EXPRESSION_KINDS = new Set(Object.keys(EXPRESSION_KIND_TABLE));
|
|
59
|
+
/** Every literal domain `spellLiteral` has an arm for; a new domain fails typecheck until listed. */
|
|
60
|
+
const LITERAL_DOMAIN_TABLE = {
|
|
61
|
+
string: true,
|
|
62
|
+
boolean: true,
|
|
63
|
+
integer: true,
|
|
64
|
+
decimal: true,
|
|
65
|
+
money: true,
|
|
66
|
+
date: true,
|
|
67
|
+
instant: true,
|
|
68
|
+
time: true,
|
|
69
|
+
media_ref: true,
|
|
70
|
+
signature_ref: true,
|
|
71
|
+
timeslot: true,
|
|
72
|
+
quantity: true,
|
|
73
|
+
duration: true,
|
|
74
|
+
address: true,
|
|
75
|
+
coordinate: true,
|
|
76
|
+
record: true,
|
|
77
|
+
array: true,
|
|
78
|
+
null: true,
|
|
79
|
+
};
|
|
80
|
+
const LITERAL_DOMAINS = new Set(Object.keys(LITERAL_DOMAIN_TABLE));
|
|
81
|
+
/** Whether `value` is an object whose `kind` is one of the closed AST's node kinds. */
|
|
82
|
+
function hasExpressionKind(value) {
|
|
83
|
+
return (isRecord(value) && typeof value['kind'] === 'string' && EXPRESSION_KINDS.has(value['kind']));
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The refusal for the first node whose shallow shape cannot be spelled, or `undefined` when every
|
|
87
|
+
* node in the tree can. The walk is iterative and validates only what the spelling walk will
|
|
88
|
+
* dereference: an object, a known node kind, a literal's known domain, a path's text, a call's
|
|
89
|
+
* operator, a comprehension's binder and source, and — for every operand list — a dense array of
|
|
90
|
+
* expression nodes. A hole or a missing member is refused here, before `checkExpressionBudget`
|
|
91
|
+
* reads `undefined.kind` or `join` reads a hole.
|
|
92
|
+
*
|
|
93
|
+
* It runs before the budget walk because that walk also dereferences every child, and before the
|
|
94
|
+
* spelling walk because that walk recurses; a shape refusal is therefore a tagged outcome rather
|
|
95
|
+
* than a `TypeError` escaping a function documented never to raise.
|
|
96
|
+
*/
|
|
97
|
+
export function shapeRefusal(root) {
|
|
98
|
+
const state = { pending: [root], inspected: 0 };
|
|
99
|
+
while (state.pending.length > 0) {
|
|
100
|
+
state.inspected += 1;
|
|
101
|
+
if (state.inspected > MAX_AST_NODES)
|
|
102
|
+
return nodeBudgetRefusal();
|
|
103
|
+
const refusal = inspectNode(state.pending.pop(), state);
|
|
104
|
+
if (refusal !== undefined)
|
|
105
|
+
return refusal;
|
|
106
|
+
}
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
function nodeBudgetRefusal() {
|
|
110
|
+
return unreproducible(`the expression exceeds the ${String(MAX_AST_NODES)}-node AST budget`);
|
|
111
|
+
}
|
|
112
|
+
function inspectNode(node, state) {
|
|
113
|
+
if (!isRecord(node))
|
|
114
|
+
return unreproducible('an expression node must be an object');
|
|
115
|
+
const kind = node['kind'];
|
|
116
|
+
if (typeof kind !== 'string') {
|
|
117
|
+
return unreproducible('an expression node must declare a string kind');
|
|
118
|
+
}
|
|
119
|
+
switch (kind) {
|
|
120
|
+
case 'literal': {
|
|
121
|
+
const domain = node['domain'];
|
|
122
|
+
return typeof domain === 'string' && LITERAL_DOMAINS.has(domain)
|
|
123
|
+
? undefined
|
|
124
|
+
: unreproducible(`\`${String(domain)}\` is not a literal domain`);
|
|
125
|
+
}
|
|
126
|
+
case 'path':
|
|
127
|
+
return typeof node['path'] === 'string'
|
|
128
|
+
? undefined
|
|
129
|
+
: unreproducible('a path node must declare its text');
|
|
130
|
+
case 'list':
|
|
131
|
+
return collectChildren(node['items'], 'items', 'a list', state);
|
|
132
|
+
case 'and':
|
|
133
|
+
case 'or':
|
|
134
|
+
case 'coalesce':
|
|
135
|
+
// The count stays `spellConnective`'s answer, so a one-operand fold keeps its own refusal.
|
|
136
|
+
return collectChildren(node['args'], 'args', `\`${kind}\``, state);
|
|
137
|
+
case 'compare':
|
|
138
|
+
if (typeof node['op'] !== 'string') {
|
|
139
|
+
return unreproducible('a comparison node must declare a string operator');
|
|
140
|
+
}
|
|
141
|
+
return collectFixed(node, 'compare', 2, state);
|
|
142
|
+
case 'not':
|
|
143
|
+
return collectFixed(node, 'not', 1, state);
|
|
144
|
+
case 'if':
|
|
145
|
+
return collectFixed(node, 'if', 3, state);
|
|
146
|
+
case 'call':
|
|
147
|
+
if (typeof node['op'] !== 'string') {
|
|
148
|
+
return unreproducible('a call node must declare a string operator');
|
|
149
|
+
}
|
|
150
|
+
return collectChildren(node['args'], 'args', `\`${node['op']}\``, state);
|
|
151
|
+
case 'comprehension':
|
|
152
|
+
return collectComprehension(node, state);
|
|
153
|
+
default:
|
|
154
|
+
return unreproducible(`\`${kind}\` is not an expression node kind`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function collectChildren(value, member, owner, state) {
|
|
158
|
+
if (!Array.isArray(value)) {
|
|
159
|
+
return unreproducible(`${owner} must declare an \`${member}\` array`);
|
|
160
|
+
}
|
|
161
|
+
const entries = value;
|
|
162
|
+
return collectEntries(entries, member, owner, state);
|
|
163
|
+
}
|
|
164
|
+
function collectFixed(node, kind, expected, state) {
|
|
165
|
+
const value = node['args'];
|
|
166
|
+
if (!Array.isArray(value)) {
|
|
167
|
+
return unreproducible(`\`${kind}\` must declare an \`args\` array`);
|
|
168
|
+
}
|
|
169
|
+
if (value.length !== expected)
|
|
170
|
+
return malformedArity(kind, value.length, expected);
|
|
171
|
+
const entries = value;
|
|
172
|
+
return collectEntries(entries, 'args', `\`${kind}\``, state);
|
|
173
|
+
}
|
|
174
|
+
function collectEntries(entries, member, owner, state) {
|
|
175
|
+
// Inspected plus queued plus this batch may not exceed the node budget. Checking before pushing
|
|
176
|
+
// keeps a hostile fan-out from growing the queue, and the same count decides the same bound the
|
|
177
|
+
// budget walk would report.
|
|
178
|
+
if (state.inspected + state.pending.length + entries.length > MAX_AST_NODES) {
|
|
179
|
+
return nodeBudgetRefusal();
|
|
180
|
+
}
|
|
181
|
+
// A sparse array's holes are skipped by `map` and `every`; counting up and testing each index
|
|
182
|
+
// refuses a hole and a present `undefined` before either walk can read them.
|
|
183
|
+
for (let index = 0; index < entries.length; index += 1) {
|
|
184
|
+
const child = entries[index];
|
|
185
|
+
if (!hasExpressionKind(child)) {
|
|
186
|
+
return unreproducible(`${owner} \`${member}\`[${String(index)}] is not an expression node`);
|
|
187
|
+
}
|
|
188
|
+
state.pending.push(child);
|
|
189
|
+
}
|
|
190
|
+
return undefined;
|
|
191
|
+
}
|
|
192
|
+
function collectComprehension(node, state) {
|
|
193
|
+
const binder = node['binder'];
|
|
194
|
+
if (!isRecord(binder) || typeof binder['name'] !== 'string') {
|
|
195
|
+
return unreproducible('a comprehension must declare a binder with a string name');
|
|
196
|
+
}
|
|
197
|
+
const source = node['source'];
|
|
198
|
+
if (!hasExpressionKind(source)) {
|
|
199
|
+
return unreproducible('a comprehension must declare a source expression');
|
|
200
|
+
}
|
|
201
|
+
const value = node['valueExpr'];
|
|
202
|
+
if (value !== undefined && !hasExpressionKind(value)) {
|
|
203
|
+
return unreproducible('a comprehension `valueExpr` must be an expression node');
|
|
204
|
+
}
|
|
205
|
+
const predicate = node['predicate'];
|
|
206
|
+
if (predicate !== undefined && !hasExpressionKind(predicate)) {
|
|
207
|
+
return unreproducible('a comprehension `predicate` must be an expression node');
|
|
208
|
+
}
|
|
209
|
+
const children = [source];
|
|
210
|
+
if (value !== undefined)
|
|
211
|
+
children.push(value);
|
|
212
|
+
if (predicate !== undefined)
|
|
213
|
+
children.push(predicate);
|
|
214
|
+
if (state.inspected + state.pending.length + children.length > MAX_AST_NODES) {
|
|
215
|
+
return nodeBudgetRefusal();
|
|
216
|
+
}
|
|
217
|
+
state.pending.push(...children);
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
220
|
+
/** Spells one node, or reports why the walk cannot continue. */
|
|
221
|
+
export function spell(node, decimals) {
|
|
222
|
+
switch (node.kind) {
|
|
223
|
+
case 'literal':
|
|
224
|
+
return spellLiteral(node, decimals);
|
|
225
|
+
case 'path':
|
|
226
|
+
return spellPath(node);
|
|
227
|
+
case 'list':
|
|
228
|
+
return spellList(node, decimals);
|
|
229
|
+
case 'not':
|
|
230
|
+
return spellNot(node, decimals);
|
|
231
|
+
case 'and':
|
|
232
|
+
case 'or':
|
|
233
|
+
case 'coalesce':
|
|
234
|
+
return spellConnective(node.kind, node.args, decimals);
|
|
235
|
+
case 'compare':
|
|
236
|
+
return spellCompare(node, decimals);
|
|
237
|
+
case 'if':
|
|
238
|
+
return spellIf(node, decimals);
|
|
239
|
+
case 'call':
|
|
240
|
+
return spellCall(node, decimals);
|
|
241
|
+
case 'comprehension':
|
|
242
|
+
// `[EXPR-3.1.2]` places a comprehension only in an aggregate's argument list, which
|
|
243
|
+
// `spellCall` handles; every other position has no production to spell it with.
|
|
244
|
+
return refusal('root_comprehension', 'a comprehension is only an argument of an aggregate built-in, so it has no source form here');
|
|
245
|
+
default:
|
|
246
|
+
return assertNever(node);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
function precedenceOf(node) {
|
|
250
|
+
switch (node.kind) {
|
|
251
|
+
case 'coalesce':
|
|
252
|
+
return 'coalesce';
|
|
253
|
+
case 'or':
|
|
254
|
+
return 'disjunction';
|
|
255
|
+
case 'and':
|
|
256
|
+
return 'conjunction';
|
|
257
|
+
case 'compare':
|
|
258
|
+
return 'comparison';
|
|
259
|
+
case 'not':
|
|
260
|
+
return 'unary';
|
|
261
|
+
case 'call':
|
|
262
|
+
switch (node.op) {
|
|
263
|
+
case '+':
|
|
264
|
+
case '-':
|
|
265
|
+
return node.op === '-' && node.args.length === 1 ? 'unary' : 'additive';
|
|
266
|
+
case '*':
|
|
267
|
+
case '/':
|
|
268
|
+
case '%':
|
|
269
|
+
case '//':
|
|
270
|
+
return 'multiplicative';
|
|
271
|
+
default:
|
|
272
|
+
return 'primary';
|
|
273
|
+
}
|
|
274
|
+
case 'literal':
|
|
275
|
+
case 'path':
|
|
276
|
+
case 'list':
|
|
277
|
+
case 'if':
|
|
278
|
+
case 'comprehension':
|
|
279
|
+
return 'primary';
|
|
280
|
+
default:
|
|
281
|
+
return assertNever(node);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Spells an operand of a form at `level`. `tieNeedsParens` states the form's associativity: a
|
|
286
|
+
* left-associative chain and a non-associative comparison both re-read an equal-precedence child
|
|
287
|
+
* as part of themselves, so only a strictly higher child may be written bare.
|
|
288
|
+
*/
|
|
289
|
+
function spellOperand(node, level, tieNeedsParens, decimals) {
|
|
290
|
+
const inner = spell(node, decimals);
|
|
291
|
+
if (!('source' in inner))
|
|
292
|
+
return inner;
|
|
293
|
+
const own = PRECEDENCE[precedenceOf(node)];
|
|
294
|
+
const outer = PRECEDENCE[level];
|
|
295
|
+
if (own > outer || (own === outer && !tieNeedsParens))
|
|
296
|
+
return inner;
|
|
297
|
+
return spelled(`(${inner.source})`);
|
|
298
|
+
}
|
|
299
|
+
/** Spells every part and joins the sources with `separator`, or reports the first failure. */
|
|
300
|
+
function join(parts, separator) {
|
|
301
|
+
const sources = [];
|
|
302
|
+
for (const part of parts) {
|
|
303
|
+
if (!('source' in part))
|
|
304
|
+
return part;
|
|
305
|
+
sources.push(part.source);
|
|
306
|
+
}
|
|
307
|
+
return spelled(sources.join(separator));
|
|
308
|
+
}
|
|
309
|
+
function spellChain(args, level, separator, decimals) {
|
|
310
|
+
return join(args.map((arg) => spellOperand(arg, level, true, decimals)), separator);
|
|
311
|
+
}
|
|
312
|
+
function spellConnective(kind, args, decimals) {
|
|
313
|
+
if (args.length < 2) {
|
|
314
|
+
return refusal('singleton_connective', `\`${kind}\` folds ${String(args.length)} operand(s), and the grammar has no form below two`);
|
|
315
|
+
}
|
|
316
|
+
return spellChain(args, CONNECTIVE_LEVEL[kind], ` ${CONNECTIVE_TEXT[kind]} `, decimals);
|
|
317
|
+
}
|
|
318
|
+
function spellCompare(node, decimals) {
|
|
319
|
+
const [left, right] = node.args;
|
|
320
|
+
return join([
|
|
321
|
+
spellOperand(left, 'comparison', true, decimals),
|
|
322
|
+
spellOperand(right, 'comparison', true, decimals),
|
|
323
|
+
], ` ${node.op} `);
|
|
324
|
+
}
|
|
325
|
+
function spellNot(node, decimals) {
|
|
326
|
+
const [operand] = node.args;
|
|
327
|
+
const inner = spellOperand(operand, 'unary', false, decimals);
|
|
328
|
+
if (!('source' in inner))
|
|
329
|
+
return inner;
|
|
330
|
+
return spelled(`not ${inner.source}`);
|
|
331
|
+
}
|
|
332
|
+
function spellIf(node, decimals) {
|
|
333
|
+
// `if`'s operands are whole expressions up to the comma, so none of them needs parentheses.
|
|
334
|
+
const [condition, thenExpr, elseExpr] = node.args;
|
|
335
|
+
const operands = join([spell(condition, decimals), spell(thenExpr, decimals), spell(elseExpr, decimals)], ', ');
|
|
336
|
+
if (!('source' in operands))
|
|
337
|
+
return operands;
|
|
338
|
+
return spelled(`if(${operands.source})`);
|
|
339
|
+
}
|
|
340
|
+
function spellList(node, decimals) {
|
|
341
|
+
const items = join(node.items.map((item) => spell(item, decimals)), ', ');
|
|
342
|
+
if (!('source' in items))
|
|
343
|
+
return items;
|
|
344
|
+
return spelled(`[${items.source}]`);
|
|
345
|
+
}
|
|
346
|
+
function spellCall(node, decimals) {
|
|
347
|
+
const { op, args } = node;
|
|
348
|
+
if (op === '+' || op === '-' || op === '*' || op === '/' || op === '%' || op === '//') {
|
|
349
|
+
return spellArithmetic(op, args, decimals);
|
|
350
|
+
}
|
|
351
|
+
if (op === 'member')
|
|
352
|
+
return spellMember(args, decimals);
|
|
353
|
+
const operands = join(args.map((arg) => arg.kind === 'comprehension' && isAggregateBuiltin(op)
|
|
354
|
+
? spellComprehension(arg, decimals)
|
|
355
|
+
: spell(arg, decimals)), ', ');
|
|
356
|
+
if (!('source' in operands))
|
|
357
|
+
return operands;
|
|
358
|
+
return spelled(`${op}(${operands.source})`);
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* `member(base, "name")` back to `base.name`, the form an author wrote.
|
|
362
|
+
*
|
|
363
|
+
* The sugar is printed only where it re-reads as the same call: a call or conditional base
|
|
364
|
+
* is a primary, and the name is an identifier. A path or any other base keeps the call form,
|
|
365
|
+
* because `f_x.name` would parse as one path rather than a member read.
|
|
366
|
+
*/
|
|
367
|
+
function spellMember(args, decimals) {
|
|
368
|
+
const [base, name] = args;
|
|
369
|
+
if (base === undefined ||
|
|
370
|
+
name === undefined ||
|
|
371
|
+
name.kind !== 'literal' ||
|
|
372
|
+
typeof name.value !== 'string' ||
|
|
373
|
+
!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name.value) ||
|
|
374
|
+
!(base.kind === 'if' ||
|
|
375
|
+
(base.kind === 'call' &&
|
|
376
|
+
base.op !== '+' &&
|
|
377
|
+
base.op !== '-' &&
|
|
378
|
+
base.op !== '*' &&
|
|
379
|
+
base.op !== '/' &&
|
|
380
|
+
base.op !== '%' &&
|
|
381
|
+
base.op !== '//'))) {
|
|
382
|
+
return spellCallArguments('member', args, decimals);
|
|
383
|
+
}
|
|
384
|
+
const inner = spell(base, decimals);
|
|
385
|
+
return 'source' in inner ? spelled(`${inner.source}.${name.value}`) : inner;
|
|
386
|
+
}
|
|
387
|
+
function spellCallArguments(op, args, decimals) {
|
|
388
|
+
const operands = join(args.map((arg) => arg.kind === 'comprehension' && isAggregateBuiltin(op)
|
|
389
|
+
? spellComprehension(arg, decimals)
|
|
390
|
+
: spell(arg, decimals)), ', ');
|
|
391
|
+
return 'source' in operands ? spelled(`${op}(${operands.source})`) : operands;
|
|
392
|
+
}
|
|
393
|
+
function spellArithmetic(op, args, decimals) {
|
|
394
|
+
const [left, right] = args;
|
|
395
|
+
if (left === undefined)
|
|
396
|
+
return unreproducible(`\`${op}\` carries no operand`);
|
|
397
|
+
if (op === '-' && args.length === 1)
|
|
398
|
+
return spellNegation(left, decimals);
|
|
399
|
+
if ((op === '/' || op === '%' || op === '//') && right !== undefined && args.length === 2) {
|
|
400
|
+
// Division is binary and left-associative: a tie on the left is the chain itself
|
|
401
|
+
// (`a / b / c` *is* `(a / b) / c`), while a tie on the right needs its parentheses.
|
|
402
|
+
return join([
|
|
403
|
+
spellOperand(left, 'multiplicative', false, decimals),
|
|
404
|
+
spellOperand(right, 'multiplicative', true, decimals),
|
|
405
|
+
], ` ${op} `);
|
|
406
|
+
}
|
|
407
|
+
if (op === '-' && right !== undefined && args.length === 2) {
|
|
408
|
+
// Subtraction is binary and left-associative, so a tie on the left is the chain itself
|
|
409
|
+
// (`a - b - c` *is* `(a - b) - c`) while a tie on the right needs its parentheses.
|
|
410
|
+
return join([
|
|
411
|
+
spellOperand(left, 'additive', false, decimals),
|
|
412
|
+
spellOperand(right, 'additive', true, decimals),
|
|
413
|
+
], ' - ');
|
|
414
|
+
}
|
|
415
|
+
return spellChain(args, op === '*' ? 'multiplicative' : 'additive', ` ${op} `, decimals);
|
|
416
|
+
}
|
|
417
|
+
function spellNegation(operand, decimals) {
|
|
418
|
+
const inner = spellOperand(operand, 'unary', false, decimals);
|
|
419
|
+
if (!('source' in inner))
|
|
420
|
+
return inner;
|
|
421
|
+
// `-1` and `-1.5` fold into a negative literal, so a numeric literal operand keeps its
|
|
422
|
+
// parentheses and the call stays a call of arity one.
|
|
423
|
+
const folds = operand.kind === 'literal' && (operand.domain === 'integer' || operand.domain === 'decimal');
|
|
424
|
+
return spelled(folds ? `-(${inner.source})` : `-${inner.source}`);
|
|
425
|
+
}
|
|
426
|
+
function spellComprehension(node, decimals) {
|
|
427
|
+
const source = spell(node.source, decimals);
|
|
428
|
+
if (!('source' in source))
|
|
429
|
+
return source;
|
|
430
|
+
const value = node.valueExpr === undefined ? undefined : spell(node.valueExpr, decimals);
|
|
431
|
+
if (value !== undefined && !('source' in value))
|
|
432
|
+
return value;
|
|
433
|
+
const predicate = node.predicate === undefined ? undefined : spell(node.predicate, decimals);
|
|
434
|
+
if (predicate !== undefined && !('source' in predicate))
|
|
435
|
+
return predicate;
|
|
436
|
+
const valueSource = sourceOf(value);
|
|
437
|
+
const predicateSource = sourceOf(predicate);
|
|
438
|
+
const body = valueSource ?? predicateSource;
|
|
439
|
+
if (body === undefined) {
|
|
440
|
+
return unreproducible(`binder \`${node.binder.name}\` declares neither a value nor a predicate, so it has no body`);
|
|
441
|
+
}
|
|
442
|
+
// A value projection's filter follows its body; a predicate aggregate has one body that is
|
|
443
|
+
// already the predicate, so only a `valueExpr` carries the `if` clause.
|
|
444
|
+
const filter = valueSource === undefined || predicateSource === undefined ? '' : ` if ${predicateSource}`;
|
|
445
|
+
return spelled(`${node.binder.name} in ${source.source}: ${body}${filter}`);
|
|
446
|
+
}
|
|
447
|
+
function spellPath(node) {
|
|
448
|
+
const body = node.path.startsWith('$') ? node.path.slice(1) : node.path;
|
|
449
|
+
const reserved = body.split('.').find((segment) => EXPR_RESERVED_WORDS.has(segment));
|
|
450
|
+
if (reserved !== undefined) {
|
|
451
|
+
return refusal('reserved_path_segment', `\`${reserved}\` is a reserved word, so \`${node.path}\` has no source spelling`);
|
|
452
|
+
}
|
|
453
|
+
return spelled(node.path);
|
|
454
|
+
}
|
|
455
|
+
function spellLiteral(node, decimals) {
|
|
456
|
+
const { domain, value } = node;
|
|
457
|
+
switch (domain) {
|
|
458
|
+
case 'integer':
|
|
459
|
+
return typeof value === 'number' && Number.isSafeInteger(value)
|
|
460
|
+
? spelled(String(value))
|
|
461
|
+
: unreproducible('an integer literal must hold a canonical integer');
|
|
462
|
+
case 'decimal':
|
|
463
|
+
return typeof value === 'string'
|
|
464
|
+
? spellDecimal(value, decimals)
|
|
465
|
+
: unreproducible('a decimal literal must hold its canonical text');
|
|
466
|
+
case 'string':
|
|
467
|
+
return typeof value === 'string'
|
|
468
|
+
? spelled(spellString(value))
|
|
469
|
+
: unreproducible('a string literal must hold text');
|
|
470
|
+
case 'boolean':
|
|
471
|
+
return typeof value === 'boolean'
|
|
472
|
+
? spelled(value ? 'true' : 'false')
|
|
473
|
+
: unreproducible('a boolean literal must hold a boolean');
|
|
474
|
+
case 'null':
|
|
475
|
+
return value === null ? spelled('null') : unreproducible('a null literal must hold null');
|
|
476
|
+
case 'date':
|
|
477
|
+
return typeof value === 'string'
|
|
478
|
+
? spelled(`date ${spellString(value)}`)
|
|
479
|
+
: unreproducible('a date literal must hold its canonical text');
|
|
480
|
+
case 'instant':
|
|
481
|
+
return typeof value === 'string'
|
|
482
|
+
? spelled(`instant ${spellString(value)}`)
|
|
483
|
+
: unreproducible('an instant literal must hold its canonical text');
|
|
484
|
+
case 'money':
|
|
485
|
+
return spellMoney(value);
|
|
486
|
+
case 'media_ref':
|
|
487
|
+
case 'signature_ref':
|
|
488
|
+
case 'timeslot':
|
|
489
|
+
case 'quantity':
|
|
490
|
+
case 'time':
|
|
491
|
+
case 'duration':
|
|
492
|
+
case 'address':
|
|
493
|
+
case 'coordinate':
|
|
494
|
+
case 'record':
|
|
495
|
+
case 'array':
|
|
496
|
+
return refusal('unsupported_literal_domain', `\`${domain}\` has no Expr v1 literal syntax`);
|
|
497
|
+
default:
|
|
498
|
+
return assertNever(domain);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* A canonical decimal the lexer reads back as the same value *without* the `decimal` keyword and
|
|
503
|
+
* with fewer tokens: a positive value with a fractional part. The runtime's pattern rules out a
|
|
504
|
+
* leading zero, an exponent and a trailing fractional zero; a whole value (`0`, `1`) is excluded
|
|
505
|
+
* because the untyped token is then an integer, a different value, and a negative value (`-1.5`)
|
|
506
|
+
* costs the same two tokens with or without its suffix, so it keeps the canonical typed spelling.
|
|
507
|
+
* A decimal that cannot take the shorter form is refused when the typed text does not fit the
|
|
508
|
+
* source budget.
|
|
509
|
+
*/
|
|
510
|
+
function isUntypedDecimal(value) {
|
|
511
|
+
return !value.startsWith('-') && DECIMAL_TEXT_PATTERN.test(value) && value.includes('.');
|
|
512
|
+
}
|
|
513
|
+
function spellDecimal(value, decimals) {
|
|
514
|
+
if (decimals === 'untyped' && isUntypedDecimal(value))
|
|
515
|
+
return spelled(value);
|
|
516
|
+
return spelled(`decimal ${spellString(value)}`);
|
|
517
|
+
}
|
|
518
|
+
/** A node whose operand count has no production, which no spelling can repair. */
|
|
519
|
+
function malformedArity(kind, arity, expected) {
|
|
520
|
+
return unreproducible(`\`${kind}\` carries ${String(arity)} operand(s) where the grammar has ${String(expected)}`);
|
|
521
|
+
}
|
|
522
|
+
function spellMoney(value) {
|
|
523
|
+
if (!isRecord(value))
|
|
524
|
+
return unreproducible('a money literal must hold a money record');
|
|
525
|
+
try {
|
|
526
|
+
const money = toMoneyValue(value);
|
|
527
|
+
return spelled(`money { "minor": ${spellString(money.minor)}, "currency": ${spellString(money.currency)}, "scale": ${String(money.scale)} }`);
|
|
528
|
+
}
|
|
529
|
+
catch (error) {
|
|
530
|
+
return unreproducible(`a money literal must hold a money record: ${messageOf(error)}`);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* A string literal in the language's own spelling: the quote and the backslash, the three named
|
|
535
|
+
* whitespace escapes, and a `\u{...}` escape for every control code and lone surrogate so the text
|
|
536
|
+
* stays readable. A surrogate that is not a Unicode scalar value survives the escape only as a
|
|
537
|
+
* parser refusal, which the self-check reports rather than emitting text nobody can read back.
|
|
538
|
+
*/
|
|
539
|
+
/**
|
|
540
|
+
* One string value as a double-quoted literal.
|
|
541
|
+
*
|
|
542
|
+
* `'…'` is an accepted alternate spelling, but the printer emits one deterministic form:
|
|
543
|
+
* a canonical report compares bytes, and preserving the author's quote style would make two
|
|
544
|
+
* equal expressions print differently. A `'` needs no escape inside double quotes, so the
|
|
545
|
+
* canonical form is the shorter one for the case that matters.
|
|
546
|
+
*/
|
|
547
|
+
function spellString(text) {
|
|
548
|
+
let body = '';
|
|
549
|
+
for (const character of text)
|
|
550
|
+
body += spellCharacter(character);
|
|
551
|
+
return `"${body}"`;
|
|
552
|
+
}
|
|
553
|
+
function spellCharacter(character) {
|
|
554
|
+
switch (character) {
|
|
555
|
+
case '"':
|
|
556
|
+
return '\\"';
|
|
557
|
+
case '\\':
|
|
558
|
+
return '\\\\';
|
|
559
|
+
case '\n':
|
|
560
|
+
return '\\n';
|
|
561
|
+
case '\r':
|
|
562
|
+
return '\\r';
|
|
563
|
+
case '\t':
|
|
564
|
+
return '\\t';
|
|
565
|
+
default: {
|
|
566
|
+
const code = character.codePointAt(0);
|
|
567
|
+
if (code === undefined)
|
|
568
|
+
return character;
|
|
569
|
+
const loneSurrogate = character.length === 1 && code >= 0xd800 && code <= 0xdfff;
|
|
570
|
+
if (code < 0x20 || code === 0x7f || loneSurrogate)
|
|
571
|
+
return `\\u{${code.toString(16)}}`;
|
|
572
|
+
return character;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
function sourceOf(spelling) {
|
|
577
|
+
return spelling !== undefined && 'source' in spelling ? spelling.source : undefined;
|
|
578
|
+
}
|
|
579
|
+
function spelled(source) {
|
|
580
|
+
return { source };
|
|
581
|
+
}
|
|
582
|
+
export function refusal(reason, detail) {
|
|
583
|
+
return { ok: false, reason, detail };
|
|
584
|
+
}
|
|
585
|
+
/** A node the walk can spell text for, but no text the parser reads back as this tree. */
|
|
586
|
+
function unreproducible(detail) {
|
|
587
|
+
return refusal('self_check_failed', detail);
|
|
588
|
+
}
|
|
589
|
+
function messageOf(error) {
|
|
590
|
+
return error instanceof Error ? error.message : 'an unrecognised failure';
|
|
591
|
+
}
|
|
592
|
+
//# sourceMappingURL=spell.js.map
|