@techspokes/typescript-wsdl-client 1.1.4 → 1.1.8
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/README.md +81 -35
- package/dist/app/generateApp.d.ts +0 -1
- package/dist/app/generateApp.js +8 -6
- package/dist/app/generateCheckedApp.d.ts +38 -0
- package/dist/app/generateCheckedApp.js +108 -0
- package/dist/checkedPipeline.d.ts +155 -0
- package/dist/checkedPipeline.js +448 -0
- package/dist/checkedPlanning.d.ts +123 -0
- package/dist/checkedPlanning.js +245 -0
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +123 -5
- package/dist/client/checkedDirectRuntime.d.ts +96 -0
- package/dist/client/checkedDirectRuntime.js +43 -0
- package/dist/client/directClientRuntime.d.ts +74 -0
- package/dist/client/directClientRuntime.js +165 -0
- package/dist/client/directClientVersion.d.ts +6 -0
- package/dist/client/directClientVersion.js +6 -0
- package/dist/client/generateClient.d.ts +0 -1
- package/dist/client/generateClient.js +26 -12
- package/dist/client/generateDirectClient.d.ts +32 -0
- package/dist/client/generateDirectClient.js +268 -0
- package/dist/client/generateOperations.d.ts +0 -1
- package/dist/client/generateTypes.d.ts +0 -1
- package/dist/client/generateUtils.d.ts +0 -1
- package/dist/client/generateUtils.js +3 -1
- package/dist/compiler/applicationGroups.d.ts +53 -0
- package/dist/compiler/applicationGroups.js +403 -0
- package/dist/compiler/buildCanonicalGraph.d.ts +6 -0
- package/dist/compiler/buildCanonicalGraph.js +381 -0
- package/dist/compiler/canonicalGraph.d.ts +197 -0
- package/dist/compiler/canonicalGraph.js +37 -0
- package/dist/compiler/catalogErrors.d.ts +17 -0
- package/dist/compiler/catalogErrors.js +86 -0
- package/dist/compiler/catalogProvenance.d.ts +14 -0
- package/dist/compiler/catalogProvenance.js +229 -0
- package/dist/compiler/checkedAssessment.d.ts +90 -0
- package/dist/compiler/checkedAssessment.js +300 -0
- package/dist/compiler/checkedComponentSource.d.ts +16 -0
- package/dist/compiler/checkedComponentSource.js +31 -0
- package/dist/compiler/checkedSourcePreparation.d.ts +72 -0
- package/dist/compiler/checkedSourcePreparation.js +202 -0
- package/dist/compiler/complexTypeContent.d.ts +58 -0
- package/dist/compiler/complexTypeContent.js +558 -0
- package/dist/compiler/componentCorrespondence.d.ts +32 -0
- package/dist/compiler/componentCorrespondence.js +140 -0
- package/dist/compiler/componentRecordProjection.d.ts +109 -0
- package/dist/compiler/componentRecordProjection.js +319 -0
- package/dist/compiler/componentSoapPreparation.d.ts +20 -0
- package/dist/compiler/componentSoapPreparation.js +36 -0
- package/dist/compiler/composeCanonicalGraph.d.ts +68 -0
- package/dist/compiler/composeCanonicalGraph.js +252 -0
- package/dist/compiler/dataOwnership.d.ts +21 -0
- package/dist/compiler/dataOwnership.js +167 -0
- package/dist/compiler/datatypeValues.d.ts +46 -0
- package/dist/compiler/datatypeValues.js +275 -0
- package/dist/compiler/directCodec.d.ts +116 -0
- package/dist/compiler/directCodec.js +377 -0
- package/dist/compiler/directExecutionPolicy.d.ts +9 -0
- package/dist/compiler/directExecutionPolicy.js +17 -0
- package/dist/compiler/directOperation.d.ts +114 -0
- package/dist/compiler/directOperation.js +373 -0
- package/dist/compiler/directSoap.d.ts +66 -0
- package/dist/compiler/directSoap.js +391 -0
- package/dist/compiler/directSoapSource.d.ts +38 -0
- package/dist/compiler/directSoapSource.js +233 -0
- package/dist/compiler/directSourceCapsule.d.ts +169 -0
- package/dist/compiler/directSourceCapsule.js +727 -0
- package/dist/compiler/directStructure.d.ts +128 -0
- package/dist/compiler/directStructure.js +543 -0
- package/dist/compiler/directStructurePlan.d.ts +149 -0
- package/dist/compiler/directStructurePlan.js +623 -0
- package/dist/compiler/directValues.d.ts +128 -0
- package/dist/compiler/directValues.js +1116 -0
- package/dist/compiler/finiteRe01Construction.d.ts +69 -0
- package/dist/compiler/finiteRe01Construction.js +422 -0
- package/dist/compiler/finiteRe01Verification.d.ts +218 -0
- package/dist/compiler/finiteRe01Verification.js +1217 -0
- package/dist/compiler/generateCatalog.d.ts +0 -1
- package/dist/compiler/graphTraversal.d.ts +10 -0
- package/dist/compiler/graphTraversal.js +37 -0
- package/dist/compiler/hypotheticalScopedIdentity.d.ts +22 -0
- package/dist/compiler/hypotheticalScopedIdentity.js +81 -0
- package/dist/compiler/occurrenceAnalysis.d.ts +66 -0
- package/dist/compiler/occurrenceAnalysis.js +316 -0
- package/dist/compiler/originalSourceMembership.d.ts +5 -0
- package/dist/compiler/originalSourceMembership.js +31 -0
- package/dist/compiler/particleAttribution.d.ts +16 -0
- package/dist/compiler/particleAttribution.js +494 -0
- package/dist/compiler/particleDeclarationConsistency.d.ts +23 -0
- package/dist/compiler/particleDeclarationConsistency.js +206 -0
- package/dist/compiler/particleExtension.d.ts +21 -0
- package/dist/compiler/particleExtension.js +123 -0
- package/dist/compiler/particleLocalAssessment.d.ts +19 -0
- package/dist/compiler/particleLocalAssessment.js +92 -0
- package/dist/compiler/particleRestriction.d.ts +23 -0
- package/dist/compiler/particleRestriction.js +494 -0
- package/dist/compiler/particleSemanticView.d.ts +51 -0
- package/dist/compiler/particleSemanticView.js +310 -0
- package/dist/compiler/particleWildcardRelation.d.ts +87 -0
- package/dist/compiler/particleWildcardRelation.js +143 -0
- package/dist/compiler/projectionScalar.d.ts +32 -0
- package/dist/compiler/projectionScalar.js +184 -0
- package/dist/compiler/re01CandidateAssignments.d.ts +95 -0
- package/dist/compiler/re01CandidateAssignments.js +341 -0
- package/dist/compiler/re01CandidateCorrespondence.d.ts +85 -0
- package/dist/compiler/re01CandidateCorrespondence.js +701 -0
- package/dist/compiler/re01TypeProperties.d.ts +70 -0
- package/dist/compiler/re01TypeProperties.js +120 -0
- package/dist/compiler/re01TypePropertyValidation.d.ts +22 -0
- package/dist/compiler/re01TypePropertyValidation.js +161 -0
- package/dist/compiler/resolveCanonicalGraph.d.ts +41 -0
- package/dist/compiler/resolveCanonicalGraph.js +240 -0
- package/dist/compiler/scalarSchemaAssessment.d.ts +424 -0
- package/dist/compiler/scalarSchemaAssessment.js +5198 -0
- package/dist/compiler/schemaAttributeGroupProperties.d.ts +16 -0
- package/dist/compiler/schemaAttributeGroupProperties.js +53 -0
- package/dist/compiler/schemaAttributeProperties.d.ts +9 -0
- package/dist/compiler/schemaAttributeProperties.js +11 -0
- package/dist/compiler/schemaAttributeUses.d.ts +110 -0
- package/dist/compiler/schemaAttributeUses.js +798 -0
- package/dist/compiler/schemaBinaryWordReconstruction.d.ts +9 -0
- package/dist/compiler/schemaBinaryWordReconstruction.js +33 -0
- package/dist/compiler/schemaBuiltinFacets.d.ts +13 -0
- package/dist/compiler/schemaBuiltinFacets.js +51 -0
- package/dist/compiler/schemaCalendarImages.d.ts +7 -0
- package/dist/compiler/schemaCalendarImages.js +204 -0
- package/dist/compiler/schemaCalendarLanguage.d.ts +10 -0
- package/dist/compiler/schemaCalendarLanguage.js +227 -0
- package/dist/compiler/schemaCompiler.d.ts +0 -1
- package/dist/compiler/schemaComponentEquality.d.ts +27 -0
- package/dist/compiler/schemaComponentEquality.js +446 -0
- package/dist/compiler/schemaConstructionAssessment.d.ts +79 -0
- package/dist/compiler/schemaConstructionAssessment.js +745 -0
- package/dist/compiler/schemaDatatypeValues.d.ts +3 -0
- package/dist/compiler/schemaDatatypeValues.js +2 -0
- package/dist/compiler/schemaDecimalLanguage.d.ts +6 -0
- package/dist/compiler/schemaDecimalLanguage.js +102 -0
- package/dist/compiler/schemaDeclarationPrimitives.d.ts +39 -0
- package/dist/compiler/schemaDeclarationPrimitives.js +211 -0
- package/dist/compiler/schemaDocumentSyntax.d.ts +54 -0
- package/dist/compiler/schemaDocumentSyntax.js +294 -0
- package/dist/compiler/schemaDurationLanguage.d.ts +10 -0
- package/dist/compiler/schemaDurationLanguage.js +170 -0
- package/dist/compiler/schemaElementInstance.d.ts +30 -0
- package/dist/compiler/schemaElementInstance.js +45 -0
- package/dist/compiler/schemaElementProperties.d.ts +15 -0
- package/dist/compiler/schemaElementProperties.js +23 -0
- package/dist/compiler/schemaEndpointWordCapacity.d.ts +35 -0
- package/dist/compiler/schemaEndpointWordCapacity.js +39 -0
- package/dist/compiler/schemaExactCalendar.d.ts +72 -0
- package/dist/compiler/schemaExactCalendar.js +264 -0
- package/dist/compiler/schemaFacetAnnotation.d.ts +31 -0
- package/dist/compiler/schemaFacetAnnotation.js +199 -0
- package/dist/compiler/schemaGeneratedScalarShape.d.ts +34 -0
- package/dist/compiler/schemaGeneratedScalarShape.js +178 -0
- package/dist/compiler/schemaIdentityConstraints.d.ts +72 -0
- package/dist/compiler/schemaIdentityConstraints.js +362 -0
- package/dist/compiler/schemaIeeeLanguage.d.ts +42 -0
- package/dist/compiler/schemaIeeeLanguage.js +759 -0
- package/dist/compiler/schemaIntegerImages.d.ts +10 -0
- package/dist/compiler/schemaIntegerImages.js +113 -0
- package/dist/compiler/schemaLexicalPredicates.d.ts +28 -0
- package/dist/compiler/schemaLexicalPredicates.js +63 -0
- package/dist/compiler/schemaNotationProperties.d.ts +31 -0
- package/dist/compiler/schemaNotationProperties.js +84 -0
- package/dist/compiler/schemaNumericImageConditions.d.ts +23 -0
- package/dist/compiler/schemaNumericImageConditions.js +66 -0
- package/dist/compiler/schemaParticleWildcardProperties.d.ts +19 -0
- package/dist/compiler/schemaParticleWildcardProperties.js +43 -0
- package/dist/compiler/schemaPattern.d.ts +1061 -0
- package/dist/compiler/schemaPattern.js +581 -0
- package/dist/compiler/schemaRegularLanguage.d.ts +66 -0
- package/dist/compiler/schemaRegularLanguage.js +1166 -0
- package/dist/compiler/schemaScalarContext.d.ts +85 -0
- package/dist/compiler/schemaScalarContext.js +78 -0
- package/dist/compiler/schemaScalarKernel.d.ts +181 -0
- package/dist/compiler/schemaScalarKernel.js +391 -0
- package/dist/compiler/schemaScalarWitnesses.d.ts +5 -0
- package/dist/compiler/schemaScalarWitnesses.js +118 -0
- package/dist/compiler/schemaSimpleTypeProperties.d.ts +94 -0
- package/dist/compiler/schemaSimpleTypeProperties.js +103 -0
- package/dist/compiler/schemaSourceGrammar.d.ts +26 -0
- package/dist/compiler/schemaSourceGrammar.js +290 -0
- package/dist/compiler/schemaSourceLexical.d.ts +3 -0
- package/dist/compiler/schemaSourceLexical.js +12 -0
- package/dist/compiler/schemaSourceValues.d.ts +50 -0
- package/dist/compiler/schemaSourceValues.js +225 -0
- package/dist/compiler/schemaSourceWildcards.d.ts +27 -0
- package/dist/compiler/schemaSourceWildcards.js +249 -0
- package/dist/compiler/schemaSymbolicSequences.d.ts +15 -0
- package/dist/compiler/schemaSymbolicSequences.js +99 -0
- package/dist/compiler/schemaSymbolicValueSets.d.ts +31 -0
- package/dist/compiler/schemaSymbolicValueSets.js +149 -0
- package/dist/compiler/schemaSyntaxAssessment.d.ts +24 -0
- package/dist/compiler/schemaSyntaxAssessment.js +361 -0
- package/dist/compiler/schemaTemporalAliases.d.ts +5 -0
- package/dist/compiler/schemaTemporalAliases.js +195 -0
- package/dist/compiler/schemaTokenImages.d.ts +8 -0
- package/dist/compiler/schemaTokenImages.js +142 -0
- package/dist/compiler/schemaTypeIdentity.d.ts +38 -0
- package/dist/compiler/schemaTypeIdentity.js +80 -0
- package/dist/compiler/schemaTypeRelations.d.ts +37 -0
- package/dist/compiler/schemaTypeRelations.js +576 -0
- package/dist/compiler/schemaUri.d.ts +12 -0
- package/dist/compiler/schemaUri.js +103 -0
- package/dist/compiler/schemaValueContext.d.ts +25 -0
- package/dist/compiler/schemaValueContext.js +1 -0
- package/dist/compiler/schemaValueImages.d.ts +9 -0
- package/dist/compiler/schemaValueImages.js +142 -0
- package/dist/compiler/schemaValueSequences.d.ts +14 -0
- package/dist/compiler/schemaValueSequences.js +19 -0
- package/dist/compiler/semanticBudget.d.ts +67 -0
- package/dist/compiler/semanticBudget.js +193 -0
- package/dist/compiler/semanticCatalog.d.ts +121 -0
- package/dist/compiler/semanticCatalog.js +160 -0
- package/dist/compiler/semanticContext.d.ts +183 -0
- package/dist/compiler/semanticContext.js +1207 -0
- package/dist/compiler/semanticTypeDependencies.d.ts +7 -0
- package/dist/compiler/semanticTypeDependencies.js +64 -0
- package/dist/compiler/semanticTypeReference.d.ts +23 -0
- package/dist/compiler/semanticTypeReference.js +36 -0
- package/dist/compiler/shapeResolver.d.ts +1 -1
- package/dist/compiler/shapeResolver.js +7 -9
- package/dist/compiler/soapHeaders.d.ts +16 -0
- package/dist/compiler/soapHeaders.js +42 -0
- package/dist/compiler/sourceSchemaBinding.d.ts +25 -0
- package/dist/compiler/sourceSchemaBinding.js +39 -0
- package/dist/compiler/standardSchemaComponents.d.ts +71 -0
- package/dist/compiler/standardSchemaComponents.js +74 -0
- package/dist/compiler/standardSchemaConstruction.d.ts +20 -0
- package/dist/compiler/standardSchemaConstruction.js +34 -0
- package/dist/compiler/structuralCompanions.d.ts +15 -0
- package/dist/compiler/structuralCompanions.js +232 -0
- package/dist/compiler/validateSemanticGraph.d.ts +4 -0
- package/dist/compiler/validateSemanticGraph.js +376 -0
- package/dist/compiler/wildcardAlgebra.d.ts +25 -0
- package/dist/compiler/wildcardAlgebra.js +155 -0
- package/dist/compiler/wsdlPolicyRequirements.d.ts +43 -0
- package/dist/compiler/wsdlPolicyRequirements.js +239 -0
- package/dist/config.d.ts +0 -1
- package/dist/gateway/generateCheckedGateway.d.ts +32 -0
- package/dist/gateway/generateCheckedGateway.js +293 -0
- package/dist/gateway/generateGateway.d.ts +0 -1
- package/dist/gateway/generateGateway.js +2 -2
- package/dist/gateway/generators.d.ts +0 -1
- package/dist/gateway/helpers.d.ts +0 -1
- package/dist/generation/componentShape.d.ts +14 -0
- package/dist/generation/componentShape.js +269 -0
- package/dist/generation/preamble.d.ts +0 -1
- package/dist/generation/sourceLayout.d.ts +13 -0
- package/dist/generation/sourceLayout.js +40 -0
- package/dist/generation/writeGeneratedSource.d.ts +0 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +3 -0
- package/dist/loader/fetch.d.ts +0 -1
- package/dist/loader/orderedSyntax.d.ts +84 -0
- package/dist/loader/orderedSyntax.js +222 -0
- package/dist/loader/resolutionDepth.d.ts +6 -0
- package/dist/loader/resolutionDepth.js +65 -0
- package/dist/loader/schemaInput.d.ts +80 -0
- package/dist/loader/schemaInput.js +249 -0
- package/dist/loader/schemaResources.d.ts +60 -0
- package/dist/loader/schemaResources.js +333 -0
- package/dist/loader/wsdlLoader.d.ts +0 -1
- package/dist/openapi/casing.d.ts +0 -1
- package/dist/openapi/generateOpenAPI.d.ts +0 -1
- package/dist/openapi/generateOpenAPI.js +2 -2
- package/dist/openapi/generatePaths.d.ts +0 -1
- package/dist/openapi/generateSchemas.d.ts +0 -1
- package/dist/openapi/security.d.ts +0 -1
- package/dist/pipeline.d.ts +6 -2
- package/dist/pipeline.js +13 -0
- package/dist/test/generateCheckedTests.d.ts +17 -0
- package/dist/test/generateCheckedTests.js +60 -0
- package/dist/test/generateTests.d.ts +0 -1
- package/dist/test/generateTests.js +2 -2
- package/dist/test/generators.d.ts +0 -1
- package/dist/test/mockData.d.ts +0 -1
- package/dist/test/mockData.js +20 -14
- package/dist/util/attributeWildcards.d.ts +0 -1
- package/dist/util/builder.d.ts +0 -1
- package/dist/util/catalogMeta.d.ts +0 -1
- package/dist/util/checkedCliDiagnostics.d.ts +11 -0
- package/dist/util/checkedCliDiagnostics.js +22 -0
- package/dist/util/cli.d.ts +0 -1
- package/dist/util/errors.d.ts +0 -1
- package/dist/util/imports.d.ts +0 -1
- package/dist/util/runtimeSource.d.ts +0 -1
- package/dist/util/runtimeSource.js +3 -5
- package/dist/util/securityConfig.d.ts +0 -1
- package/dist/util/streamConfig.d.ts +0 -1
- package/dist/util/tools.d.ts +0 -1
- package/dist/util/xmlWhitespace.d.ts +2 -0
- package/dist/util/xmlWhitespace.js +4 -0
- package/dist/xsd/primitives.d.ts +0 -1
- package/docs/agent-skill.md +2 -0
- package/docs/api-reference.md +1 -1
- package/docs/checked-gateway.md +210 -0
- package/docs/checked-generation.md +161 -0
- package/docs/cli-reference.md +43 -1
- package/docs/concepts.md +136 -1
- package/docs/configuration.md +5 -1
- package/docs/corpus.md +33 -0
- package/docs/direct-values.md +311 -0
- package/docs/examples/checked-forecast.wsdl +19 -0
- package/docs/gateway-guide.md +1 -1
- package/docs/generated-code.md +10 -5
- package/docs/mapping-contract.md +114 -0
- package/docs/migration-playbook.md +1 -1
- package/docs/output-anatomy.md +1 -1
- package/docs/start-here.md +8 -2
- package/docs/supported-patterns.md +17 -5
- package/docs/testing.md +117 -31
- package/llms.txt +7 -7
- package/package.json +79 -25
- package/src/generation/preambles/direct-client/typescript.preamble +3 -0
- package/src/runtime/checkedGatewayHost.tpl.txt +157 -0
- package/src/runtime/streamXml.ts +1 -1
- package/dist/app/generateApp.d.ts.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/client/generateClient.d.ts.map +0 -1
- package/dist/client/generateOperations.d.ts.map +0 -1
- package/dist/client/generateTypes.d.ts.map +0 -1
- package/dist/client/generateUtils.d.ts.map +0 -1
- package/dist/compiler/generateCatalog.d.ts.map +0 -1
- package/dist/compiler/schemaCompiler.d.ts.map +0 -1
- package/dist/compiler/shapeResolver.d.ts.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/gateway/generateGateway.d.ts.map +0 -1
- package/dist/gateway/generators.d.ts.map +0 -1
- package/dist/gateway/helpers.d.ts.map +0 -1
- package/dist/generation/preamble.d.ts.map +0 -1
- package/dist/generation/writeGeneratedSource.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/loader/fetch.d.ts.map +0 -1
- package/dist/loader/wsdlLoader.d.ts.map +0 -1
- package/dist/openapi/casing.d.ts.map +0 -1
- package/dist/openapi/generateOpenAPI.d.ts.map +0 -1
- package/dist/openapi/generatePaths.d.ts.map +0 -1
- package/dist/openapi/generateSchemas.d.ts.map +0 -1
- package/dist/openapi/security.d.ts.map +0 -1
- package/dist/pipeline.d.ts.map +0 -1
- package/dist/runtime/jsonArray.d.ts +0 -24
- package/dist/runtime/jsonArray.d.ts.map +0 -1
- package/dist/runtime/jsonArray.js +0 -52
- package/dist/runtime/ndjson.d.ts +0 -24
- package/dist/runtime/ndjson.d.ts.map +0 -1
- package/dist/runtime/ndjson.js +0 -30
- package/dist/runtime/streamXml.d.ts +0 -45
- package/dist/runtime/streamXml.d.ts.map +0 -1
- package/dist/runtime/streamXml.js +0 -212
- package/dist/test/generateTests.d.ts.map +0 -1
- package/dist/test/generators.d.ts.map +0 -1
- package/dist/test/mockData.d.ts.map +0 -1
- package/dist/util/attributeWildcards.d.ts.map +0 -1
- package/dist/util/builder.d.ts.map +0 -1
- package/dist/util/catalogMeta.d.ts.map +0 -1
- package/dist/util/cli.d.ts.map +0 -1
- package/dist/util/errors.d.ts.map +0 -1
- package/dist/util/imports.d.ts.map +0 -1
- package/dist/util/runtimeSource.d.ts.map +0 -1
- package/dist/util/securityConfig.d.ts.map +0 -1
- package/dist/util/streamConfig.d.ts.map +0 -1
- package/dist/util/tools.d.ts.map +0 -1
- package/dist/xsd/primitives.d.ts.map +0 -1
- package/docs/AGENTS.md +0 -47
- package/docs/README.md +0 -56
- package/docs/architecture.md +0 -149
- package/docs/decisions/001-test-generation.md +0 -36
- package/docs/decisions/002-streamable-responses.md +0 -330
- package/docs/file-naming-and-path-organization.md +0 -213
- package/docs/releases/README.md +0 -94
- package/docs/releases/v0.20.0.md +0 -22
- package/docs/releases/v0.21.0.md +0 -30
- package/docs/releases/v0.22.0.md +0 -30
- package/docs/releases/v0.23.0.md +0 -31
- package/docs/releases/v0.24.0.md +0 -38
- package/docs/releases/v0.25.0.md +0 -31
- package/docs/releases/v0.25.2.md +0 -32
- package/docs/releases/v0.26.0.md +0 -32
- package/docs/releases/v0.27.0.md +0 -31
- package/docs/releases/v0.28.0.md +0 -32
- package/docs/releases/v0.29.0.md +0 -32
- package/docs/releases/v0.30.0.md +0 -30
- package/docs/releases/v0.30.1.md +0 -31
- package/docs/releases/v0.30.2.md +0 -30
- package/docs/releases/v0.30.3.md +0 -33
- package/docs/releases/v0.31.0.md +0 -33
- package/docs/releases/v0.32.0.md +0 -33
- package/docs/releases/v0.33.0.md +0 -34
- package/docs/releases/v0.34.0.md +0 -30
- package/docs/releases/v0.35.0.md +0 -33
- package/docs/releases/v0.36.0.md +0 -32
- package/docs/releases/v0.37.0.md +0 -33
- package/docs/releases/v0.38.0.md +0 -35
- package/docs/releases/v0.39.0.md +0 -35
- package/docs/releases/v0.40.0.md +0 -45
- package/docs/releases/v0.40.1.md +0 -34
- package/docs/releases/v1.0.0.md +0 -42
- package/docs/releases/v1.0.1.md +0 -38
- package/docs/releases/v1.0.2.md +0 -51
- package/docs/releases/v1.0.3.md +0 -37
- package/docs/releases/v1.0.4.md +0 -45
- package/docs/releases/v1.0.5.md +0 -41
- package/docs/releases/v1.0.6.md +0 -35
- package/docs/releases/v1.0.7.md +0 -36
- package/docs/releases/v1.1.0.md +0 -42
- package/docs/releases/v1.1.1.md +0 -44
- package/docs/releases/v1.1.2.md +0 -42
- package/docs/releases/v1.1.3.md +0 -36
- package/docs/releases/v1.1.4.md +0 -36
- package/docs/roadmap/README.md +0 -107
- package/docs/roadmap/v1.0-capability-conformance-framework.md +0 -582
- package/docs/roadmap/v1.0-choice-union-mode.md +0 -90
- package/docs/roadmap/v1.0-contract-audit.md +0 -75
- package/docs/roadmap/v1.0-json-array-streaming.md +0 -101
- package/docs/roadmap/v1.0-openapi-fastify-compatibility.md +0 -99
- package/docs/roadmap/v1.0-release-candidate-gates.md +0 -92
- package/docs/roadmap/v1.0-wsdl-coverage-matrix.md +0 -200
- package/docs/roadmap/v1.0-xs-anyattribute-wildcard-bag.md +0 -932
- package/src/runtime/jsonArray.ts +0 -55
- package/src/runtime/ndjson.ts +0 -32
|
@@ -0,0 +1,759 @@
|
|
|
1
|
+
import { schemaRegularLanguages } from './schemaRegularLanguage.js';
|
|
2
|
+
import { schemaDecimalLanguages } from './schemaDecimalLanguage.js';
|
|
3
|
+
export function schemaIeeeLanguages(c, regular, expression) {
|
|
4
|
+
const decimals = schemaDecimalLanguages(c);
|
|
5
|
+
const charge = (owner, digits) => c.step(owner, (digits + 4) ** 2);
|
|
6
|
+
const normalize = (value, owner) => {
|
|
7
|
+
c.step(owner);
|
|
8
|
+
if (value.coefficient === 0n)
|
|
9
|
+
return { coefficient: 0n, scale: 0, digits: 1 };
|
|
10
|
+
c.step(owner, (value.digits ?? value.scale + 330) + 4);
|
|
11
|
+
const text = value.coefficient.toString();
|
|
12
|
+
let zeros = 0;
|
|
13
|
+
while (zeros < value.scale) {
|
|
14
|
+
c.step(owner, 3);
|
|
15
|
+
if (text[text.length - zeros - 1] !== '0')
|
|
16
|
+
break;
|
|
17
|
+
zeros++;
|
|
18
|
+
}
|
|
19
|
+
if (!zeros)
|
|
20
|
+
return { ...value, digits: text.length };
|
|
21
|
+
charge(owner, text.length + zeros);
|
|
22
|
+
c.step(owner, 4);
|
|
23
|
+
return { coefficient: value.coefficient / 10n ** BigInt(zeros), scale: value.scale - zeros, digits: text.length - zeros };
|
|
24
|
+
};
|
|
25
|
+
const key = (value, owner) => {
|
|
26
|
+
charge(owner, value.digits ?? value.scale + 330);
|
|
27
|
+
c.step(owner, value.scale + (value.digits ?? 330) + 2);
|
|
28
|
+
const digits = value.coefficient.toString().padStart(value.scale + 1, '0');
|
|
29
|
+
return value.scale ? digits.slice(0, -value.scale) + '.' + digits.slice(-value.scale) : digits;
|
|
30
|
+
};
|
|
31
|
+
const add = (a, b, owner) => {
|
|
32
|
+
const scale = Math.max(a.scale, b.scale), digits = Math.max((a.digits ?? 330) + scale - a.scale, (b.digits ?? 330) + scale - b.scale) + 1;
|
|
33
|
+
charge(owner, digits);
|
|
34
|
+
return normalize({ coefficient: a.coefficient * 10n ** BigInt(scale - a.scale) + b.coefficient * 10n ** BigInt(scale - b.scale), scale, digits }, owner);
|
|
35
|
+
};
|
|
36
|
+
const half = (a, owner) => {
|
|
37
|
+
charge(owner, a.digits ?? a.scale + 330);
|
|
38
|
+
return normalize(a.coefficient % 2n === 0n
|
|
39
|
+
? { coefficient: a.coefficient / 2n, scale: a.scale, digits: a.digits } : { coefficient: a.coefficient * 5n, scale: a.scale + 1, digits: (a.digits ?? 330) + 1 }, owner);
|
|
40
|
+
};
|
|
41
|
+
const binary = (significand, exponent, owner) => {
|
|
42
|
+
const digits = exponent >= 0 ? Math.floor((exponent + 53) / 3) + 1 : -exponent + 18;
|
|
43
|
+
charge(owner, digits);
|
|
44
|
+
return normalize(exponent >= 0 ? { coefficient: significand << BigInt(exponent), scale: 0, digits }
|
|
45
|
+
: { coefficient: significand * 5n ** BigInt(-exponent), scale: -exponent, digits }, owner);
|
|
46
|
+
};
|
|
47
|
+
const ieeeValue = (bits, single, owner) => {
|
|
48
|
+
c.step(owner, 16);
|
|
49
|
+
const precision = single ? 24 : 53, bias = single ? 127 : 1023;
|
|
50
|
+
const mask = (1n << BigInt(precision - 1)) - 1n, fraction = bits & mask, exponent = Number(bits >> BigInt(precision - 1));
|
|
51
|
+
return binary(fraction + (exponent ? 1n << BigInt(precision - 1) : 0n), (exponent ? exponent - bias : 1 - bias) - (precision - 1), owner);
|
|
52
|
+
};
|
|
53
|
+
const inverseCache = new Map();
|
|
54
|
+
const copyIntervals = (input, owner) => {
|
|
55
|
+
c.step(owner, input.length * 16 + 2);
|
|
56
|
+
return input.map(interval => ({ ...interval,
|
|
57
|
+
...(interval.lower ? { lower: { ...interval.lower, value: { ...interval.lower.value } } } : {}),
|
|
58
|
+
...(interval.upper ? { upper: { ...interval.upper, value: { ...interval.upper.value } } } : {}) }));
|
|
59
|
+
};
|
|
60
|
+
const inverseIntervals = (target, owner) => {
|
|
61
|
+
c.text(target.family, owner);
|
|
62
|
+
c.text(target.canonical, owner);
|
|
63
|
+
c.step(owner, target.family.length + target.canonical.length + 4);
|
|
64
|
+
const key = target.family + ':' + target.canonical, cached = inverseCache.get(key);
|
|
65
|
+
if (cached)
|
|
66
|
+
return copyIntervals(cached, owner);
|
|
67
|
+
const result = computeInverseIntervals(target, owner);
|
|
68
|
+
// Cache only a completed inverse, and keep its endpoints private. A caller
|
|
69
|
+
// can never mutate a later inverse result or avoid a sticky budget failure.
|
|
70
|
+
const retained = copyIntervals(result, owner);
|
|
71
|
+
c.step(owner, 2);
|
|
72
|
+
inverseCache.set(key, retained);
|
|
73
|
+
return result;
|
|
74
|
+
};
|
|
75
|
+
const computeInverseIntervals = (target, owner) => {
|
|
76
|
+
const single = target.family === 'float', p = single ? 24 : 53, minimum = single ? -126 : -1022, maximum = single ? 127 : 1023;
|
|
77
|
+
if (target.canonical === 'NaN')
|
|
78
|
+
return [];
|
|
79
|
+
if (target.canonical === '0') {
|
|
80
|
+
const threshold = binary(1n, minimum - p, owner);
|
|
81
|
+
c.step(owner, 6);
|
|
82
|
+
return [{ negative: false, upper: { value: threshold, inclusive: true } }, { negative: true, upper: { value: threshold, inclusive: true } }];
|
|
83
|
+
}
|
|
84
|
+
const infinity = target.canonical === 'Infinity' || target.canonical === '-Infinity', negative = target.canonical.startsWith('-');
|
|
85
|
+
// Overflow tie goes to the even carried significand (infinity).
|
|
86
|
+
const overflow = binary((1n << BigInt(p + 1)) - 1n, maximum - p, owner);
|
|
87
|
+
if (infinity) {
|
|
88
|
+
c.step(owner, 4);
|
|
89
|
+
return [{ negative, lower: { value: overflow, inclusive: true } }];
|
|
90
|
+
}
|
|
91
|
+
c.step(owner, 24 + target.canonical.length);
|
|
92
|
+
const bytes = new ArrayBuffer(8), view = new DataView(bytes), number = Math.abs(Number(target.canonical));
|
|
93
|
+
let bits;
|
|
94
|
+
if (single) {
|
|
95
|
+
view.setFloat32(0, number);
|
|
96
|
+
bits = BigInt(view.getUint32(0));
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
view.setFloat64(0, number);
|
|
100
|
+
bits = view.getBigUint64(0);
|
|
101
|
+
}
|
|
102
|
+
const actual = ieeeValue(bits, single, owner), prior = ieeeValue(bits - 1n, single, owner);
|
|
103
|
+
const last = single ? 0x7f7fffffn : 0x7fefffffffffffffn;
|
|
104
|
+
const next = bits === last ? undefined : ieeeValue(bits + 1n, single, owner), even = bits % 2n === 0n;
|
|
105
|
+
c.step(owner, 6);
|
|
106
|
+
return [{ negative, lower: { value: half(add(prior, actual, owner), owner), inclusive: even },
|
|
107
|
+
upper: { value: next ? half(add(actual, next, owner), owner) : overflow, inclusive: even } }];
|
|
108
|
+
};
|
|
109
|
+
const order = (value, owner) => {
|
|
110
|
+
charge(owner, value.digits ?? value.scale + 330);
|
|
111
|
+
return value.coefficient.toString().length - value.scale - 1;
|
|
112
|
+
};
|
|
113
|
+
const scaled = (value, exponent, owner) => {
|
|
114
|
+
const scale = value.scale + exponent, digits = (value.digits ?? 330) + Math.max(0, -scale);
|
|
115
|
+
charge(owner, digits);
|
|
116
|
+
return normalize(scale >= 0 ? { coefficient: value.coefficient, scale, digits }
|
|
117
|
+
: { coefficient: value.coefficient * 10n ** BigInt(-scale), scale: 0, digits }, owner);
|
|
118
|
+
};
|
|
119
|
+
const move = (program, state, cp, owner) => {
|
|
120
|
+
for (const edge of program.states[state].transitions) {
|
|
121
|
+
c.step(owner);
|
|
122
|
+
if (cp >= edge.lo && cp <= edge.hi)
|
|
123
|
+
return edge.to;
|
|
124
|
+
}
|
|
125
|
+
return undefined;
|
|
126
|
+
};
|
|
127
|
+
const suffix = (program, start, owner) => {
|
|
128
|
+
c.step(owner, 2);
|
|
129
|
+
return regular.fromAutomaton({ states: program.states, start }, owner);
|
|
130
|
+
};
|
|
131
|
+
const integerInverse = (value, owner) => {
|
|
132
|
+
c.step(owner, 32);
|
|
133
|
+
const negative = value < 0n, digits = (negative ? -value : value).toString();
|
|
134
|
+
c.text(digits, owner);
|
|
135
|
+
c.step(owner, digits.length + 24);
|
|
136
|
+
return expression(value === 0n ? '[+\\-]?0+' : (negative ? '\\-' : '[+]?') + '0*' + digits, owner);
|
|
137
|
+
};
|
|
138
|
+
const modulo = (period, residue, owner) => {
|
|
139
|
+
// Two signed remainder copies and a nonaccepting initial state.
|
|
140
|
+
c.step(owner, period * 64 + 16);
|
|
141
|
+
const states = [];
|
|
142
|
+
const positive = 1, negative = period + 1, signPositive = period * 2 + 1, signNegative = signPositive + 1;
|
|
143
|
+
for (let index = 0; index <= signNegative; index++)
|
|
144
|
+
states.push({ accepting: false, transitions: [] });
|
|
145
|
+
states[0].transitions.push({ to: signPositive, lo: 43, hi: 43 }, { to: signNegative, lo: 45, hi: 45 });
|
|
146
|
+
for (const [start, offset] of [[0, positive], [signPositive, positive], [signNegative, negative]])
|
|
147
|
+
for (let digit = 0; digit < 10; digit++) {
|
|
148
|
+
c.step(owner, 4);
|
|
149
|
+
states[start].transitions.push({ to: offset + digit % period, lo: 48 + digit, hi: 48 + digit });
|
|
150
|
+
}
|
|
151
|
+
for (let remainder = 0; remainder < period; remainder++)
|
|
152
|
+
for (const offset of [positive, negative]) {
|
|
153
|
+
c.step(owner, 2);
|
|
154
|
+
states[offset + remainder].accepting = remainder === (offset === positive ? residue : (period - residue) % period);
|
|
155
|
+
for (let digit = 0; digit < 10; digit++) {
|
|
156
|
+
c.step(owner, 4);
|
|
157
|
+
states[offset + remainder].transitions.push({ to: offset + (remainder * 10 + digit) % period, lo: 48 + digit, hi: 48 + digit });
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return regular.fromAutomaton({ states, start: 0 }, owner);
|
|
161
|
+
};
|
|
162
|
+
const search = (language, interval, exponentOrder, relation, owner) => {
|
|
163
|
+
const input = regular.automaton(language, owner);
|
|
164
|
+
c.step(owner, input.states.length * 3 + 4);
|
|
165
|
+
const incoming = input.states.map(() => []), productive = new Set(), pending = [];
|
|
166
|
+
for (let from = 0; from < input.states.length; from++) {
|
|
167
|
+
c.step(owner);
|
|
168
|
+
if (input.states[from].accepting) {
|
|
169
|
+
c.step(owner, 2);
|
|
170
|
+
productive.add(from);
|
|
171
|
+
pending.push(from);
|
|
172
|
+
}
|
|
173
|
+
for (const edge of input.states[from].transitions) {
|
|
174
|
+
c.step(owner);
|
|
175
|
+
incoming[edge.to].push(from);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
while (pending.length)
|
|
179
|
+
for (const previous of incoming[pending.pop()]) {
|
|
180
|
+
c.step(owner);
|
|
181
|
+
if (!productive.has(previous)) {
|
|
182
|
+
c.step(owner, 2);
|
|
183
|
+
productive.add(previous);
|
|
184
|
+
pending.push(previous);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (!productive.has(input.start))
|
|
188
|
+
return undefined;
|
|
189
|
+
c.step(owner, input.states.length * 3 + 2);
|
|
190
|
+
const program = { start: input.start, states: input.states.map(state => {
|
|
191
|
+
c.step(owner, state.transitions.length + 2);
|
|
192
|
+
return { ...state, transitions: state.transitions.filter(edge => productive.has(edge.to)) };
|
|
193
|
+
}) };
|
|
194
|
+
const lower = relation === 'equal' && interval.lower ? scaled(interval.lower.value, exponentOrder, owner) : undefined;
|
|
195
|
+
const upper = relation === 'equal' && interval.upper ? scaled(interval.upper.value, exponentOrder, owner) : undefined;
|
|
196
|
+
const threshold = (value) => value ? key(value, owner).replace('.', '') : undefined;
|
|
197
|
+
const low = threshold(lower), high = threshold(upper);
|
|
198
|
+
// Bounds outside [1,10) either disappear or reject this whole order.
|
|
199
|
+
const lowerText = lower ? key(lower, owner) : undefined, upperText = upper ? key(upper, owner) : undefined;
|
|
200
|
+
if (lowerText && (lowerText.startsWith('0.') || lowerText === '0'))
|
|
201
|
+
return search(language, { ...interval, lower: undefined }, exponentOrder, relation, owner);
|
|
202
|
+
if (lowerText && Number(lowerText.split('.')[0]) >= 10)
|
|
203
|
+
return undefined;
|
|
204
|
+
if (upperText && Number(upperText.split('.')[0]) >= 10)
|
|
205
|
+
return search(language, { ...interval, upper: undefined }, exponentOrder, relation, owner);
|
|
206
|
+
if (upperText && (upperText.startsWith('0.') || upperText === '0'))
|
|
207
|
+
return undefined;
|
|
208
|
+
const compareDigit = (state, digits, digit) => {
|
|
209
|
+
if (digits === undefined || state < 0)
|
|
210
|
+
return state;
|
|
211
|
+
c.step(owner);
|
|
212
|
+
const expected = state < digits.length ? Number(digits[state]) : 0;
|
|
213
|
+
return digit < expected ? -1 : digit > expected ? -2 : Math.min(state + 1, digits.length);
|
|
214
|
+
};
|
|
215
|
+
const compareEnd = (state, digits) => {
|
|
216
|
+
if (digits === undefined)
|
|
217
|
+
return 0;
|
|
218
|
+
if (state === -1)
|
|
219
|
+
return -1;
|
|
220
|
+
if (state === -2)
|
|
221
|
+
return 1;
|
|
222
|
+
c.step(owner, digits.length - state + 1);
|
|
223
|
+
return /[1-9]/.test(digits.slice(state)) ? -1 : 0;
|
|
224
|
+
};
|
|
225
|
+
for (const fractional of [false, true]) {
|
|
226
|
+
c.step(owner, 6);
|
|
227
|
+
const states = [], edges = [[]], ids = new Map(), finals = [];
|
|
228
|
+
const publish = (state) => {
|
|
229
|
+
c.step(owner, 32);
|
|
230
|
+
const key = JSON.stringify(state), prior = ids.get(key);
|
|
231
|
+
if (prior !== undefined)
|
|
232
|
+
return prior;
|
|
233
|
+
c.step(owner, key.length + 10);
|
|
234
|
+
const id = states.length + 1;
|
|
235
|
+
ids.set(key, id);
|
|
236
|
+
states.push(state);
|
|
237
|
+
edges.push([]);
|
|
238
|
+
return id;
|
|
239
|
+
};
|
|
240
|
+
const first = (source, char) => { const id = publish({ source, dotted: false, nonzero: false, lo: 0, hi: 0 }); c.step(owner, 5); edges[0].push({ to: id, weight: 0, char }); };
|
|
241
|
+
if (!interval.negative) {
|
|
242
|
+
first(program.start, '');
|
|
243
|
+
const plus = move(program, program.start, 43, owner);
|
|
244
|
+
if (plus !== undefined)
|
|
245
|
+
first(plus, '+');
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
const minus = move(program, program.start, 45, owner);
|
|
249
|
+
if (minus !== undefined)
|
|
250
|
+
first(minus, '-');
|
|
251
|
+
}
|
|
252
|
+
for (let cursor = 0; cursor < states.length; cursor++) {
|
|
253
|
+
c.step(owner, 4);
|
|
254
|
+
const state = states[cursor], node = cursor + 1;
|
|
255
|
+
const lowOrder = compareEnd(state.lo, low), highOrder = compareEnd(state.hi, high);
|
|
256
|
+
const accepted = state.nonzero && (!low || lowOrder > 0 || lowOrder === 0 && interval.lower.inclusive)
|
|
257
|
+
&& (!high || highOrder < 0 || highOrder === 0 && interval.upper.inclusive);
|
|
258
|
+
if (accepted) {
|
|
259
|
+
if (program.states[state.source].accepting) {
|
|
260
|
+
c.step(owner, 4);
|
|
261
|
+
finals.push({ node, marker: '' });
|
|
262
|
+
}
|
|
263
|
+
for (const marker of ['e', 'E']) {
|
|
264
|
+
const next = move(program, state.source, marker.charCodeAt(0), owner);
|
|
265
|
+
if (next !== undefined) {
|
|
266
|
+
c.step(owner, 4);
|
|
267
|
+
finals.push({ node, marker, exponent: suffix(program, next, owner) });
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (!state.dotted) {
|
|
272
|
+
const dot = move(program, state.source, 46, owner);
|
|
273
|
+
if (dot !== undefined) {
|
|
274
|
+
const next = publish({ ...state, source: dot, dotted: true });
|
|
275
|
+
c.step(owner, 5);
|
|
276
|
+
edges[node].push({ to: next, weight: 0, char: '.' });
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
for (let digit = 0; digit < 10; digit++) {
|
|
280
|
+
const nextSource = move(program, state.source, 48 + digit, owner);
|
|
281
|
+
if (nextSource === undefined)
|
|
282
|
+
continue;
|
|
283
|
+
if (!state.nonzero && digit !== 0 && state.dotted !== fractional)
|
|
284
|
+
continue;
|
|
285
|
+
const nonzero = state.nonzero || digit !== 0;
|
|
286
|
+
const next = publish({ ...state, source: nextSource, nonzero,
|
|
287
|
+
lo: nonzero ? compareDigit(state.lo, low, digit) : state.lo,
|
|
288
|
+
hi: nonzero ? compareDigit(state.hi, high, digit) : state.hi });
|
|
289
|
+
const weight = fractional ? state.dotted && !state.nonzero ? 1 : 0 : state.nonzero && !state.dotted ? 1 : 0;
|
|
290
|
+
c.step(owner, 5);
|
|
291
|
+
edges[node].push({ to: next, weight, char: String(digit) });
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
if (!finals.length)
|
|
295
|
+
continue;
|
|
296
|
+
const closure = (input) => {
|
|
297
|
+
c.step(owner, input.length * 2 + 4);
|
|
298
|
+
const seen = new Set(input), pending = [...input];
|
|
299
|
+
while (pending.length)
|
|
300
|
+
for (const edge of edges[pending.pop()]) {
|
|
301
|
+
c.step(owner, 2);
|
|
302
|
+
if (!edge.weight && !seen.has(edge.to)) {
|
|
303
|
+
c.step(owner, 2);
|
|
304
|
+
seen.add(edge.to);
|
|
305
|
+
pending.push(edge.to);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
c.step(owner, seen.size ** 2 + seen.size + 1);
|
|
309
|
+
return [...seen].sort((a, b) => a - b);
|
|
310
|
+
};
|
|
311
|
+
const path = (count, target) => {
|
|
312
|
+
c.step(owner, Number(count > BigInt(Math.floor(Number.MAX_SAFE_INTEGER / 16)) ? BigInt(Number.MAX_SAFE_INTEGER) : count * 16n));
|
|
313
|
+
const wanted = Number(count);
|
|
314
|
+
c.step(owner, 8);
|
|
315
|
+
const queue = [{ node: 0, count: 0, char: '' }], seen = new Set(['0:0']);
|
|
316
|
+
for (let cursor = 0; cursor < queue.length; cursor++) {
|
|
317
|
+
c.step(owner);
|
|
318
|
+
const step = queue[cursor];
|
|
319
|
+
if (step.node === target && step.count === wanted) {
|
|
320
|
+
c.step(owner, 2);
|
|
321
|
+
const chars = [];
|
|
322
|
+
let index = cursor;
|
|
323
|
+
while (index !== undefined) {
|
|
324
|
+
c.step(owner, 2);
|
|
325
|
+
const item = queue[index];
|
|
326
|
+
chars.push(item.char);
|
|
327
|
+
index = item.prior;
|
|
328
|
+
}
|
|
329
|
+
c.step(owner, chars.length * 2 + 1);
|
|
330
|
+
return chars.reverse().join('');
|
|
331
|
+
}
|
|
332
|
+
for (const edge of edges[step.node]) {
|
|
333
|
+
c.step(owner, 12);
|
|
334
|
+
const next = step.count + edge.weight, identity = edge.to + ':' + next;
|
|
335
|
+
if (next > wanted || seen.has(identity))
|
|
336
|
+
continue;
|
|
337
|
+
c.step(owner, identity.length + 8);
|
|
338
|
+
seen.add(identity);
|
|
339
|
+
queue.push({ node: edge.to, count: next, prior: cursor, char: edge.char });
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
throw new TypeError('Accepted unary count must have a mantissa path');
|
|
343
|
+
};
|
|
344
|
+
const probe = (final, count, exponent) => {
|
|
345
|
+
const e = fractional ? BigInt(exponentOrder) + count : BigInt(exponentOrder) - count;
|
|
346
|
+
if (!final.exponent) {
|
|
347
|
+
if (relation === 'equal' ? e !== 0n : relation === 'less' ? e <= 0n : e >= 0n)
|
|
348
|
+
return undefined;
|
|
349
|
+
return path(count, final.node);
|
|
350
|
+
}
|
|
351
|
+
let word = exponent;
|
|
352
|
+
if (word === undefined) {
|
|
353
|
+
let candidate = integerInverse(e, owner);
|
|
354
|
+
if (relation !== 'equal') {
|
|
355
|
+
const text = decimals.relation(e.toString(), relation === 'greater', owner);
|
|
356
|
+
candidate = text === undefined ? regular.union([], owner) : expression(text, owner);
|
|
357
|
+
}
|
|
358
|
+
word = regular.witness(regular.intersect([final.exponent, candidate], owner), owner);
|
|
359
|
+
}
|
|
360
|
+
if (word === undefined)
|
|
361
|
+
return undefined;
|
|
362
|
+
const mantissa = path(count, final.node);
|
|
363
|
+
c.step(owner, mantissa.length + word.length + 2);
|
|
364
|
+
return mantissa + final.marker + word;
|
|
365
|
+
};
|
|
366
|
+
c.step(owner, 6);
|
|
367
|
+
const orbit = [], known = new Map();
|
|
368
|
+
let current = closure([0]), prefix = 0;
|
|
369
|
+
while (true) {
|
|
370
|
+
c.step(owner, current.length * 16 + 4);
|
|
371
|
+
const identity = JSON.stringify(current), previous = known.get(identity);
|
|
372
|
+
if (previous !== undefined) {
|
|
373
|
+
prefix = previous;
|
|
374
|
+
break;
|
|
375
|
+
}
|
|
376
|
+
c.step(owner, identity.length + current.length + 4);
|
|
377
|
+
known.set(identity, orbit.length);
|
|
378
|
+
orbit.push(current);
|
|
379
|
+
for (const final of finals) {
|
|
380
|
+
c.step(owner, current.length + 1);
|
|
381
|
+
if (!current.includes(final.node))
|
|
382
|
+
continue;
|
|
383
|
+
const word = probe(final, BigInt(orbit.length - 1));
|
|
384
|
+
if (word !== undefined)
|
|
385
|
+
return word;
|
|
386
|
+
}
|
|
387
|
+
c.step(owner, 2);
|
|
388
|
+
const next = [];
|
|
389
|
+
for (const node of current)
|
|
390
|
+
for (const edge of edges[node]) {
|
|
391
|
+
c.step(owner);
|
|
392
|
+
if (edge.weight) {
|
|
393
|
+
c.step(owner);
|
|
394
|
+
next.push(edge.to);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
current = closure(next);
|
|
398
|
+
}
|
|
399
|
+
const period = orbit.length - prefix;
|
|
400
|
+
for (let index = prefix; index < orbit.length; index++)
|
|
401
|
+
for (const final of finals) {
|
|
402
|
+
c.step(owner, orbit[index].length + 2);
|
|
403
|
+
if (!orbit[index].includes(final.node))
|
|
404
|
+
continue;
|
|
405
|
+
if (!final.exponent) {
|
|
406
|
+
const required = BigInt(fractional ? -exponentOrder : exponentOrder);
|
|
407
|
+
let count;
|
|
408
|
+
if (relation === 'equal' && required >= BigInt(index) && (required - BigInt(index)) % BigInt(period) === 0n)
|
|
409
|
+
count = required;
|
|
410
|
+
else if (fractional && relation === 'less' || !fractional && relation === 'greater') {
|
|
411
|
+
const minimum = required >= BigInt(index) ? required + 1n : BigInt(index);
|
|
412
|
+
count = BigInt(index) + ((minimum - BigInt(index) + BigInt(period) - 1n) / BigInt(period)) * BigInt(period);
|
|
413
|
+
}
|
|
414
|
+
if (count !== undefined) {
|
|
415
|
+
const word = probe(final, count);
|
|
416
|
+
if (word !== undefined)
|
|
417
|
+
return word;
|
|
418
|
+
}
|
|
419
|
+
continue;
|
|
420
|
+
}
|
|
421
|
+
const initial = fractional ? BigInt(exponentOrder + index) : BigInt(exponentOrder - index);
|
|
422
|
+
if (relation !== 'equal') {
|
|
423
|
+
// For an unbounded available count the favorable half-line is
|
|
424
|
+
// automatic; any accepted exponent supplies some large count.
|
|
425
|
+
if (fractional && relation === 'less' || !fractional && relation === 'greater') {
|
|
426
|
+
const word = regular.witness(final.exponent, owner);
|
|
427
|
+
if (word === undefined)
|
|
428
|
+
continue;
|
|
429
|
+
charge(owner, word.length + 4);
|
|
430
|
+
const exponent = BigInt(word), boundary = fractional ? exponent - BigInt(exponentOrder) : BigInt(exponentOrder) - exponent;
|
|
431
|
+
const lowerCount = boundary >= BigInt(index) ? boundary + 1n : BigInt(index);
|
|
432
|
+
c.step(owner, 32);
|
|
433
|
+
const count = BigInt(index) + ((lowerCount - BigInt(index) + BigInt(period) - 1n) / BigInt(period)) * BigInt(period);
|
|
434
|
+
const result = probe(final, count, word);
|
|
435
|
+
if (result !== undefined)
|
|
436
|
+
return result;
|
|
437
|
+
}
|
|
438
|
+
continue;
|
|
439
|
+
}
|
|
440
|
+
c.step(owner, 32);
|
|
441
|
+
const residue = Number((initial % BigInt(period) + BigInt(period)) % BigInt(period));
|
|
442
|
+
const comparison = decimals.relation(initial.toString(), fractional ? false : true, owner);
|
|
443
|
+
const outside = comparison === undefined ? regular.union([], owner) : expression(comparison, owner);
|
|
444
|
+
const allowed = regular.intersect([final.exponent, modulo(period, residue, owner), regular.negate(outside, owner)], owner);
|
|
445
|
+
const word = regular.witness(allowed, owner);
|
|
446
|
+
if (word === undefined)
|
|
447
|
+
continue;
|
|
448
|
+
charge(owner, word.length + 4);
|
|
449
|
+
const exponent = BigInt(word), count = fractional ? exponent - BigInt(exponentOrder) : BigInt(exponentOrder) - exponent;
|
|
450
|
+
const result = probe(final, count, word);
|
|
451
|
+
if (result !== undefined)
|
|
452
|
+
return result;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
return undefined;
|
|
456
|
+
};
|
|
457
|
+
const intervalWitness = (language, interval, owner) => {
|
|
458
|
+
if (!interval.lower && !interval.upper)
|
|
459
|
+
return regular.witness(regular.intersect([language,
|
|
460
|
+
expression((interval.negative ? '\\-' : '[+]?') + '([0-9]+([.][0-9]*)?|[.][0-9]+)([eE][+\\-]?[0-9]+)?', owner)], owner), owner);
|
|
461
|
+
if (!interval.lower) {
|
|
462
|
+
const zero = regular.witness(regular.intersect([language, expression((interval.negative ? '\\-' : '[+]?') + '(0+([.]0*)?|[.]0+)([eE][+\\-]?[0-9]+)?', owner)], owner), owner);
|
|
463
|
+
if (zero !== undefined)
|
|
464
|
+
return zero;
|
|
465
|
+
}
|
|
466
|
+
const first = interval.lower ? order(interval.lower.value, owner) : undefined, last = interval.upper ? order(interval.upper.value, owner) : undefined;
|
|
467
|
+
if (first === undefined && last !== undefined) {
|
|
468
|
+
const word = search(language, interval, last, 'less', owner);
|
|
469
|
+
if (word !== undefined)
|
|
470
|
+
return word;
|
|
471
|
+
}
|
|
472
|
+
if (last === undefined && first !== undefined) {
|
|
473
|
+
const word = search(language, interval, first, 'greater', owner);
|
|
474
|
+
if (word !== undefined)
|
|
475
|
+
return word;
|
|
476
|
+
}
|
|
477
|
+
for (let exponent = first ?? last; exponent <= (last ?? first); exponent++) {
|
|
478
|
+
c.step(owner);
|
|
479
|
+
const word = search(language, interval, exponent, 'equal', owner);
|
|
480
|
+
if (word !== undefined)
|
|
481
|
+
return word;
|
|
482
|
+
}
|
|
483
|
+
return undefined;
|
|
484
|
+
};
|
|
485
|
+
const witness = (language, target, owner) => {
|
|
486
|
+
c.text(target.canonical, owner);
|
|
487
|
+
if (target.canonical === 'NaN')
|
|
488
|
+
return regular.witness(regular.intersect([language, expression('NaN', owner)], owner), owner);
|
|
489
|
+
if (target.canonical === 'Infinity' || target.canonical === '-Infinity') {
|
|
490
|
+
const literal = regular.witness(regular.intersect([language, expression(target.canonical[0] === '-' ? '\\-INF' : 'INF', owner)], owner), owner);
|
|
491
|
+
if (literal !== undefined)
|
|
492
|
+
return literal;
|
|
493
|
+
}
|
|
494
|
+
if (target.canonical === '0') {
|
|
495
|
+
const zero = regular.witness(regular.intersect([language, expression('[+\\-]?(0+([.]0*)?|[.]0+)([eE][+\\-]?[0-9]+)?', owner)], owner), owner);
|
|
496
|
+
if (zero !== undefined)
|
|
497
|
+
return zero;
|
|
498
|
+
}
|
|
499
|
+
for (const interval of inverseIntervals(target, owner)) {
|
|
500
|
+
const word = intervalWitness(language, interval, owner);
|
|
501
|
+
if (word !== undefined)
|
|
502
|
+
return word;
|
|
503
|
+
}
|
|
504
|
+
return undefined;
|
|
505
|
+
};
|
|
506
|
+
const rank = (value, owner) => {
|
|
507
|
+
c.text(value.canonical, owner);
|
|
508
|
+
c.step(owner, 24);
|
|
509
|
+
const bytes = new ArrayBuffer(8), view = new DataView(bytes), number = Number(value.canonical);
|
|
510
|
+
let bits;
|
|
511
|
+
if (value.family === 'float') {
|
|
512
|
+
view.setFloat32(0, Math.abs(number));
|
|
513
|
+
bits = BigInt(view.getUint32(0));
|
|
514
|
+
}
|
|
515
|
+
else {
|
|
516
|
+
view.setFloat64(0, Math.abs(number));
|
|
517
|
+
bits = view.getBigUint64(0);
|
|
518
|
+
}
|
|
519
|
+
return number < 0 ? -bits : bits;
|
|
520
|
+
};
|
|
521
|
+
const rankedValue = (bits, single, owner) => {
|
|
522
|
+
c.step(owner, 32);
|
|
523
|
+
const bytes = new ArrayBuffer(8), view = new DataView(bytes);
|
|
524
|
+
let number;
|
|
525
|
+
if (single) {
|
|
526
|
+
view.setUint32(0, Number(bits));
|
|
527
|
+
number = view.getFloat32(0);
|
|
528
|
+
}
|
|
529
|
+
else {
|
|
530
|
+
view.setBigUint64(0, bits);
|
|
531
|
+
number = view.getFloat64(0);
|
|
532
|
+
}
|
|
533
|
+
c.step(owner, 32);
|
|
534
|
+
return { family: single ? 'float' : 'double', canonical: String(number) };
|
|
535
|
+
};
|
|
536
|
+
/** A complete predicate over IEEE ranks, converted to exact input intervals. */
|
|
537
|
+
const wideningWitness = (language, family, supplied, prior, owner) => {
|
|
538
|
+
const single = family === 'float', infinity = single ? 0x7f800000n : 0x7ff0000000000000n;
|
|
539
|
+
let lo = -infinity, hi = infinity, ordinary = true, nan = true;
|
|
540
|
+
for (const bound of supplied) {
|
|
541
|
+
c.step(owner, 6);
|
|
542
|
+
if (bound.value.canonical === 'NaN') {
|
|
543
|
+
ordinary = false;
|
|
544
|
+
if (bound.name.endsWith('Exclusive'))
|
|
545
|
+
nan = false;
|
|
546
|
+
continue;
|
|
547
|
+
}
|
|
548
|
+
nan = false;
|
|
549
|
+
const value = rank(bound.value, owner);
|
|
550
|
+
if (bound.name.startsWith('min')) {
|
|
551
|
+
const minimum = value + (bound.name.endsWith('Exclusive') ? 1n : 0n);
|
|
552
|
+
if (minimum > lo)
|
|
553
|
+
lo = minimum;
|
|
554
|
+
}
|
|
555
|
+
else {
|
|
556
|
+
const maximum = value - (bound.name.endsWith('Exclusive') ? 1n : 0n);
|
|
557
|
+
if (maximum < hi)
|
|
558
|
+
hi = maximum;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
if (prior.value.canonical === 'NaN') {
|
|
562
|
+
if (!prior.name.endsWith('Exclusive'))
|
|
563
|
+
nan = false;
|
|
564
|
+
}
|
|
565
|
+
else {
|
|
566
|
+
const value = rank(prior.value, owner);
|
|
567
|
+
if (prior.name.startsWith('min')) {
|
|
568
|
+
const maximum = value - (prior.name.endsWith('Inclusive') ? 1n : 0n);
|
|
569
|
+
if (maximum < hi)
|
|
570
|
+
hi = maximum;
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
const minimum = value + (prior.name.endsWith('Inclusive') ? 1n : 0n);
|
|
574
|
+
if (minimum > lo)
|
|
575
|
+
lo = minimum;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
if (nan) {
|
|
579
|
+
const word = regular.witness(regular.intersect([language, expression('NaN', owner)], owner), owner);
|
|
580
|
+
if (word !== undefined)
|
|
581
|
+
return word;
|
|
582
|
+
}
|
|
583
|
+
if (!ordinary || lo > hi)
|
|
584
|
+
return undefined;
|
|
585
|
+
for (const [negative, bits] of [[true, -infinity], [false, infinity]])
|
|
586
|
+
if (lo <= bits && hi >= bits) {
|
|
587
|
+
const word = regular.witness(regular.intersect([language, expression(negative ? '\\-INF' : 'INF', owner)], owner), owner);
|
|
588
|
+
if (word !== undefined)
|
|
589
|
+
return word;
|
|
590
|
+
}
|
|
591
|
+
if (lo <= 0n && hi >= 0n)
|
|
592
|
+
for (const interval of inverseIntervals({ family, canonical: '0' }, owner)) {
|
|
593
|
+
const word = intervalWitness(language, interval, owner);
|
|
594
|
+
if (word !== undefined)
|
|
595
|
+
return word;
|
|
596
|
+
}
|
|
597
|
+
for (const negative of [false, true]) {
|
|
598
|
+
const minimum = negative ? hi < -1n ? -hi : 1n : lo > 1n ? lo : 1n;
|
|
599
|
+
const maximum = negative ? -lo : hi;
|
|
600
|
+
if (minimum > maximum)
|
|
601
|
+
continue;
|
|
602
|
+
const lower = inverseIntervals(rankedValue(minimum, single, owner), owner)[0].lower;
|
|
603
|
+
const upper = inverseIntervals(rankedValue(maximum, single, owner), owner)[0].upper;
|
|
604
|
+
const word = intervalWitness(language, { negative, lower, upper }, owner);
|
|
605
|
+
if (word !== undefined)
|
|
606
|
+
return word;
|
|
607
|
+
}
|
|
608
|
+
return undefined;
|
|
609
|
+
};
|
|
610
|
+
const boundIntervals = (family, bounds, owner) => {
|
|
611
|
+
const single = family === 'float', infinity = single ? 0x7f800000n : 0x7ff0000000000000n;
|
|
612
|
+
let lo = -infinity, hi = infinity, ordinary = true, nan = true;
|
|
613
|
+
for (const bound of bounds) {
|
|
614
|
+
c.step(owner, 6);
|
|
615
|
+
if (bound.value.canonical === 'NaN') {
|
|
616
|
+
ordinary = false;
|
|
617
|
+
if (bound.name.endsWith('Exclusive'))
|
|
618
|
+
nan = false;
|
|
619
|
+
continue;
|
|
620
|
+
}
|
|
621
|
+
nan = false;
|
|
622
|
+
const value = rank(bound.value, owner);
|
|
623
|
+
if (bound.name.startsWith('min')) {
|
|
624
|
+
const minimum = value + (bound.name.endsWith('Exclusive') ? 1n : 0n);
|
|
625
|
+
if (minimum > lo)
|
|
626
|
+
lo = minimum;
|
|
627
|
+
}
|
|
628
|
+
else {
|
|
629
|
+
const maximum = value - (bound.name.endsWith('Exclusive') ? 1n : 0n);
|
|
630
|
+
if (maximum < hi)
|
|
631
|
+
hi = maximum;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
c.step(owner, 4);
|
|
635
|
+
const intervals = [], literals = nan ? ['NaN'] : [];
|
|
636
|
+
if (!ordinary || lo > hi)
|
|
637
|
+
return { intervals, literals };
|
|
638
|
+
for (const [negative, bits] of [[true, -infinity], [false, infinity]])
|
|
639
|
+
if (lo <= bits && hi >= bits)
|
|
640
|
+
literals.push(negative ? '-INF' : 'INF');
|
|
641
|
+
for (const negative of [false, true]) {
|
|
642
|
+
const minimum = negative ? hi < 0n ? -hi : 0n : lo > 0n ? lo : 0n, maximum = negative ? -lo : hi;
|
|
643
|
+
if (minimum > maximum)
|
|
644
|
+
continue;
|
|
645
|
+
const lower = minimum === 0n ? undefined : inverseIntervals(rankedValue(minimum, single, owner), owner)[0].lower;
|
|
646
|
+
const upper = maximum === 0n ? inverseIntervals({ family, canonical: '0' }, owner)[0].upper
|
|
647
|
+
: inverseIntervals(rankedValue(maximum, single, owner), owner)[0].upper;
|
|
648
|
+
intervals.push({ negative, lower, upper });
|
|
649
|
+
}
|
|
650
|
+
return { intervals, literals };
|
|
651
|
+
};
|
|
652
|
+
const compareExact = (a, b, owner) => {
|
|
653
|
+
const scale = Math.max(a.scale, b.scale);
|
|
654
|
+
// Only the scale difference extends a coefficient: its existing fractional
|
|
655
|
+
// digits are already included in digits. Charging the whole common scale
|
|
656
|
+
// again greatly overstates subnormal endpoint comparisons.
|
|
657
|
+
charge(owner, Math.max((a.digits ?? a.scale + 330) + scale - a.scale, (b.digits ?? b.scale + 330) + scale - b.scale));
|
|
658
|
+
const x = a.coefficient * 10n ** BigInt(scale - a.scale), y = b.coefficient * 10n ** BigInt(scale - b.scale);
|
|
659
|
+
return x < y ? -1 : x > y ? 1 : 0;
|
|
660
|
+
};
|
|
661
|
+
const subtractIntervals = (input, removed, owner) => {
|
|
662
|
+
c.step(owner, input.length + 2);
|
|
663
|
+
let result = [...input];
|
|
664
|
+
for (const cut of removed) {
|
|
665
|
+
c.step(owner, result.length + 2);
|
|
666
|
+
const next = [];
|
|
667
|
+
for (const original of result) {
|
|
668
|
+
c.step(owner, 6);
|
|
669
|
+
if (original.negative !== cut.negative) {
|
|
670
|
+
next.push(original);
|
|
671
|
+
continue;
|
|
672
|
+
}
|
|
673
|
+
const lower = !original.lower ? cut.lower : !cut.lower ? original.lower
|
|
674
|
+
: compareExact(original.lower.value, cut.lower.value, owner) > 0 ? original.lower
|
|
675
|
+
: compareExact(original.lower.value, cut.lower.value, owner) < 0 ? cut.lower
|
|
676
|
+
: { ...original.lower, inclusive: original.lower.inclusive && cut.lower.inclusive };
|
|
677
|
+
const upper = !original.upper ? cut.upper : !cut.upper ? original.upper
|
|
678
|
+
: compareExact(original.upper.value, cut.upper.value, owner) < 0 ? original.upper
|
|
679
|
+
: compareExact(original.upper.value, cut.upper.value, owner) > 0 ? cut.upper
|
|
680
|
+
: { ...original.upper, inclusive: original.upper.inclusive && cut.upper.inclusive };
|
|
681
|
+
const order = lower && upper ? compareExact(lower.value, upper.value, owner) : -1;
|
|
682
|
+
if (order > 0 || order === 0 && !(lower.inclusive && upper.inclusive)) {
|
|
683
|
+
next.push(original);
|
|
684
|
+
continue;
|
|
685
|
+
}
|
|
686
|
+
if (lower && (!original.lower || compareExact(original.lower.value, lower.value, owner) < 0
|
|
687
|
+
|| compareExact(original.lower.value, lower.value, owner) === 0 && original.lower.inclusive && !lower.inclusive))
|
|
688
|
+
next.push({ ...original, upper: { ...lower, inclusive: !lower.inclusive } });
|
|
689
|
+
if (upper && (!original.upper || compareExact(original.upper.value, upper.value, owner) > 0
|
|
690
|
+
|| compareExact(original.upper.value, upper.value, owner) === 0 && original.upper.inclusive && !upper.inclusive))
|
|
691
|
+
next.push({ ...original, lower: { ...upper, inclusive: !upper.inclusive } });
|
|
692
|
+
}
|
|
693
|
+
result = next;
|
|
694
|
+
}
|
|
695
|
+
return result;
|
|
696
|
+
};
|
|
697
|
+
function* formatValues(family, owner) {
|
|
698
|
+
const single = family === 'float', infinity = single ? 0x7f800000n : 0x7ff0000000000000n;
|
|
699
|
+
c.step(owner, 64);
|
|
700
|
+
yield { family, canonical: 'NaN' };
|
|
701
|
+
for (let bits = -infinity; bits <= infinity; bits++) {
|
|
702
|
+
c.step(owner, 64);
|
|
703
|
+
const value = rankedValue(bits < 0n ? -bits : bits, single, owner);
|
|
704
|
+
yield bits < 0n ? { ...value, canonical: '-' + value.canonical } : value;
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
const decimalInputLanguage = (intervals, literals, owner) => {
|
|
708
|
+
c.step(owner, intervals.length + literals.length + 3);
|
|
709
|
+
const choices = literals.map(value => expression(value === '-INF' ? '\\-INF' : value, owner));
|
|
710
|
+
for (const interval of intervals) {
|
|
711
|
+
const predicates = [expression('([0-9]+([.][0-9]*)?|[.][0-9]+)', owner)];
|
|
712
|
+
for (const [endpoint, lower] of [[interval.lower, true], [interval.upper, false]]) {
|
|
713
|
+
if (!endpoint)
|
|
714
|
+
continue;
|
|
715
|
+
const greater = lower ? !endpoint.inclusive : endpoint.inclusive, source = decimals.relation(key(endpoint.value, owner), greater, owner);
|
|
716
|
+
const language = source === undefined ? regular.union([], owner) : expression(source, owner);
|
|
717
|
+
predicates.push(endpoint.inclusive ? regular.negate(language, owner) : language);
|
|
718
|
+
}
|
|
719
|
+
choices.push(regular.concatenate([expression(interval.negative ? '\\-' : '[+]?', owner), regular.intersect(predicates, owner)], owner));
|
|
720
|
+
}
|
|
721
|
+
return regular.union(choices, owner);
|
|
722
|
+
};
|
|
723
|
+
/** On unsigned integer mantissas and nonnegative exponents, only finitely
|
|
724
|
+
* many exponents can straddle an interval endpoint. Above their decimal
|
|
725
|
+
* orders every nonzero mantissa exceeds every finite endpoint; zero stays
|
|
726
|
+
* zero. This covers the exponent syntax admitted inside binary alphabets. */
|
|
727
|
+
const unsignedExponentialLanguage = (source, intervals, owner) => {
|
|
728
|
+
const exponentGrammar = expression('[+]?0*[0-9]+', owner), mantissa = expression('[+]?[0-9]+', owner), marker = expression('[eE]', owner);
|
|
729
|
+
const positive = intervals.filter(interval => !interval.negative);
|
|
730
|
+
c.step(owner, intervals.length + 4);
|
|
731
|
+
let cutoff = 0;
|
|
732
|
+
for (const interval of positive)
|
|
733
|
+
for (const endpoint of [interval.lower, interval.upper])
|
|
734
|
+
if (endpoint)
|
|
735
|
+
cutoff = Math.max(cutoff, order(endpoint.value, owner) + 1);
|
|
736
|
+
c.step(owner, 2);
|
|
737
|
+
const choices = [];
|
|
738
|
+
for (let exponent = 0; exponent < cutoff; exponent++) {
|
|
739
|
+
c.step(owner, 64);
|
|
740
|
+
const suffix = regular.concatenate([marker, expression('[+]?0*' + exponent, owner)], owner);
|
|
741
|
+
const token = regular.quotient(source, expression('', owner), suffix, owner);
|
|
742
|
+
if (regular.witness(regular.intersect([token, mantissa], owner), owner) === undefined)
|
|
743
|
+
continue;
|
|
744
|
+
c.step(owner, positive.length * 8 + 3);
|
|
745
|
+
const scaledIntervals = positive.map(interval => ({ negative: false,
|
|
746
|
+
lower: interval.lower && { ...interval.lower, value: scaled(interval.lower.value, exponent, owner) },
|
|
747
|
+
upper: interval.upper && { ...interval.upper, value: scaled(interval.upper.value, exponent, owner) } }));
|
|
748
|
+
choices.push(regular.concatenate([regular.intersect([mantissa, decimalInputLanguage(scaledIntervals, [], owner)], owner), suffix], owner));
|
|
749
|
+
}
|
|
750
|
+
const tail = regular.intersect([exponentGrammar, regular.negate(decimalInputLanguage([{ negative: false, upper: { value: { coefficient: BigInt(cutoff), scale: 0 }, inclusive: false } }], [], owner), owner)], owner);
|
|
751
|
+
if (positive.some(interval => !interval.upper))
|
|
752
|
+
choices.push(regular.concatenate([expression('[+]?0*[1-9][0-9]*', owner), marker, tail], owner));
|
|
753
|
+
if (positive.some(interval => (!interval.lower || interval.lower.value.coefficient === 0n && interval.lower.inclusive)
|
|
754
|
+
&& (!interval.upper || interval.upper.value.coefficient !== 0n || interval.upper.inclusive)))
|
|
755
|
+
choices.push(regular.concatenate([expression('[+]?0+', owner), marker, exponentGrammar], owner));
|
|
756
|
+
return regular.intersect([source, regular.union(choices, owner)], owner);
|
|
757
|
+
};
|
|
758
|
+
return { witness, inverseIntervals, intervalWitness, wideningWitness, boundIntervals, subtractIntervals, formatValues, decimalInputLanguage, unsignedExponentialLanguage };
|
|
759
|
+
}
|