@primmel/primmel 1.3.2 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +40 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +112 -1
- package/dist/index.js.map +1 -1
- package/dist/src/check-allowlist.d.ts +56 -0
- package/dist/src/check-allowlist.d.ts.map +1 -0
- package/dist/src/check-allowlist.js +307 -0
- package/dist/src/check-allowlist.js.map +1 -0
- package/dist/src/check-rules.d.ts +17 -0
- package/dist/src/check-rules.d.ts.map +1 -0
- package/dist/src/check-rules.js +351 -0
- package/dist/src/check-rules.js.map +1 -0
- package/dist/src/check.d.ts +115 -0
- package/dist/src/check.d.ts.map +1 -0
- package/dist/src/check.js +4164 -0
- package/dist/src/check.js.map +1 -0
- package/dist/src/export/rdf-competency-questions.d.ts +11 -0
- package/dist/src/export/rdf-competency-questions.d.ts.map +1 -0
- package/dist/src/export/rdf-competency-questions.js +99 -0
- package/dist/src/export/rdf-competency-questions.js.map +1 -0
- package/dist/src/export/rdf-shapes.d.ts +3 -0
- package/dist/src/export/rdf-shapes.d.ts.map +1 -0
- package/dist/src/export/rdf-shapes.js +225 -0
- package/dist/src/export/rdf-shapes.js.map +1 -0
- package/dist/src/export/rdf-vocabulary.d.ts +125 -0
- package/dist/src/export/rdf-vocabulary.d.ts.map +1 -0
- package/dist/src/export/rdf-vocabulary.js +230 -0
- package/dist/src/export/rdf-vocabulary.js.map +1 -0
- package/dist/src/export/rdf.d.ts +92 -0
- package/dist/src/export/rdf.d.ts.map +1 -0
- package/dist/src/export/rdf.js +707 -0
- package/dist/src/export/rdf.js.map +1 -0
- package/dist/src/export/reqif.d.ts +81 -0
- package/dist/src/export/reqif.d.ts.map +1 -0
- package/dist/src/export/reqif.js +703 -0
- package/dist/src/export/reqif.js.map +1 -0
- package/dist/src/instance-resolution.d.ts +68 -0
- package/dist/src/instance-resolution.d.ts.map +1 -0
- package/dist/src/instance-resolution.js +239 -0
- package/dist/src/instance-resolution.js.map +1 -0
- package/dist/src/mapping-coverage.d.ts +220 -0
- package/dist/src/mapping-coverage.d.ts.map +1 -0
- package/dist/src/mapping-coverage.js +528 -0
- package/dist/src/mapping-coverage.js.map +1 -0
- package/dist/src/model-diff.d.ts +198 -0
- package/dist/src/model-diff.d.ts.map +1 -0
- package/dist/src/model-diff.js +914 -0
- package/dist/src/model-diff.js.map +1 -0
- package/dist/src/operational-state.d.ts +112 -0
- package/dist/src/operational-state.d.ts.map +1 -0
- package/dist/src/operational-state.js +162 -0
- package/dist/src/operational-state.js.map +1 -0
- package/dist/src/package-diff.d.ts +36 -0
- package/dist/src/package-diff.d.ts.map +1 -0
- package/dist/src/package-diff.js +104 -0
- package/dist/src/package-diff.js.map +1 -0
- package/dist/src/ser-des/config/acceptance.d.ts +10 -0
- package/dist/src/ser-des/config/acceptance.d.ts.map +1 -0
- package/dist/src/ser-des/config/acceptance.js +163 -0
- package/dist/src/ser-des/config/acceptance.js.map +1 -0
- package/dist/src/ser-des/config/activityArchetype.d.ts +5 -0
- package/dist/src/ser-des/config/activityArchetype.d.ts.map +1 -0
- package/dist/src/ser-des/config/activityArchetype.js +78 -0
- package/dist/src/ser-des/config/activityArchetype.js.map +1 -0
- package/dist/src/ser-des/config/artifact.d.ts +16 -0
- package/dist/src/ser-des/config/artifact.d.ts.map +1 -0
- package/dist/src/ser-des/config/artifact.js +392 -0
- package/dist/src/ser-des/config/artifact.js.map +1 -0
- package/dist/src/ser-des/config/calculation.d.ts.map +1 -1
- package/dist/src/ser-des/config/calculation.js +214 -12
- package/dist/src/ser-des/config/calculation.js.map +1 -1
- package/dist/src/ser-des/config/comment.d.ts +34 -0
- package/dist/src/ser-des/config/comment.d.ts.map +1 -0
- package/dist/src/ser-des/config/comment.js +121 -0
- package/dist/src/ser-des/config/comment.js.map +1 -0
- package/dist/src/ser-des/config/competenceKind.d.ts +8 -0
- package/dist/src/ser-des/config/competenceKind.d.ts.map +1 -0
- package/dist/src/ser-des/config/competenceKind.js +266 -0
- package/dist/src/ser-des/config/competenceKind.js.map +1 -0
- package/dist/src/ser-des/config/composition.d.ts +6 -0
- package/dist/src/ser-des/config/composition.d.ts.map +1 -0
- package/dist/src/ser-des/config/composition.js +165 -0
- package/dist/src/ser-des/config/composition.js.map +1 -0
- package/dist/src/ser-des/config/conformanceClass.d.ts +9 -0
- package/dist/src/ser-des/config/conformanceClass.d.ts.map +1 -0
- package/dist/src/ser-des/config/conformanceClass.js +128 -0
- package/dist/src/ser-des/config/conformanceClass.js.map +1 -0
- package/dist/src/ser-des/config/conformanceTest.d.ts +6 -0
- package/dist/src/ser-des/config/conformanceTest.d.ts.map +1 -0
- package/dist/src/ser-des/config/conformanceTest.js +929 -0
- package/dist/src/ser-des/config/conformanceTest.js.map +1 -0
- package/dist/src/ser-des/config/constraint.d.ts +5 -0
- package/dist/src/ser-des/config/constraint.d.ts.map +1 -0
- package/dist/src/ser-des/config/constraint.js +108 -0
- package/dist/src/ser-des/config/constraint.js.map +1 -0
- package/dist/src/ser-des/config/data.d.ts.map +1 -1
- package/dist/src/ser-des/config/data.js +105 -12
- package/dist/src/ser-des/config/data.js.map +1 -1
- package/dist/src/ser-des/config/design.d.ts +9 -0
- package/dist/src/ser-des/config/design.d.ts.map +1 -0
- package/dist/src/ser-des/config/design.js +847 -0
- package/dist/src/ser-des/config/design.js.map +1 -0
- package/dist/src/ser-des/config/discrepancyRecord.d.ts +5 -0
- package/dist/src/ser-des/config/discrepancyRecord.d.ts.map +1 -0
- package/dist/src/ser-des/config/discrepancyRecord.js +109 -0
- package/dist/src/ser-des/config/discrepancyRecord.js.map +1 -0
- package/dist/src/ser-des/config/dual.d.ts +9 -0
- package/dist/src/ser-des/config/dual.d.ts.map +1 -0
- package/dist/src/ser-des/config/dual.js +84 -0
- package/dist/src/ser-des/config/dual.js.map +1 -0
- package/dist/src/ser-des/config/field-parser.d.ts +92 -7
- package/dist/src/ser-des/config/field-parser.d.ts.map +1 -1
- package/dist/src/ser-des/config/field-parser.js +832 -29
- package/dist/src/ser-des/config/field-parser.js.map +1 -1
- package/dist/src/ser-des/config/form.d.ts.map +1 -1
- package/dist/src/ser-des/config/form.js +355 -134
- package/dist/src/ser-des/config/form.js.map +1 -1
- package/dist/src/ser-des/config/formulasUsed.d.ts +9 -0
- package/dist/src/ser-des/config/formulasUsed.d.ts.map +1 -0
- package/dist/src/ser-des/config/formulasUsed.js +126 -0
- package/dist/src/ser-des/config/formulasUsed.js.map +1 -0
- package/dist/src/ser-des/config/index.d.ts.map +1 -1
- package/dist/src/ser-des/config/index.js +180 -1
- package/dist/src/ser-des/config/index.js.map +1 -1
- package/dist/src/ser-des/config/instance.d.ts +22 -0
- package/dist/src/ser-des/config/instance.d.ts.map +1 -0
- package/dist/src/ser-des/config/instance.js +266 -0
- package/dist/src/ser-des/config/instance.js.map +1 -0
- package/dist/src/ser-des/config/invariant.d.ts +9 -0
- package/dist/src/ser-des/config/invariant.d.ts.map +1 -0
- package/dist/src/ser-des/config/invariant.js +143 -0
- package/dist/src/ser-des/config/invariant.js.map +1 -0
- package/dist/src/ser-des/config/mapProfile.d.ts.map +1 -1
- package/dist/src/ser-des/config/mapProfile.js +199 -14
- package/dist/src/ser-des/config/mapProfile.js.map +1 -1
- package/dist/src/ser-des/config/metadata.js +6 -6
- package/dist/src/ser-des/config/metadata.js.map +1 -1
- package/dist/src/ser-des/config/monitor.d.ts +9 -0
- package/dist/src/ser-des/config/monitor.d.ts.map +1 -0
- package/dist/src/ser-des/config/monitor.js +322 -0
- package/dist/src/ser-des/config/monitor.js.map +1 -0
- package/dist/src/ser-des/config/note.d.ts.map +1 -1
- package/dist/src/ser-des/config/note.js +16 -1
- package/dist/src/ser-des/config/note.js.map +1 -1
- package/dist/src/ser-des/config/packageManifest.d.ts +5 -0
- package/dist/src/ser-des/config/packageManifest.d.ts.map +1 -0
- package/dist/src/ser-des/config/packageManifest.js +349 -0
- package/dist/src/ser-des/config/packageManifest.js.map +1 -0
- package/dist/src/ser-des/config/passport.d.ts +9 -0
- package/dist/src/ser-des/config/passport.d.ts.map +1 -0
- package/dist/src/ser-des/config/passport.js +191 -0
- package/dist/src/ser-des/config/passport.js.map +1 -0
- package/dist/src/ser-des/config/process.d.ts +5 -3
- package/dist/src/ser-des/config/process.d.ts.map +1 -1
- package/dist/src/ser-des/config/process.js +915 -8
- package/dist/src/ser-des/config/process.js.map +1 -1
- package/dist/src/ser-des/config/quantity.d.ts +21 -0
- package/dist/src/ser-des/config/quantity.d.ts.map +1 -0
- package/dist/src/ser-des/config/quantity.js +114 -0
- package/dist/src/ser-des/config/quantity.js.map +1 -0
- package/dist/src/ser-des/config/quantityRegister.d.ts +9 -0
- package/dist/src/ser-des/config/quantityRegister.d.ts.map +1 -0
- package/dist/src/ser-des/config/quantityRegister.js +202 -0
- package/dist/src/ser-des/config/quantityRegister.js.map +1 -0
- package/dist/src/ser-des/config/reference.d.ts.map +1 -1
- package/dist/src/ser-des/config/reference.js +6 -0
- package/dist/src/ser-des/config/reference.js.map +1 -1
- package/dist/src/ser-des/config/referenceMaterial.d.ts +5 -0
- package/dist/src/ser-des/config/referenceMaterial.d.ts.map +1 -0
- package/dist/src/ser-des/config/referenceMaterial.js +296 -0
- package/dist/src/ser-des/config/referenceMaterial.js.map +1 -0
- package/dist/src/ser-des/config/requirement.d.ts +16 -0
- package/dist/src/ser-des/config/requirement.d.ts.map +1 -0
- package/dist/src/ser-des/config/requirement.js +579 -0
- package/dist/src/ser-des/config/requirement.js.map +1 -0
- package/dist/src/ser-des/config/role.d.ts.map +1 -1
- package/dist/src/ser-des/config/role.js +12 -0
- package/dist/src/ser-des/config/role.js.map +1 -1
- package/dist/src/ser-des/config/series.d.ts +9 -0
- package/dist/src/ser-des/config/series.d.ts.map +1 -0
- package/dist/src/ser-des/config/series.js +121 -0
- package/dist/src/ser-des/config/series.js.map +1 -0
- package/dist/src/ser-des/config/sourceDiscrepancy.d.ts +11 -0
- package/dist/src/ser-des/config/sourceDiscrepancy.d.ts.map +1 -0
- package/dist/src/ser-des/config/sourceDiscrepancy.js +83 -0
- package/dist/src/ser-des/config/sourceDiscrepancy.js.map +1 -0
- package/dist/src/ser-des/config/stateMachine.d.ts.map +1 -1
- package/dist/src/ser-des/config/stateMachine.js +189 -38
- package/dist/src/ser-des/config/stateMachine.js.map +1 -1
- package/dist/src/ser-des/config/subform.d.ts.map +1 -1
- package/dist/src/ser-des/config/subform.js +25 -33
- package/dist/src/ser-des/config/subform.js.map +1 -1
- package/dist/src/ser-des/config/subject.d.ts +58 -0
- package/dist/src/ser-des/config/subject.d.ts.map +1 -0
- package/dist/src/ser-des/config/subject.js +2093 -0
- package/dist/src/ser-des/config/subject.js.map +1 -0
- package/dist/src/ser-des/config/symbol.d.ts.map +1 -1
- package/dist/src/ser-des/config/symbol.js +130 -6
- package/dist/src/ser-des/config/symbol.js.map +1 -1
- package/dist/src/ser-des/config/table.d.ts.map +1 -1
- package/dist/src/ser-des/config/table.js +373 -7
- package/dist/src/ser-des/config/table.js.map +1 -1
- package/dist/src/ser-des/config/term.d.ts.map +1 -1
- package/dist/src/ser-des/config/term.js +107 -0
- package/dist/src/ser-des/config/term.js.map +1 -1
- package/dist/src/ser-des/config/testPointSet.d.ts +5 -0
- package/dist/src/ser-des/config/testPointSet.d.ts.map +1 -0
- package/dist/src/ser-des/config/testPointSet.js +199 -0
- package/dist/src/ser-des/config/testPointSet.js.map +1 -0
- package/dist/src/ser-des/config/testSequence.d.ts +9 -0
- package/dist/src/ser-des/config/testSequence.d.ts.map +1 -0
- package/dist/src/ser-des/config/testSequence.js +206 -0
- package/dist/src/ser-des/config/testSequence.js.map +1 -0
- package/dist/src/ser-des/config/text.d.ts +5 -0
- package/dist/src/ser-des/config/text.d.ts.map +1 -0
- package/dist/src/ser-des/config/text.js +106 -0
- package/dist/src/ser-des/config/text.js.map +1 -0
- package/dist/src/ser-des/config/twin.d.ts +31 -0
- package/dist/src/ser-des/config/twin.d.ts.map +1 -0
- package/dist/src/ser-des/config/twin.js +362 -0
- package/dist/src/ser-des/config/twin.js.map +1 -0
- package/dist/src/ser-des/config/verdict.d.ts +5 -0
- package/dist/src/ser-des/config/verdict.d.ts.map +1 -0
- package/dist/src/ser-des/config/verdict.js +159 -0
- package/dist/src/ser-des/config/verdict.js.map +1 -0
- package/dist/src/ser-des/config/viewProfile.d.ts.map +1 -1
- package/dist/src/ser-des/config/viewProfile.js +7 -0
- package/dist/src/ser-des/config/viewProfile.js.map +1 -1
- package/dist/src/ser-des/includes.d.ts.map +1 -1
- package/dist/src/ser-des/includes.js +5 -2
- package/dist/src/ser-des/includes.js.map +1 -1
- package/dist/src/ser-des/index.d.ts +12 -0
- package/dist/src/ser-des/index.d.ts.map +1 -1
- package/dist/src/ser-des/index.js +42 -0
- package/dist/src/ser-des/index.js.map +1 -1
- package/dist/src/ser-des/package.d.ts +53 -0
- package/dist/src/ser-des/package.d.ts.map +1 -0
- package/dist/src/ser-des/package.js +404 -0
- package/dist/src/ser-des/package.js.map +1 -0
- package/dist/src/ser-des/parse-block.d.ts.map +1 -1
- package/dist/src/ser-des/parse-block.js +7 -1
- package/dist/src/ser-des/parse-block.js.map +1 -1
- package/dist/src/ser-des/parse.d.ts.map +1 -1
- package/dist/src/ser-des/parse.js +45 -0
- package/dist/src/ser-des/parse.js.map +1 -1
- package/dist/src/ser-des/prm.d.ts +53 -0
- package/dist/src/ser-des/prm.d.ts.map +1 -0
- package/dist/src/ser-des/prm.js +257 -0
- package/dist/src/ser-des/prm.js.map +1 -0
- package/dist/src/ser-des/resolve.d.ts.map +1 -1
- package/dist/src/ser-des/resolve.js +1 -0
- package/dist/src/ser-des/resolve.js.map +1 -1
- package/dist/src/ser-des/tokenize.d.ts +11 -0
- package/dist/src/ser-des/tokenize.d.ts.map +1 -1
- package/dist/src/ser-des/tokenize.js +28 -1
- package/dist/src/ser-des/tokenize.js.map +1 -1
- package/dist/src/ser-des/types.d.ts +56 -1
- package/dist/src/ser-des/types.d.ts.map +1 -1
- package/dist/src/spelling.d.ts +35 -0
- package/dist/src/spelling.d.ts.map +1 -0
- package/dist/src/spelling.js +140 -0
- package/dist/src/spelling.js.map +1 -0
- package/dist/src/text-coverage.d.ts +164 -0
- package/dist/src/text-coverage.d.ts.map +1 -0
- package/dist/src/text-coverage.js +679 -0
- package/dist/src/text-coverage.js.map +1 -0
- package/dist/src/time.d.ts +55 -0
- package/dist/src/time.d.ts.map +1 -0
- package/dist/src/time.js +223 -0
- package/dist/src/time.js.map +1 -0
- package/dist/src/type-expr.d.ts +31 -0
- package/dist/src/type-expr.d.ts.map +1 -0
- package/dist/src/type-expr.js +110 -0
- package/dist/src/type-expr.js.map +1 -0
- package/dist/src/types/Acceptance.d.ts +31 -0
- package/dist/src/types/Acceptance.d.ts.map +1 -0
- package/dist/src/types/Acceptance.js +12 -0
- package/dist/src/types/Acceptance.js.map +1 -0
- package/dist/src/types/ActivityArchetype.d.ts +14 -0
- package/dist/src/types/ActivityArchetype.d.ts.map +1 -0
- package/dist/src/types/ActivityArchetype.js +17 -0
- package/dist/src/types/ActivityArchetype.js.map +1 -0
- package/dist/src/types/Artifact.d.ts +117 -0
- package/dist/src/types/Artifact.d.ts.map +1 -0
- package/dist/src/types/Artifact.js +35 -0
- package/dist/src/types/Artifact.js.map +1 -0
- package/dist/src/types/Calculation.d.ts +49 -0
- package/dist/src/types/Calculation.d.ts.map +1 -1
- package/dist/src/types/Comment.d.ts +23 -0
- package/dist/src/types/Comment.d.ts.map +1 -0
- package/dist/src/types/Comment.js +3 -0
- package/dist/src/types/Comment.js.map +1 -0
- package/dist/src/types/CompetenceKind.d.ts +70 -0
- package/dist/src/types/CompetenceKind.d.ts.map +1 -0
- package/dist/src/types/CompetenceKind.js +3 -0
- package/dist/src/types/CompetenceKind.js.map +1 -0
- package/dist/src/types/Composition.d.ts +80 -0
- package/dist/src/types/Composition.d.ts.map +1 -0
- package/dist/src/types/Composition.js +44 -0
- package/dist/src/types/Composition.js.map +1 -0
- package/dist/src/types/ConformanceClass.d.ts +22 -0
- package/dist/src/types/ConformanceClass.d.ts.map +1 -0
- package/dist/src/types/ConformanceClass.js +7 -0
- package/dist/src/types/ConformanceClass.js.map +1 -0
- package/dist/src/types/ConformanceTest.d.ts +206 -0
- package/dist/src/types/ConformanceTest.d.ts.map +1 -0
- package/dist/src/types/ConformanceTest.js +3 -0
- package/dist/src/types/ConformanceTest.js.map +1 -0
- package/dist/src/types/Constraint.d.ts +34 -0
- package/dist/src/types/Constraint.d.ts.map +1 -0
- package/dist/src/types/Constraint.js +3 -0
- package/dist/src/types/Constraint.js.map +1 -0
- package/dist/src/types/Design.d.ts +147 -0
- package/dist/src/types/Design.d.ts.map +1 -0
- package/dist/src/types/Design.js +10 -0
- package/dist/src/types/Design.js.map +1 -0
- package/dist/src/types/DiscrepancyRecord.d.ts +42 -0
- package/dist/src/types/DiscrepancyRecord.d.ts.map +1 -0
- package/dist/src/types/DiscrepancyRecord.js +3 -0
- package/dist/src/types/DiscrepancyRecord.js.map +1 -0
- package/dist/src/types/Form.d.ts +127 -1
- package/dist/src/types/Form.d.ts.map +1 -1
- package/dist/src/types/FormulasUsed.d.ts +95 -0
- package/dist/src/types/FormulasUsed.d.ts.map +1 -0
- package/dist/src/types/FormulasUsed.js +64 -0
- package/dist/src/types/FormulasUsed.js.map +1 -0
- package/dist/src/types/Instance.d.ts +105 -0
- package/dist/src/types/Instance.d.ts.map +1 -0
- package/dist/src/types/Instance.js +40 -0
- package/dist/src/types/Instance.js.map +1 -0
- package/dist/src/types/Invariant.d.ts +82 -0
- package/dist/src/types/Invariant.d.ts.map +1 -0
- package/dist/src/types/Invariant.js +50 -0
- package/dist/src/types/Invariant.js.map +1 -0
- package/dist/src/types/MapProfile.d.ts +36 -1
- package/dist/src/types/MapProfile.d.ts.map +1 -1
- package/dist/src/types/Monitor.d.ts +144 -0
- package/dist/src/types/Monitor.d.ts.map +1 -0
- package/dist/src/types/Monitor.js +74 -0
- package/dist/src/types/Monitor.js.map +1 -0
- package/dist/src/types/Note.d.ts +4 -1
- package/dist/src/types/Note.d.ts.map +1 -1
- package/dist/src/types/Package.d.ts +161 -0
- package/dist/src/types/Package.d.ts.map +1 -0
- package/dist/src/types/Package.js +3 -0
- package/dist/src/types/Package.js.map +1 -0
- package/dist/src/types/Passport.d.ts +125 -0
- package/dist/src/types/Passport.d.ts.map +1 -0
- package/dist/src/types/Passport.js +84 -0
- package/dist/src/types/Passport.js.map +1 -0
- package/dist/src/types/Quantity.d.ts +99 -0
- package/dist/src/types/Quantity.d.ts.map +1 -0
- package/dist/src/types/Quantity.js +24 -0
- package/dist/src/types/Quantity.js.map +1 -0
- package/dist/src/types/Reference.d.ts +2 -0
- package/dist/src/types/Reference.d.ts.map +1 -1
- package/dist/src/types/ReferenceMaterial.d.ts +53 -0
- package/dist/src/types/ReferenceMaterial.d.ts.map +1 -0
- package/dist/src/types/ReferenceMaterial.js +14 -0
- package/dist/src/types/ReferenceMaterial.js.map +1 -0
- package/dist/src/types/Requirement.d.ts +111 -0
- package/dist/src/types/Requirement.d.ts.map +1 -0
- package/dist/src/types/Requirement.js +10 -0
- package/dist/src/types/Requirement.js.map +1 -0
- package/dist/src/types/Role.d.ts +4 -0
- package/dist/src/types/Role.d.ts.map +1 -1
- package/dist/src/types/Series.d.ts +31 -0
- package/dist/src/types/Series.d.ts.map +1 -0
- package/dist/src/types/Series.js +14 -0
- package/dist/src/types/Series.js.map +1 -0
- package/dist/src/types/SourceDiscrepancy.d.ts +21 -0
- package/dist/src/types/SourceDiscrepancy.d.ts.map +1 -0
- package/dist/src/types/SourceDiscrepancy.js +13 -0
- package/dist/src/types/SourceDiscrepancy.js.map +1 -0
- package/dist/src/types/Standard.d.ts +68 -0
- package/dist/src/types/Standard.d.ts.map +1 -1
- package/dist/src/types/StateMachine.d.ts +43 -0
- package/dist/src/types/StateMachine.d.ts.map +1 -1
- package/dist/src/types/StateMachine.js +7 -0
- package/dist/src/types/StateMachine.js.map +1 -1
- package/dist/src/types/Subject.d.ts +432 -0
- package/dist/src/types/Subject.d.ts.map +1 -0
- package/dist/src/types/Subject.js +13 -0
- package/dist/src/types/Subject.js.map +1 -0
- package/dist/src/types/Symbol.d.ts +31 -1
- package/dist/src/types/Symbol.d.ts.map +1 -1
- package/dist/src/types/Table.d.ts +43 -0
- package/dist/src/types/Table.d.ts.map +1 -1
- package/dist/src/types/Term.d.ts +29 -0
- package/dist/src/types/Term.d.ts.map +1 -1
- package/dist/src/types/TestPointSet.d.ts +33 -0
- package/dist/src/types/TestPointSet.d.ts.map +1 -0
- package/dist/src/types/TestPointSet.js +11 -0
- package/dist/src/types/TestPointSet.js.map +1 -0
- package/dist/src/types/TestSequence.d.ts +105 -0
- package/dist/src/types/TestSequence.d.ts.map +1 -0
- package/dist/src/types/TestSequence.js +65 -0
- package/dist/src/types/TestSequence.js.map +1 -0
- package/dist/src/types/Text.d.ts +21 -0
- package/dist/src/types/Text.d.ts.map +1 -0
- package/dist/src/types/Text.js +38 -0
- package/dist/src/types/Text.js.map +1 -0
- package/dist/src/types/Time.d.ts +43 -0
- package/dist/src/types/Time.d.ts.map +1 -0
- package/dist/src/types/Time.js +14 -0
- package/dist/src/types/Time.js.map +1 -0
- package/dist/src/types/Twin.d.ts +155 -0
- package/dist/src/types/Twin.d.ts.map +1 -0
- package/dist/src/types/Twin.js +102 -0
- package/dist/src/types/Twin.js.map +1 -0
- package/dist/src/types/Verdict.d.ts +40 -0
- package/dist/src/types/Verdict.d.ts.map +1 -0
- package/dist/src/types/Verdict.js +14 -0
- package/dist/src/types/Verdict.js.map +1 -0
- package/dist/src/types/ViewProfile.d.ts +6 -0
- package/dist/src/types/ViewProfile.d.ts.map +1 -1
- package/dist/src/types/data.d.ts +27 -0
- package/dist/src/types/data.d.ts.map +1 -1
- package/dist/src/types/process.d.ts +231 -0
- package/dist/src/types/process.d.ts.map +1 -1
- package/dist-browser/index.mjs +6695 -662
- package/dist-cli/primmel.mjs +21453 -0
- package/package.json +61 -5
|
@@ -0,0 +1,2093 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
3
|
+
// Subject-chain constructs (Primmel v2, gap G1):
|
|
4
|
+
// instrument, attribute_definition, capability, behavior, condition_set
|
|
5
|
+
//
|
|
6
|
+
// Grammar sketch:
|
|
7
|
+
// instrument LoadCell {
|
|
8
|
+
// extends MeasuringInstrumentModel
|
|
9
|
+
// definition "..."
|
|
10
|
+
// variant AnaloguePassiveLoadCell { definition "..." }
|
|
11
|
+
// dimension accuracy_class {
|
|
12
|
+
// label "Accuracy class" scope group description "..."
|
|
13
|
+
// reference { doc "urn:..." clause "5.1.1" }
|
|
14
|
+
// values { A { description "..." payload { n_lc_limits: "..." } } B C D }
|
|
15
|
+
// }
|
|
16
|
+
// family_criteria { "same material..." "same design..." }
|
|
17
|
+
// family_defaults { dimensions { construction technology } parameters { rated_output } }
|
|
18
|
+
// model_group {
|
|
19
|
+
// definition "..."
|
|
20
|
+
// identical_characteristics { metrological_class n_lc y z }
|
|
21
|
+
// identical_attributes { accuracy_class n_lc y z t_min t_max }
|
|
22
|
+
// }
|
|
23
|
+
// }
|
|
24
|
+
//
|
|
25
|
+
// attribute_definition e_max {
|
|
26
|
+
// symbol "E_max" name "Maximum capacity" definition "..."
|
|
27
|
+
// source { doc "urn:..." clause "3.5.5" }
|
|
28
|
+
// quantity_kind mass unit kg value_type QuantityValue
|
|
29
|
+
// origin design-fixed scope model category metrological
|
|
30
|
+
// is_dimension false enum humidity_class irdi "..." derived "ocl{...}"
|
|
31
|
+
// }
|
|
32
|
+
//
|
|
33
|
+
// capability digital {
|
|
34
|
+
// label "Digital" description "..." abstract false
|
|
35
|
+
// extends analogue-active requires strain-gauge
|
|
36
|
+
// has_parameters { output_signal software_identification }
|
|
37
|
+
// satisfies_requirements { /req/electronic/software }
|
|
38
|
+
// verified_by_tests { /conf/electronic-tests/software }
|
|
39
|
+
// }
|
|
40
|
+
//
|
|
41
|
+
// behavior creep {
|
|
42
|
+
// kind temporal stimulus force response "..."
|
|
43
|
+
// source { doc "..." clause "3.7.1" } verified_by { /conf/... }
|
|
44
|
+
// }
|
|
45
|
+
//
|
|
46
|
+
// condition_set load-cell-reference {
|
|
47
|
+
// role reference
|
|
48
|
+
// entries { temperature { value 20 unit degC tolerance 1 } }
|
|
49
|
+
// }
|
|
50
|
+
//
|
|
51
|
+
// Subject anatomy (Primmel v3, TODO.roadmap/01) — the `subject` construct
|
|
52
|
+
// organizes the aspect catalog by the three families is / has / does:
|
|
53
|
+
//
|
|
54
|
+
// subject LoadCell {
|
|
55
|
+
// extends MeasuringInstrumentModel
|
|
56
|
+
// is {
|
|
57
|
+
// metadata { name "Load cell" source "urn:oiml:pub:r:60-1:2021#clause-3.1.3" }
|
|
58
|
+
// provenance { manufacturer ACME }
|
|
59
|
+
// structure { }
|
|
60
|
+
// design_parameters { e_max : mass by design }
|
|
61
|
+
// designed_conditions { reference ref-conds rated rated-conds }
|
|
62
|
+
// promises {
|
|
63
|
+
// c6-envelope {
|
|
64
|
+
// target accuracy-class
|
|
65
|
+
// level symbolic C6
|
|
66
|
+
// conditions ocl{self.temperature >= rated.t_min and self.temperature <= rated.t_max}
|
|
67
|
+
// statement "Holds accuracy class C6 across the rated range −10…+40 °C."
|
|
68
|
+
// verified_by { /req/metrological/mpe /conf/metrological-tests/mpe-test }
|
|
69
|
+
// source { doc "urn:oiml:pub:r:60-1:2021" clause "5.1" }
|
|
70
|
+
// }
|
|
71
|
+
// "a statement-only claim (shorthand — linter C43 flags it unverifiable)"
|
|
72
|
+
// }
|
|
73
|
+
// artifacts { }
|
|
74
|
+
// }
|
|
75
|
+
// has {
|
|
76
|
+
// attributes { d_min : mass test_dependent }
|
|
77
|
+
// dimensions { accuracy_class in {A,B,C,D} }
|
|
78
|
+
// state OperationalStates
|
|
79
|
+
// characteristics { creep c_c = ocl{self.indication.delta / self.time.delta} }
|
|
80
|
+
// (block form, TODO.roadmap/10: creep { symbol "c_c" derivation ocl{…}
|
|
81
|
+
// behavior creep quantity_kind verification_interval unit "v"
|
|
82
|
+
// source { doc "…" clause "…" } })
|
|
83
|
+
// environmental_context { "logged 23.4 degC during run 7" }
|
|
84
|
+
// artifact_instances { }
|
|
85
|
+
// }
|
|
86
|
+
// does {
|
|
87
|
+
// behavior measure
|
|
88
|
+
// behavior creep
|
|
89
|
+
// }
|
|
90
|
+
// }
|
|
91
|
+
//
|
|
92
|
+
// Aspect blocks under the wrong family (or undeclared aspect kinds) are
|
|
93
|
+
// recorded on Subject.misplacedAspects for the linter (C6) — the parse
|
|
94
|
+
// itself stays lenient.
|
|
95
|
+
//
|
|
96
|
+
// `extends` merges at resolve time (resolveSubject): each subject merges
|
|
97
|
+
// with its parent per aspect-kind rules — maps merge by key (child
|
|
98
|
+
// wins), lists append (parent entries first), scalars override (child's
|
|
99
|
+
// non-empty value wins). Missing parents and cycle links stay unmerged
|
|
100
|
+
// (lint rule subject-extends-resolves reports the missing ones).
|
|
101
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
102
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
103
|
+
exports.subjectConstruct = exports.conditionSetConstruct = exports.behaviorConstruct = exports.capabilityConstruct = exports.attributeDefinitionConstruct = exports.instrumentConstruct = void 0;
|
|
104
|
+
exports.resolveSubject = resolveSubject;
|
|
105
|
+
const tokenize_1 = require("../tokenize");
|
|
106
|
+
const tokenize_2 = require("../tokenize");
|
|
107
|
+
const field_parser_1 = require("./field-parser");
|
|
108
|
+
const field_parser_2 = require("./field-parser");
|
|
109
|
+
const twin_1 = require("./twin");
|
|
110
|
+
const composition_1 = require("./composition");
|
|
111
|
+
const quantity_1 = require("./quantity");
|
|
112
|
+
// ── shared little readers ────────────────────────────────────────────
|
|
113
|
+
function dumpSource(keyword, src, indent) {
|
|
114
|
+
if (!src || (!src.doc && !src.clause)) {
|
|
115
|
+
return '';
|
|
116
|
+
}
|
|
117
|
+
const frag = src.fragment ? ` fragment "${(0, tokenize_2.escapeString)(src.fragment)}"` : '';
|
|
118
|
+
return `${indent}${keyword} { doc "${(0, tokenize_2.escapeString)(src.doc)}" clause "${(0, tokenize_2.escapeString)(src.clause)}"${frag} }\n`;
|
|
119
|
+
}
|
|
120
|
+
function readIdList(block) {
|
|
121
|
+
// Wrap-tolerant: `{ a b }` block OR bare scalar — stripWrapping only strips
|
|
122
|
+
// when actually wrapped (unwrapBlock would mangle bare ids).
|
|
123
|
+
return (0, tokenize_1.default)((0, tokenize_2.stripWrapping)(block))
|
|
124
|
+
.map(field_parser_1.stripColon)
|
|
125
|
+
.map(tokenize_2.stripWrapping)
|
|
126
|
+
.filter(s => s.length > 0);
|
|
127
|
+
}
|
|
128
|
+
function dumpIdList(keyword, ids, indent) {
|
|
129
|
+
if (ids.length === 0) {
|
|
130
|
+
return '';
|
|
131
|
+
}
|
|
132
|
+
return `${indent}${keyword} { ${ids.join(' ')} }\n`;
|
|
133
|
+
}
|
|
134
|
+
function readReference(block) {
|
|
135
|
+
return (0, tokenize_1.default)((0, tokenize_2.stripWrapping)(block))
|
|
136
|
+
.map(tokenize_2.stripWrapping)
|
|
137
|
+
.filter(s => s.length > 0);
|
|
138
|
+
}
|
|
139
|
+
// ── instrument ───────────────────────────────────────────────────────
|
|
140
|
+
const parseInstrument = function (id, data) {
|
|
141
|
+
const result = {
|
|
142
|
+
id,
|
|
143
|
+
extends: '',
|
|
144
|
+
definition: '',
|
|
145
|
+
variants: [],
|
|
146
|
+
dimensions: [],
|
|
147
|
+
perChannel: '',
|
|
148
|
+
familyCriteria: [],
|
|
149
|
+
familyDefaultDimensions: [],
|
|
150
|
+
familyDefaultParameters: [],
|
|
151
|
+
modelGroup: null,
|
|
152
|
+
referenceIds: [],
|
|
153
|
+
measurand: null,
|
|
154
|
+
components: [],
|
|
155
|
+
structure: [],
|
|
156
|
+
};
|
|
157
|
+
const t = (0, tokenize_2.tokenizePackage)(data);
|
|
158
|
+
let i = 0;
|
|
159
|
+
while (i < t.length) {
|
|
160
|
+
const cmd = t[i++];
|
|
161
|
+
if (i >= t.length) {
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
if (cmd === 'extends') {
|
|
165
|
+
result.extends = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
166
|
+
}
|
|
167
|
+
else if (cmd === 'measurand_kind') {
|
|
168
|
+
result.measurandKind = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
169
|
+
}
|
|
170
|
+
else if (cmd === 'measurand') {
|
|
171
|
+
result.measurand = parseMeasurand((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
172
|
+
}
|
|
173
|
+
else if (cmd === 'component') {
|
|
174
|
+
result.components.push(parseComponent((0, tokenize_2.stripWrapping)(t[i++]), (0, tokenize_2.unwrapBlock)(t[i++])));
|
|
175
|
+
}
|
|
176
|
+
else if (cmd === 'structure') {
|
|
177
|
+
result.structure.push(parseStructure((0, tokenize_2.stripWrapping)(t[i++]), (0, tokenize_2.unwrapBlock)(t[i++])));
|
|
178
|
+
}
|
|
179
|
+
else if (cmd === 'definition') {
|
|
180
|
+
result.definition = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
181
|
+
}
|
|
182
|
+
else if (cmd === 'note') {
|
|
183
|
+
result.note = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
184
|
+
}
|
|
185
|
+
else if (cmd === 'source') {
|
|
186
|
+
result.source = (0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
187
|
+
}
|
|
188
|
+
else if (cmd === 'variant') {
|
|
189
|
+
const variantId = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
190
|
+
const vblock = i < t.length ? (0, tokenize_2.unwrapBlock)(t[i++]) : '';
|
|
191
|
+
const v = { id: variantId, definition: '' };
|
|
192
|
+
const vt = (0, tokenize_1.default)(vblock);
|
|
193
|
+
let j = 0;
|
|
194
|
+
while (j < vt.length) {
|
|
195
|
+
const vc = vt[j++];
|
|
196
|
+
if (j >= vt.length) {
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
if (vc === 'name') {
|
|
200
|
+
v.name = (0, tokenize_2.stripWrapping)(vt[j++]);
|
|
201
|
+
}
|
|
202
|
+
else if (vc === 'definition') {
|
|
203
|
+
v.definition = (0, tokenize_2.stripWrapping)(vt[j++]);
|
|
204
|
+
}
|
|
205
|
+
else if (vc === 'note') {
|
|
206
|
+
v.note = (0, tokenize_2.stripWrapping)(vt[j++]);
|
|
207
|
+
}
|
|
208
|
+
else if (vc === 'source') {
|
|
209
|
+
v.source = (0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(vt[j++]));
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
(0, tokenize_2.unwrapBlock)(vt[j++]);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
result.variants.push(v);
|
|
216
|
+
}
|
|
217
|
+
else if (cmd === 'dimension') {
|
|
218
|
+
result.dimensions.push(parseDimension((0, tokenize_2.stripWrapping)(t[i++]), (0, tokenize_2.unwrapBlock)(t[i++])));
|
|
219
|
+
}
|
|
220
|
+
else if (cmd === 'per_channel') {
|
|
221
|
+
result.perChannel = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
222
|
+
}
|
|
223
|
+
else if (cmd === 'family_criteria') {
|
|
224
|
+
result.familyCriteria = readReference(t[i++]);
|
|
225
|
+
}
|
|
226
|
+
else if (cmd === 'family') {
|
|
227
|
+
// family { metamodel_class X definition "..." note "..." source { … } }
|
|
228
|
+
const fblk = (0, tokenize_2.unwrapBlock)(t[i++]);
|
|
229
|
+
const ft = (0, tokenize_1.default)(fblk);
|
|
230
|
+
let j = 0;
|
|
231
|
+
while (j < ft.length) {
|
|
232
|
+
const fc = ft[j++];
|
|
233
|
+
if (j >= ft.length) {
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
if (fc === 'metamodel_class') {
|
|
237
|
+
result.familyMetamodelClass = (0, tokenize_2.stripWrapping)(ft[j++]);
|
|
238
|
+
}
|
|
239
|
+
else if (fc === 'definition') {
|
|
240
|
+
result.familyDefinition = (0, tokenize_2.stripWrapping)(ft[j++]);
|
|
241
|
+
}
|
|
242
|
+
else if (fc === 'note') {
|
|
243
|
+
result.familyNote = (0, tokenize_2.stripWrapping)(ft[j++]);
|
|
244
|
+
}
|
|
245
|
+
else if (fc === 'source') {
|
|
246
|
+
result.familySource = (0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(ft[j++]));
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
(0, tokenize_2.unwrapBlock)(ft[j++]);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
else if (cmd === 'family_defaults') {
|
|
254
|
+
const fblock = (0, tokenize_2.unwrapBlock)(t[i++]);
|
|
255
|
+
const ft = (0, tokenize_1.default)(fblock);
|
|
256
|
+
let j = 0;
|
|
257
|
+
while (j < ft.length) {
|
|
258
|
+
const fc = ft[j++];
|
|
259
|
+
if (j >= ft.length) {
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
if (fc === 'dimensions') {
|
|
263
|
+
result.familyDefaultDimensions = readIdList(ft[j++]);
|
|
264
|
+
}
|
|
265
|
+
else if (fc === 'parameters') {
|
|
266
|
+
result.familyDefaultParameters = readIdList(ft[j++]);
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
(0, tokenize_2.unwrapBlock)(ft[j++]);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
else if (cmd === 'model_group') {
|
|
274
|
+
result.modelGroup = parseModelGroup((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
275
|
+
}
|
|
276
|
+
else if (cmd === 'reference') {
|
|
277
|
+
result.referenceIds = readReference(t[i++]);
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
(0, tokenize_2.unwrapBlock)(t[i++]);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return ctx => {
|
|
284
|
+
ctx.instruments[id] = result;
|
|
285
|
+
return ctx;
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
/** measurand { kind X description "..." context { … } source { … } } (TODO.roadmap/19, G8). */
|
|
289
|
+
function parseMeasurand(block) {
|
|
290
|
+
const m = {
|
|
291
|
+
kind: '',
|
|
292
|
+
description: '',
|
|
293
|
+
context: null,
|
|
294
|
+
source: null,
|
|
295
|
+
};
|
|
296
|
+
const t = (0, tokenize_1.default)(block);
|
|
297
|
+
let i = 0;
|
|
298
|
+
while (i < t.length) {
|
|
299
|
+
const cmd = t[i++];
|
|
300
|
+
if (i >= t.length) {
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
if (cmd === 'kind') {
|
|
304
|
+
m.kind = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
305
|
+
}
|
|
306
|
+
else if (cmd === 'description') {
|
|
307
|
+
m.description = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
308
|
+
}
|
|
309
|
+
else if (cmd === 'context') {
|
|
310
|
+
const ctx = { targetObject: '', identificationMethod: '' };
|
|
311
|
+
const ct = (0, tokenize_1.default)((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
312
|
+
let j = 0;
|
|
313
|
+
while (j < ct.length) {
|
|
314
|
+
const cc = ct[j++];
|
|
315
|
+
if (j >= ct.length) {
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
318
|
+
if (cc === 'target_object') {
|
|
319
|
+
ctx.targetObject = (0, tokenize_2.stripWrapping)(ct[j++]);
|
|
320
|
+
}
|
|
321
|
+
else if (cc === 'identification_method') {
|
|
322
|
+
ctx.identificationMethod = (0, tokenize_2.stripWrapping)(ct[j++]);
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
(0, tokenize_2.unwrapBlock)(ct[j++]);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
m.context = ctx;
|
|
329
|
+
}
|
|
330
|
+
else if (cmd === 'source') {
|
|
331
|
+
m.source = (0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
(0, tokenize_2.unwrapBlock)(t[i++]);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return m;
|
|
338
|
+
}
|
|
339
|
+
/** component <id> { class X definition "..." source { … } } (TODO.roadmap/19, G3). */
|
|
340
|
+
function parseComponent(id, block) {
|
|
341
|
+
const c = {
|
|
342
|
+
id,
|
|
343
|
+
classId: '',
|
|
344
|
+
definition: '',
|
|
345
|
+
source: null,
|
|
346
|
+
};
|
|
347
|
+
const t = (0, tokenize_1.default)(block);
|
|
348
|
+
let i = 0;
|
|
349
|
+
while (i < t.length) {
|
|
350
|
+
const cmd = t[i++];
|
|
351
|
+
if (i >= t.length) {
|
|
352
|
+
break;
|
|
353
|
+
}
|
|
354
|
+
if (cmd === 'class') {
|
|
355
|
+
c.classId = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
356
|
+
}
|
|
357
|
+
else if (cmd === 'definition') {
|
|
358
|
+
c.definition = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
359
|
+
}
|
|
360
|
+
else if (cmd === 'source') {
|
|
361
|
+
c.source = (0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
(0, tokenize_2.unwrapBlock)(t[i++]);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
return c;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* structure <id> { predicate X subject Y target Z applicability { … }
|
|
371
|
+
* propagation { prop dir … } note "..." source { … } } (TODO.roadmap/19, G3).
|
|
372
|
+
*/
|
|
373
|
+
function parseStructure(id, block) {
|
|
374
|
+
const s = {
|
|
375
|
+
id,
|
|
376
|
+
predicate: '',
|
|
377
|
+
subject: '',
|
|
378
|
+
target: '',
|
|
379
|
+
applicability: [],
|
|
380
|
+
propagation: [],
|
|
381
|
+
note: '',
|
|
382
|
+
source: null,
|
|
383
|
+
};
|
|
384
|
+
const t = (0, tokenize_1.default)(block);
|
|
385
|
+
let i = 0;
|
|
386
|
+
while (i < t.length) {
|
|
387
|
+
const cmd = t[i++];
|
|
388
|
+
if (i >= t.length) {
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
if (cmd === 'predicate') {
|
|
392
|
+
s.predicate = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
393
|
+
}
|
|
394
|
+
else if (cmd === 'subject') {
|
|
395
|
+
s.subject = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
396
|
+
}
|
|
397
|
+
else if (cmd === 'target') {
|
|
398
|
+
s.target = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
399
|
+
}
|
|
400
|
+
else if (cmd === 'applicability') {
|
|
401
|
+
s.applicability = (0, field_parser_2.parseApplicability)((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
402
|
+
}
|
|
403
|
+
else if (cmd === 'propagation') {
|
|
404
|
+
const pt = (0, tokenize_1.default)((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
405
|
+
for (let j = 0; j + 1 < pt.length; j += 2) {
|
|
406
|
+
s.propagation.push({
|
|
407
|
+
property: (0, tokenize_2.stripWrapping)(pt[j]),
|
|
408
|
+
direction: (0, tokenize_2.stripWrapping)(pt[j + 1]),
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
else if (cmd === 'note') {
|
|
413
|
+
s.note = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
414
|
+
}
|
|
415
|
+
else if (cmd === 'source') {
|
|
416
|
+
s.source = (0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
417
|
+
}
|
|
418
|
+
else {
|
|
419
|
+
(0, tokenize_2.unwrapBlock)(t[i++]);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
return s;
|
|
423
|
+
}
|
|
424
|
+
function parseDimension(id, block) {
|
|
425
|
+
const dim = {
|
|
426
|
+
id,
|
|
427
|
+
label: '',
|
|
428
|
+
scope: '',
|
|
429
|
+
cardinality: '',
|
|
430
|
+
labelSeparator: '',
|
|
431
|
+
description: '',
|
|
432
|
+
source: null,
|
|
433
|
+
values: [],
|
|
434
|
+
};
|
|
435
|
+
const t = (0, tokenize_1.default)(block);
|
|
436
|
+
let i = 0;
|
|
437
|
+
while (i < t.length) {
|
|
438
|
+
const cmd = t[i++];
|
|
439
|
+
if (i >= t.length) {
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
if (cmd === 'label') {
|
|
443
|
+
dim.label = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
444
|
+
}
|
|
445
|
+
else if (cmd === 'scope') {
|
|
446
|
+
dim.scope = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
447
|
+
}
|
|
448
|
+
else if (cmd === 'cardinality') {
|
|
449
|
+
const c = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
450
|
+
if (c !== 'single' && c !== 'set') {
|
|
451
|
+
throw new Error(`Parsing error: dimension. ID ${id}: Unknown cardinality ${c} (valid: single, set)`);
|
|
452
|
+
}
|
|
453
|
+
dim.cardinality = c;
|
|
454
|
+
}
|
|
455
|
+
else if (cmd === 'label_separator') {
|
|
456
|
+
dim.labelSeparator = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
457
|
+
}
|
|
458
|
+
else if (cmd === 'description') {
|
|
459
|
+
dim.description = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
460
|
+
}
|
|
461
|
+
else if (cmd === 'reference' || cmd === 'source') {
|
|
462
|
+
dim.source = (0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
463
|
+
}
|
|
464
|
+
else if (cmd === 'values') {
|
|
465
|
+
dim.values = parseDimensionValues((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
466
|
+
}
|
|
467
|
+
else {
|
|
468
|
+
(0, tokenize_2.unwrapBlock)(t[i++]);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
return dim;
|
|
472
|
+
}
|
|
473
|
+
function parseDimensionValues(block) {
|
|
474
|
+
const out = [];
|
|
475
|
+
const t = (0, tokenize_1.default)(block);
|
|
476
|
+
let i = 0;
|
|
477
|
+
while (i < t.length) {
|
|
478
|
+
const id = (0, field_parser_1.stripColon)(t[i++]);
|
|
479
|
+
if (!id) {
|
|
480
|
+
break;
|
|
481
|
+
}
|
|
482
|
+
const value = {
|
|
483
|
+
id,
|
|
484
|
+
label: '',
|
|
485
|
+
description: '',
|
|
486
|
+
payload: {},
|
|
487
|
+
implies: [],
|
|
488
|
+
};
|
|
489
|
+
if (i < t.length && t[i].startsWith('{')) {
|
|
490
|
+
const vblock = (0, tokenize_2.unwrapBlock)(t[i++]);
|
|
491
|
+
const vt = (0, tokenize_1.default)(vblock);
|
|
492
|
+
let j = 0;
|
|
493
|
+
while (j < vt.length) {
|
|
494
|
+
const cmd = vt[j++];
|
|
495
|
+
if (j >= vt.length) {
|
|
496
|
+
break;
|
|
497
|
+
}
|
|
498
|
+
if (cmd === 'label') {
|
|
499
|
+
value.label = (0, tokenize_2.stripWrapping)(vt[j++]);
|
|
500
|
+
}
|
|
501
|
+
else if (cmd === 'description') {
|
|
502
|
+
value.description = (0, tokenize_2.stripWrapping)(vt[j++]);
|
|
503
|
+
}
|
|
504
|
+
else if (cmd === 'implies') {
|
|
505
|
+
value.implies = readIdList(vt[j++]);
|
|
506
|
+
}
|
|
507
|
+
else if (cmd === 'term_ref') {
|
|
508
|
+
value.termRef = (0, tokenize_2.stripWrapping)(vt[j++]);
|
|
509
|
+
}
|
|
510
|
+
else if (cmd === 'payload') {
|
|
511
|
+
const pblock = (0, tokenize_2.unwrapBlock)(vt[j++]);
|
|
512
|
+
const pt = (0, tokenize_1.default)(pblock);
|
|
513
|
+
let k = 0;
|
|
514
|
+
while (k < pt.length) {
|
|
515
|
+
const key = (0, field_parser_1.stripColon)(pt[k++]);
|
|
516
|
+
if (k >= pt.length) {
|
|
517
|
+
break;
|
|
518
|
+
}
|
|
519
|
+
if (pt[k] === ':') {
|
|
520
|
+
k++;
|
|
521
|
+
}
|
|
522
|
+
if (k < pt.length && pt[k].startsWith('{')) {
|
|
523
|
+
// Nested payload block: n_lc_limits { lower: 50000 upper: unlimited }
|
|
524
|
+
const nt = (0, tokenize_1.default)((0, tokenize_2.unwrapBlock)(pt[k++]));
|
|
525
|
+
const nested = {};
|
|
526
|
+
let n = 0;
|
|
527
|
+
while (n < nt.length) {
|
|
528
|
+
const nkey = (0, field_parser_1.stripColon)(nt[n++]);
|
|
529
|
+
if (n >= nt.length) {
|
|
530
|
+
break;
|
|
531
|
+
}
|
|
532
|
+
if (nt[n] === ':') {
|
|
533
|
+
n++;
|
|
534
|
+
}
|
|
535
|
+
if (n < nt.length) {
|
|
536
|
+
nested[nkey] = (0, tokenize_2.stripWrapping)(nt[n++]);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
value.payload[key] = nested;
|
|
540
|
+
}
|
|
541
|
+
else if (k < pt.length) {
|
|
542
|
+
value.payload[key] = (0, tokenize_2.stripWrapping)(pt[k++]);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
else {
|
|
547
|
+
(0, tokenize_2.unwrapBlock)(vt[j++]);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
out.push(value);
|
|
552
|
+
}
|
|
553
|
+
return out;
|
|
554
|
+
}
|
|
555
|
+
function parseModelGroup(block) {
|
|
556
|
+
const mg = {
|
|
557
|
+
definition: '',
|
|
558
|
+
identicalCharacteristics: [],
|
|
559
|
+
identicalAttributes: [],
|
|
560
|
+
sources: [],
|
|
561
|
+
sampleSelection: [],
|
|
562
|
+
};
|
|
563
|
+
const t = (0, tokenize_1.default)(block);
|
|
564
|
+
let i = 0;
|
|
565
|
+
while (i < t.length) {
|
|
566
|
+
const cmd = t[i++];
|
|
567
|
+
if (i >= t.length) {
|
|
568
|
+
break;
|
|
569
|
+
}
|
|
570
|
+
if (cmd === 'definition') {
|
|
571
|
+
mg.definition = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
572
|
+
}
|
|
573
|
+
else if (cmd === 'identical_characteristics') {
|
|
574
|
+
mg.identicalCharacteristics = readIdList(t[i++]);
|
|
575
|
+
}
|
|
576
|
+
else if (cmd === 'identical_attributes') {
|
|
577
|
+
mg.identicalAttributes = readIdList(t[i++]);
|
|
578
|
+
}
|
|
579
|
+
else if (cmd === 'group_by') {
|
|
580
|
+
mg.groupBy = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
581
|
+
}
|
|
582
|
+
else if (cmd === 'note') {
|
|
583
|
+
mg.note = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
584
|
+
}
|
|
585
|
+
else if (cmd === 'source') {
|
|
586
|
+
mg.sources.push((0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(t[i++])));
|
|
587
|
+
}
|
|
588
|
+
else if (cmd === 'sample_selection') {
|
|
589
|
+
mg.sampleSelection.push((0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(t[i++])));
|
|
590
|
+
}
|
|
591
|
+
else {
|
|
592
|
+
(0, tokenize_2.unwrapBlock)(t[i++]);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
return mg;
|
|
596
|
+
}
|
|
597
|
+
const dumpInstrument = function (inst) {
|
|
598
|
+
let out = 'instrument ' + inst.id + ' {\n';
|
|
599
|
+
if (inst.extends) {
|
|
600
|
+
out += ' extends ' + inst.extends + '\n';
|
|
601
|
+
}
|
|
602
|
+
if (inst.perChannel) {
|
|
603
|
+
out += ' per_channel ' + inst.perChannel + '\n';
|
|
604
|
+
}
|
|
605
|
+
if (inst.measurandKind) {
|
|
606
|
+
out += ' measurand_kind ' + inst.measurandKind + '\n';
|
|
607
|
+
}
|
|
608
|
+
if (inst.measurand) {
|
|
609
|
+
const m = inst.measurand;
|
|
610
|
+
out += ' measurand {\n';
|
|
611
|
+
if (m.kind) {
|
|
612
|
+
out += ' kind ' + m.kind + '\n';
|
|
613
|
+
}
|
|
614
|
+
if (m.description) {
|
|
615
|
+
out += ' description "' + (0, tokenize_2.escapeString)(m.description) + '"\n';
|
|
616
|
+
}
|
|
617
|
+
if (m.context) {
|
|
618
|
+
out += ' context {';
|
|
619
|
+
if (m.context.targetObject) {
|
|
620
|
+
out += ' target_object "' + (0, tokenize_2.escapeString)(m.context.targetObject) + '"';
|
|
621
|
+
}
|
|
622
|
+
if (m.context.identificationMethod) {
|
|
623
|
+
out +=
|
|
624
|
+
' identification_method "' +
|
|
625
|
+
(0, tokenize_2.escapeString)(m.context.identificationMethod) +
|
|
626
|
+
'"';
|
|
627
|
+
}
|
|
628
|
+
out += ' }\n';
|
|
629
|
+
}
|
|
630
|
+
out += dumpSource('source', m.source, ' ');
|
|
631
|
+
out += ' }\n';
|
|
632
|
+
}
|
|
633
|
+
for (const c of inst.components ?? []) {
|
|
634
|
+
let line = ' component ' + c.id + ' { ';
|
|
635
|
+
if (c.classId) {
|
|
636
|
+
line += 'class ' + c.classId + ' ';
|
|
637
|
+
}
|
|
638
|
+
if (c.definition) {
|
|
639
|
+
line += 'definition "' + (0, tokenize_2.escapeString)(c.definition) + '" ';
|
|
640
|
+
}
|
|
641
|
+
if (c.source && (c.source.doc || c.source.clause)) {
|
|
642
|
+
line +=
|
|
643
|
+
'source { doc "' +
|
|
644
|
+
(0, tokenize_2.escapeString)(c.source.doc) +
|
|
645
|
+
'" clause "' +
|
|
646
|
+
(0, tokenize_2.escapeString)(c.source.clause) +
|
|
647
|
+
'" } ';
|
|
648
|
+
}
|
|
649
|
+
out += line + '}\n';
|
|
650
|
+
}
|
|
651
|
+
for (const s of inst.structure ?? []) {
|
|
652
|
+
out += ' structure ' + s.id + ' {\n';
|
|
653
|
+
if (s.predicate) {
|
|
654
|
+
out += ' predicate ' + s.predicate + '\n';
|
|
655
|
+
}
|
|
656
|
+
if (s.subject) {
|
|
657
|
+
out += ' subject ' + s.subject + '\n';
|
|
658
|
+
}
|
|
659
|
+
if (s.target) {
|
|
660
|
+
out += ' target ' + s.target + '\n';
|
|
661
|
+
}
|
|
662
|
+
if (s.applicability.length > 0) {
|
|
663
|
+
out +=
|
|
664
|
+
' applicability { ' +
|
|
665
|
+
(0, field_parser_2.dumpApplicabilityEntries)(s.applicability).trim() +
|
|
666
|
+
' }\n';
|
|
667
|
+
}
|
|
668
|
+
if (s.propagation.length > 0) {
|
|
669
|
+
out += ' propagation { ';
|
|
670
|
+
for (const p of s.propagation) {
|
|
671
|
+
out += p.property + ' ' + p.direction + ' ';
|
|
672
|
+
}
|
|
673
|
+
out += '}\n';
|
|
674
|
+
}
|
|
675
|
+
if (s.note) {
|
|
676
|
+
out += ' note "' + (0, tokenize_2.escapeString)(s.note) + '"\n';
|
|
677
|
+
}
|
|
678
|
+
out += dumpSource('source', s.source, ' ');
|
|
679
|
+
out += ' }\n';
|
|
680
|
+
}
|
|
681
|
+
if (inst.definition) {
|
|
682
|
+
out += ' definition "' + (0, tokenize_2.escapeString)(inst.definition) + '"\n';
|
|
683
|
+
}
|
|
684
|
+
if (inst.note) {
|
|
685
|
+
out += ' note "' + (0, tokenize_2.escapeString)(inst.note) + '"\n';
|
|
686
|
+
}
|
|
687
|
+
for (const v of inst.variants) {
|
|
688
|
+
let line = ' variant ' + v.id + ' { ';
|
|
689
|
+
if (v.name) {
|
|
690
|
+
line += 'name "' + (0, tokenize_2.escapeString)(v.name) + '" ';
|
|
691
|
+
}
|
|
692
|
+
line += 'definition "' + (0, tokenize_2.escapeString)(v.definition) + '" ';
|
|
693
|
+
if (v.note) {
|
|
694
|
+
line += 'note "' + (0, tokenize_2.escapeString)(v.note) + '" ';
|
|
695
|
+
}
|
|
696
|
+
if (v.source && (v.source.doc || v.source.clause)) {
|
|
697
|
+
line +=
|
|
698
|
+
'source { doc "' +
|
|
699
|
+
(0, tokenize_2.escapeString)(v.source.doc) +
|
|
700
|
+
'" clause "' +
|
|
701
|
+
(0, tokenize_2.escapeString)(v.source.clause) +
|
|
702
|
+
'" } ';
|
|
703
|
+
}
|
|
704
|
+
out += line + '}\n';
|
|
705
|
+
}
|
|
706
|
+
for (const d of inst.dimensions) {
|
|
707
|
+
out += ' dimension ' + d.id + ' {\n';
|
|
708
|
+
if (d.label) {
|
|
709
|
+
out += ' label "' + (0, tokenize_2.escapeString)(d.label) + '"\n';
|
|
710
|
+
}
|
|
711
|
+
if (d.scope) {
|
|
712
|
+
out += ' scope ' + d.scope + '\n';
|
|
713
|
+
}
|
|
714
|
+
if (d.cardinality) {
|
|
715
|
+
out += ' cardinality ' + d.cardinality + '\n';
|
|
716
|
+
}
|
|
717
|
+
if (d.labelSeparator) {
|
|
718
|
+
out += ' label_separator "' + (0, tokenize_2.escapeString)(d.labelSeparator) + '"\n';
|
|
719
|
+
}
|
|
720
|
+
if (d.description) {
|
|
721
|
+
out += ' description "' + (0, tokenize_2.escapeString)(d.description) + '"\n';
|
|
722
|
+
}
|
|
723
|
+
out += dumpSource('reference', d.source, ' ');
|
|
724
|
+
if (d.values.length > 0) {
|
|
725
|
+
out += ' values {\n';
|
|
726
|
+
for (const v of d.values) {
|
|
727
|
+
let line = ' ' + v.id;
|
|
728
|
+
const hasProps = v.label ||
|
|
729
|
+
v.description ||
|
|
730
|
+
v.termRef ||
|
|
731
|
+
Object.keys(v.payload).length > 0 ||
|
|
732
|
+
v.implies.length > 0;
|
|
733
|
+
if (hasProps) {
|
|
734
|
+
line += ' { ';
|
|
735
|
+
if (v.label) {
|
|
736
|
+
line += 'label "' + (0, tokenize_2.escapeString)(v.label) + '" ';
|
|
737
|
+
}
|
|
738
|
+
if (v.description) {
|
|
739
|
+
line += 'description "' + (0, tokenize_2.escapeString)(v.description) + '" ';
|
|
740
|
+
}
|
|
741
|
+
if (v.termRef) {
|
|
742
|
+
line += 'term_ref ' + v.termRef + ' ';
|
|
743
|
+
}
|
|
744
|
+
if (v.implies.length > 0) {
|
|
745
|
+
line += 'implies { ' + v.implies.join(' ') + ' } ';
|
|
746
|
+
}
|
|
747
|
+
if (Object.keys(v.payload).length > 0) {
|
|
748
|
+
line += 'payload { ';
|
|
749
|
+
for (const [k, val] of Object.entries(v.payload)) {
|
|
750
|
+
if (typeof val === 'object' && val !== null) {
|
|
751
|
+
line += k + ' { ';
|
|
752
|
+
for (const [nk, nv] of Object.entries(val)) {
|
|
753
|
+
line += nk + ': "' + (0, tokenize_2.escapeString)(String(nv)) + '" ';
|
|
754
|
+
}
|
|
755
|
+
line += '} ';
|
|
756
|
+
}
|
|
757
|
+
else {
|
|
758
|
+
line += k + ': "' + (0, tokenize_2.escapeString)(String(val)) + '" ';
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
line += '} ';
|
|
762
|
+
}
|
|
763
|
+
line += '}';
|
|
764
|
+
}
|
|
765
|
+
out += line + '\n';
|
|
766
|
+
}
|
|
767
|
+
out += ' }\n';
|
|
768
|
+
}
|
|
769
|
+
out += ' }\n';
|
|
770
|
+
}
|
|
771
|
+
if (inst.familyMetamodelClass ||
|
|
772
|
+
inst.familyDefinition ||
|
|
773
|
+
inst.familyNote ||
|
|
774
|
+
(inst.familySource && (inst.familySource.doc || inst.familySource.clause))) {
|
|
775
|
+
out += ' family {\n';
|
|
776
|
+
if (inst.familyMetamodelClass) {
|
|
777
|
+
out += ' metamodel_class ' + inst.familyMetamodelClass + '\n';
|
|
778
|
+
}
|
|
779
|
+
if (inst.familyDefinition) {
|
|
780
|
+
out += ' definition "' + (0, tokenize_2.escapeString)(inst.familyDefinition) + '"\n';
|
|
781
|
+
}
|
|
782
|
+
if (inst.familyNote) {
|
|
783
|
+
out += ' note "' + (0, tokenize_2.escapeString)(inst.familyNote) + '"\n';
|
|
784
|
+
}
|
|
785
|
+
out += dumpSource('source', inst.familySource ?? null, ' ');
|
|
786
|
+
out += ' }\n';
|
|
787
|
+
}
|
|
788
|
+
if (inst.familyCriteria.length > 0) {
|
|
789
|
+
out += ' family_criteria {\n';
|
|
790
|
+
for (const c of inst.familyCriteria) {
|
|
791
|
+
out += ' "' + (0, tokenize_2.escapeString)(c) + '"\n';
|
|
792
|
+
}
|
|
793
|
+
out += ' }\n';
|
|
794
|
+
}
|
|
795
|
+
if (inst.familyDefaultDimensions.length > 0 ||
|
|
796
|
+
inst.familyDefaultParameters.length > 0) {
|
|
797
|
+
out += ' family_defaults {\n';
|
|
798
|
+
out += dumpIdList('dimensions', inst.familyDefaultDimensions, ' ');
|
|
799
|
+
out += dumpIdList('parameters', inst.familyDefaultParameters, ' ');
|
|
800
|
+
out += ' }\n';
|
|
801
|
+
}
|
|
802
|
+
if (inst.modelGroup) {
|
|
803
|
+
out += ' model_group {\n';
|
|
804
|
+
if (inst.modelGroup.definition) {
|
|
805
|
+
out +=
|
|
806
|
+
' definition "' + (0, tokenize_2.escapeString)(inst.modelGroup.definition) + '"\n';
|
|
807
|
+
}
|
|
808
|
+
if (inst.modelGroup.groupBy) {
|
|
809
|
+
out += ' group_by ' + inst.modelGroup.groupBy + '\n';
|
|
810
|
+
}
|
|
811
|
+
if (inst.modelGroup.note) {
|
|
812
|
+
out += ' note "' + (0, tokenize_2.escapeString)(inst.modelGroup.note) + '"\n';
|
|
813
|
+
}
|
|
814
|
+
out += dumpIdList('identical_characteristics', inst.modelGroup.identicalCharacteristics, ' ');
|
|
815
|
+
out += dumpIdList('identical_attributes', inst.modelGroup.identicalAttributes, ' ');
|
|
816
|
+
for (const s of inst.modelGroup.sources ?? []) {
|
|
817
|
+
out += dumpSource('source', s, ' ');
|
|
818
|
+
}
|
|
819
|
+
for (const s of inst.modelGroup.sampleSelection ?? []) {
|
|
820
|
+
out += dumpSource('sample_selection', s, ' ');
|
|
821
|
+
}
|
|
822
|
+
out += ' }\n';
|
|
823
|
+
}
|
|
824
|
+
out += dumpSource('source', inst.source ?? null, ' ');
|
|
825
|
+
out += dumpIdList('reference', inst.referenceIds, ' ');
|
|
826
|
+
out += '}\n';
|
|
827
|
+
return out;
|
|
828
|
+
};
|
|
829
|
+
// ── attribute_definition ─────────────────────────────────────────────
|
|
830
|
+
const parseAttributeDefinition = function (id, data) {
|
|
831
|
+
const result = {
|
|
832
|
+
id,
|
|
833
|
+
symbol: '',
|
|
834
|
+
name: '',
|
|
835
|
+
definition: '',
|
|
836
|
+
source: null,
|
|
837
|
+
quantityKind: '',
|
|
838
|
+
unit: '',
|
|
839
|
+
valueType: '',
|
|
840
|
+
origin: '',
|
|
841
|
+
scope: '',
|
|
842
|
+
category: '',
|
|
843
|
+
isDimension: null,
|
|
844
|
+
enumRef: '',
|
|
845
|
+
irdi: '',
|
|
846
|
+
derived: '',
|
|
847
|
+
referenceIds: [],
|
|
848
|
+
};
|
|
849
|
+
const t = (0, tokenize_2.tokenizePackage)(data);
|
|
850
|
+
let i = 0;
|
|
851
|
+
while (i < t.length) {
|
|
852
|
+
const cmd = t[i++];
|
|
853
|
+
if (i >= t.length) {
|
|
854
|
+
break;
|
|
855
|
+
}
|
|
856
|
+
if (cmd === 'symbol') {
|
|
857
|
+
result.symbol = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
858
|
+
}
|
|
859
|
+
else if (cmd === 'name') {
|
|
860
|
+
result.name = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
861
|
+
}
|
|
862
|
+
else if (cmd === 'definition') {
|
|
863
|
+
result.definition = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
864
|
+
}
|
|
865
|
+
else if (cmd === 'source' || cmd === 'reference') {
|
|
866
|
+
result.source = (0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
867
|
+
}
|
|
868
|
+
else if (cmd === 'quantity_kind') {
|
|
869
|
+
result.quantityKind = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
870
|
+
}
|
|
871
|
+
else if (cmd === 'unit') {
|
|
872
|
+
result.unit = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
873
|
+
}
|
|
874
|
+
else if (cmd === 'value_type') {
|
|
875
|
+
result.valueType = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
876
|
+
}
|
|
877
|
+
else if (cmd === 'origin') {
|
|
878
|
+
result.origin = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
879
|
+
}
|
|
880
|
+
else if (cmd === 'scope') {
|
|
881
|
+
result.scope = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
882
|
+
}
|
|
883
|
+
else if (cmd === 'category') {
|
|
884
|
+
result.category = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
885
|
+
}
|
|
886
|
+
else if (cmd === 'is_dimension') {
|
|
887
|
+
result.isDimension = (0, tokenize_2.stripWrapping)(t[i++]) === 'true';
|
|
888
|
+
}
|
|
889
|
+
else if (cmd === 'enum') {
|
|
890
|
+
result.enumRef = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
891
|
+
}
|
|
892
|
+
else if (cmd === 'enum_values') {
|
|
893
|
+
result.enumValues = readIdList(t[i++]);
|
|
894
|
+
}
|
|
895
|
+
else if (cmd === 'note') {
|
|
896
|
+
result.note = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
897
|
+
}
|
|
898
|
+
else if (cmd === 'irdi') {
|
|
899
|
+
result.irdi = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
900
|
+
}
|
|
901
|
+
else if (cmd === 'derived') {
|
|
902
|
+
result.derived = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
903
|
+
}
|
|
904
|
+
else {
|
|
905
|
+
(0, tokenize_2.unwrapBlock)(t[i++]);
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
return ctx => {
|
|
909
|
+
ctx.attributeDefinitions[id] = result;
|
|
910
|
+
return ctx;
|
|
911
|
+
};
|
|
912
|
+
};
|
|
913
|
+
const dumpAttributeDefinition = function (a) {
|
|
914
|
+
let out = 'attribute_definition ' + a.id + ' {\n';
|
|
915
|
+
if (a.symbol) {
|
|
916
|
+
out += ' symbol "' + (0, tokenize_2.escapeString)(a.symbol) + '"\n';
|
|
917
|
+
}
|
|
918
|
+
if (a.name) {
|
|
919
|
+
out += ' name "' + (0, tokenize_2.escapeString)(a.name) + '"\n';
|
|
920
|
+
}
|
|
921
|
+
if (a.definition) {
|
|
922
|
+
out += ' definition "' + (0, tokenize_2.escapeString)(a.definition) + '"\n';
|
|
923
|
+
}
|
|
924
|
+
out += dumpSource('source', a.source, ' ');
|
|
925
|
+
if (a.quantityKind) {
|
|
926
|
+
out += ' quantity_kind ' + a.quantityKind + '\n';
|
|
927
|
+
}
|
|
928
|
+
if (a.unit) {
|
|
929
|
+
out += ' unit "' + (0, tokenize_2.escapeString)(a.unit) + '"\n';
|
|
930
|
+
}
|
|
931
|
+
if (a.valueType) {
|
|
932
|
+
out += ' value_type ' + a.valueType + '\n';
|
|
933
|
+
}
|
|
934
|
+
if (a.origin) {
|
|
935
|
+
out += ' origin ' + a.origin + '\n';
|
|
936
|
+
}
|
|
937
|
+
if (a.scope) {
|
|
938
|
+
out += ' scope ' + a.scope + '\n';
|
|
939
|
+
}
|
|
940
|
+
if (a.category) {
|
|
941
|
+
out += ' category ' + a.category + '\n';
|
|
942
|
+
}
|
|
943
|
+
if (a.isDimension !== null && a.isDimension !== undefined) {
|
|
944
|
+
out += ' is_dimension ' + (a.isDimension ? 'true' : 'false') + '\n';
|
|
945
|
+
}
|
|
946
|
+
if (a.enumRef) {
|
|
947
|
+
out += ' enum ' + a.enumRef + '\n';
|
|
948
|
+
}
|
|
949
|
+
if (a.irdi) {
|
|
950
|
+
out += ' irdi "' + (0, tokenize_2.escapeString)(a.irdi) + '"\n';
|
|
951
|
+
}
|
|
952
|
+
if (a.derived) {
|
|
953
|
+
out += ' derived "' + (0, tokenize_2.escapeString)(a.derived) + '"\n';
|
|
954
|
+
}
|
|
955
|
+
out += '}\n';
|
|
956
|
+
return out;
|
|
957
|
+
};
|
|
958
|
+
// ── capability ───────────────────────────────────────────────────────
|
|
959
|
+
const parseCapability = function (id, data) {
|
|
960
|
+
const result = {
|
|
961
|
+
id,
|
|
962
|
+
label: '',
|
|
963
|
+
description: '',
|
|
964
|
+
abstract: false,
|
|
965
|
+
extends: [],
|
|
966
|
+
requires: [],
|
|
967
|
+
hasParameters: [],
|
|
968
|
+
satisfiesRequirements: [],
|
|
969
|
+
verifiedByTests: [],
|
|
970
|
+
referenceIds: [],
|
|
971
|
+
};
|
|
972
|
+
const t = (0, tokenize_2.tokenizePackage)(data);
|
|
973
|
+
let i = 0;
|
|
974
|
+
while (i < t.length) {
|
|
975
|
+
const cmd = t[i++];
|
|
976
|
+
if (i >= t.length) {
|
|
977
|
+
break;
|
|
978
|
+
}
|
|
979
|
+
if (cmd === 'label') {
|
|
980
|
+
result.label = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
981
|
+
}
|
|
982
|
+
else if (cmd === 'description') {
|
|
983
|
+
result.description = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
984
|
+
}
|
|
985
|
+
else if (cmd === 'abstract') {
|
|
986
|
+
result.abstract = (0, tokenize_2.stripWrapping)(t[i++]) === 'true';
|
|
987
|
+
}
|
|
988
|
+
else if (cmd === 'extends') {
|
|
989
|
+
result.extends = readIdList(t[i++]);
|
|
990
|
+
}
|
|
991
|
+
else if (cmd === 'requires') {
|
|
992
|
+
result.requires = readIdList(t[i++]);
|
|
993
|
+
}
|
|
994
|
+
else if (cmd === 'has_parameters') {
|
|
995
|
+
result.hasParameters = readIdList(t[i++]);
|
|
996
|
+
}
|
|
997
|
+
else if (cmd === 'satisfies_requirements') {
|
|
998
|
+
result.satisfiesRequirements = readReference(t[i++]);
|
|
999
|
+
}
|
|
1000
|
+
else if (cmd === 'verified_by_tests' || cmd === 'verified_by') {
|
|
1001
|
+
result.verifiedByTests = readReference(t[i++]);
|
|
1002
|
+
}
|
|
1003
|
+
else if (cmd === 'reference') {
|
|
1004
|
+
result.referenceIds = readReference(t[i++]);
|
|
1005
|
+
}
|
|
1006
|
+
else {
|
|
1007
|
+
(0, tokenize_2.unwrapBlock)(t[i++]);
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
return ctx => {
|
|
1011
|
+
ctx.capabilities[id] = result;
|
|
1012
|
+
return ctx;
|
|
1013
|
+
};
|
|
1014
|
+
};
|
|
1015
|
+
const dumpCapability = function (c) {
|
|
1016
|
+
let out = 'capability ' + c.id + ' {\n';
|
|
1017
|
+
if (c.label) {
|
|
1018
|
+
out += ' label "' + (0, tokenize_2.escapeString)(c.label) + '"\n';
|
|
1019
|
+
}
|
|
1020
|
+
if (c.description) {
|
|
1021
|
+
out += ' description "' + (0, tokenize_2.escapeString)(c.description) + '"\n';
|
|
1022
|
+
}
|
|
1023
|
+
if (c.abstract) {
|
|
1024
|
+
out += ' abstract true\n';
|
|
1025
|
+
}
|
|
1026
|
+
out += dumpIdList('extends', c.extends, ' ');
|
|
1027
|
+
out += dumpIdList('requires', c.requires, ' ');
|
|
1028
|
+
out += dumpIdList('has_parameters', c.hasParameters, ' ');
|
|
1029
|
+
out += dumpIdList('satisfies_requirements', c.satisfiesRequirements, ' ');
|
|
1030
|
+
out += dumpIdList('verified_by_tests', c.verifiedByTests, ' ');
|
|
1031
|
+
out += dumpIdList('reference', c.referenceIds, ' ');
|
|
1032
|
+
out += '}\n';
|
|
1033
|
+
return out;
|
|
1034
|
+
};
|
|
1035
|
+
// ── behavior ─────────────────────────────────────────────────────────
|
|
1036
|
+
const parseBehavior = function (id, data) {
|
|
1037
|
+
const result = {
|
|
1038
|
+
id,
|
|
1039
|
+
kind: '',
|
|
1040
|
+
stimulus: '',
|
|
1041
|
+
response: '',
|
|
1042
|
+
source: null,
|
|
1043
|
+
verifiedBy: [],
|
|
1044
|
+
referenceIds: [],
|
|
1045
|
+
};
|
|
1046
|
+
const t = (0, tokenize_2.tokenizePackage)(data);
|
|
1047
|
+
let i = 0;
|
|
1048
|
+
while (i < t.length) {
|
|
1049
|
+
const cmd = t[i++];
|
|
1050
|
+
if (i >= t.length) {
|
|
1051
|
+
break;
|
|
1052
|
+
}
|
|
1053
|
+
if (cmd === 'kind') {
|
|
1054
|
+
result.kind = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
1055
|
+
}
|
|
1056
|
+
else if (cmd === 'stimulus') {
|
|
1057
|
+
result.stimulus = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
1058
|
+
}
|
|
1059
|
+
else if (cmd === 'response') {
|
|
1060
|
+
result.response = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
1061
|
+
}
|
|
1062
|
+
else if (cmd === 'source' || cmd === 'reference') {
|
|
1063
|
+
result.source = (0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
1064
|
+
}
|
|
1065
|
+
else if (cmd === 'verified_by' || cmd === 'verified_by_tests') {
|
|
1066
|
+
result.verifiedBy = readReference(t[i++]);
|
|
1067
|
+
}
|
|
1068
|
+
else {
|
|
1069
|
+
(0, tokenize_2.unwrapBlock)(t[i++]);
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
return ctx => {
|
|
1073
|
+
ctx.behaviors[id] = result;
|
|
1074
|
+
return ctx;
|
|
1075
|
+
};
|
|
1076
|
+
};
|
|
1077
|
+
const dumpBehavior = function (b) {
|
|
1078
|
+
let out = 'behavior ' + b.id + ' {\n';
|
|
1079
|
+
if (b.kind) {
|
|
1080
|
+
out += ' kind ' + b.kind + '\n';
|
|
1081
|
+
}
|
|
1082
|
+
if (b.stimulus) {
|
|
1083
|
+
out += ' stimulus ' + b.stimulus + '\n';
|
|
1084
|
+
}
|
|
1085
|
+
if (b.response) {
|
|
1086
|
+
out += ' response "' + (0, tokenize_2.escapeString)(b.response) + '"\n';
|
|
1087
|
+
}
|
|
1088
|
+
out += dumpSource('source', b.source, ' ');
|
|
1089
|
+
out += dumpIdList('verified_by', b.verifiedBy, ' ');
|
|
1090
|
+
out += '}\n';
|
|
1091
|
+
return out;
|
|
1092
|
+
};
|
|
1093
|
+
// ── condition_set ────────────────────────────────────────────────────
|
|
1094
|
+
const parseConditionSet = function (id, data) {
|
|
1095
|
+
const result = {
|
|
1096
|
+
id,
|
|
1097
|
+
role: '',
|
|
1098
|
+
entries: [],
|
|
1099
|
+
source: null,
|
|
1100
|
+
sources: [],
|
|
1101
|
+
referenceIds: [],
|
|
1102
|
+
};
|
|
1103
|
+
const t = (0, tokenize_2.tokenizePackage)(data);
|
|
1104
|
+
let i = 0;
|
|
1105
|
+
while (i < t.length) {
|
|
1106
|
+
const cmd = t[i++];
|
|
1107
|
+
if (i >= t.length) {
|
|
1108
|
+
break;
|
|
1109
|
+
}
|
|
1110
|
+
if (cmd === 'role') {
|
|
1111
|
+
result.role = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
1112
|
+
}
|
|
1113
|
+
else if (cmd === 'subject') {
|
|
1114
|
+
result.subject = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
1115
|
+
}
|
|
1116
|
+
else if (cmd === 'description') {
|
|
1117
|
+
result.description = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
1118
|
+
}
|
|
1119
|
+
else if (cmd === 'entries') {
|
|
1120
|
+
result.entries = parseConditionEntries((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
1121
|
+
}
|
|
1122
|
+
else if (cmd === 'source') {
|
|
1123
|
+
// Repeated source blocks accumulate; `source` stays the first entry.
|
|
1124
|
+
const src = (0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
1125
|
+
result.sources.push(src);
|
|
1126
|
+
if (!result.source) {
|
|
1127
|
+
result.source = src;
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
else if (cmd === 'reference') {
|
|
1131
|
+
result.referenceIds = readReference(t[i++]);
|
|
1132
|
+
}
|
|
1133
|
+
else {
|
|
1134
|
+
(0, tokenize_2.unwrapBlock)(t[i++]);
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
return ctx => {
|
|
1138
|
+
ctx.conditionSets[id] = result;
|
|
1139
|
+
return ctx;
|
|
1140
|
+
};
|
|
1141
|
+
};
|
|
1142
|
+
function parseConditionEntries(block) {
|
|
1143
|
+
const out = [];
|
|
1144
|
+
const t = (0, tokenize_1.default)(block);
|
|
1145
|
+
let i = 0;
|
|
1146
|
+
while (i < t.length) {
|
|
1147
|
+
const qk = (0, field_parser_1.stripColon)(t[i++]);
|
|
1148
|
+
if (!qk) {
|
|
1149
|
+
break;
|
|
1150
|
+
}
|
|
1151
|
+
const entry = {
|
|
1152
|
+
quantityKind: qk,
|
|
1153
|
+
value: '',
|
|
1154
|
+
unit: '',
|
|
1155
|
+
tolerance: '',
|
|
1156
|
+
};
|
|
1157
|
+
if (i < t.length && t[i].startsWith('{')) {
|
|
1158
|
+
const eblock = (0, tokenize_2.unwrapBlock)(t[i++]);
|
|
1159
|
+
const et = (0, tokenize_1.default)(eblock);
|
|
1160
|
+
let j = 0;
|
|
1161
|
+
while (j < et.length) {
|
|
1162
|
+
const cmd = et[j++];
|
|
1163
|
+
if (j >= et.length) {
|
|
1164
|
+
break;
|
|
1165
|
+
}
|
|
1166
|
+
if (cmd === 'value') {
|
|
1167
|
+
entry.value = (0, tokenize_2.stripWrapping)(et[j++]);
|
|
1168
|
+
}
|
|
1169
|
+
else if (cmd === 'unit') {
|
|
1170
|
+
entry.unit = (0, tokenize_2.stripWrapping)(et[j++]);
|
|
1171
|
+
}
|
|
1172
|
+
else if (cmd === 'tolerance') {
|
|
1173
|
+
entry.tolerance = (0, tokenize_2.stripWrapping)(et[j++]);
|
|
1174
|
+
}
|
|
1175
|
+
else if (cmd === 'note') {
|
|
1176
|
+
entry.note = (0, tokenize_2.stripWrapping)(et[j++]);
|
|
1177
|
+
}
|
|
1178
|
+
else {
|
|
1179
|
+
(0, tokenize_2.unwrapBlock)(et[j++]);
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
out.push(entry);
|
|
1184
|
+
}
|
|
1185
|
+
return out;
|
|
1186
|
+
}
|
|
1187
|
+
const dumpConditionSet = function (cs) {
|
|
1188
|
+
let out = 'condition_set ' + cs.id + ' {\n';
|
|
1189
|
+
if (cs.role) {
|
|
1190
|
+
out += ' role ' + cs.role + '\n';
|
|
1191
|
+
}
|
|
1192
|
+
if (cs.subject) {
|
|
1193
|
+
out += ' subject ' + cs.subject + '\n';
|
|
1194
|
+
}
|
|
1195
|
+
if (cs.description) {
|
|
1196
|
+
out += ' description "' + (0, tokenize_2.escapeString)(cs.description) + '"\n';
|
|
1197
|
+
}
|
|
1198
|
+
if (cs.entries.length > 0) {
|
|
1199
|
+
out += ' entries {\n';
|
|
1200
|
+
for (const e of cs.entries) {
|
|
1201
|
+
// Entry values may be free text ("nominal, per installation
|
|
1202
|
+
// conditions") — quote whenever not a single safe token.
|
|
1203
|
+
let line = ' ' + e.quantityKind + ' { value ' + (0, field_parser_1.dumpBareSafe)(e.value);
|
|
1204
|
+
if (e.unit) {
|
|
1205
|
+
line += ' unit "' + (0, tokenize_2.escapeString)(e.unit) + '"';
|
|
1206
|
+
}
|
|
1207
|
+
if (e.tolerance) {
|
|
1208
|
+
line += ' tolerance ' + (0, field_parser_1.dumpBareSafe)(e.tolerance);
|
|
1209
|
+
}
|
|
1210
|
+
if (e.note) {
|
|
1211
|
+
line += ' note "' + (0, tokenize_2.escapeString)(e.note) + '"';
|
|
1212
|
+
}
|
|
1213
|
+
out += line + ' }\n';
|
|
1214
|
+
}
|
|
1215
|
+
out += ' }\n';
|
|
1216
|
+
}
|
|
1217
|
+
const sources = cs.sources && cs.sources.length > 0
|
|
1218
|
+
? cs.sources
|
|
1219
|
+
: cs.source
|
|
1220
|
+
? [cs.source]
|
|
1221
|
+
: [];
|
|
1222
|
+
for (const s of sources) {
|
|
1223
|
+
out += dumpSource('source', s, ' ');
|
|
1224
|
+
}
|
|
1225
|
+
out += dumpIdList('reference', cs.referenceIds, ' ');
|
|
1226
|
+
out += '}\n';
|
|
1227
|
+
return out;
|
|
1228
|
+
};
|
|
1229
|
+
// ── subject (v3 anatomy: is / has / does) ────────────────────────────
|
|
1230
|
+
/** Read `key value` / `key: value` pairs into a string map. */
|
|
1231
|
+
function readStringMap(block) {
|
|
1232
|
+
const out = {};
|
|
1233
|
+
const t = (0, tokenize_1.default)(block);
|
|
1234
|
+
let i = 0;
|
|
1235
|
+
while (i < t.length) {
|
|
1236
|
+
const key = (0, field_parser_1.stripColon)(t[i++]);
|
|
1237
|
+
if (!key) {
|
|
1238
|
+
break;
|
|
1239
|
+
}
|
|
1240
|
+
if (t[i] === ':') {
|
|
1241
|
+
i++;
|
|
1242
|
+
}
|
|
1243
|
+
if (i < t.length) {
|
|
1244
|
+
out[key] = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
return out;
|
|
1248
|
+
}
|
|
1249
|
+
/**
|
|
1250
|
+
* Read `<id> : <qualifier tokens…>` entries (design_parameters / attributes).
|
|
1251
|
+
* The qualifier runs to the next `<id> :` head or the end of the block;
|
|
1252
|
+
* the stored value is the tokens joined with single spaces. The dump
|
|
1253
|
+
* re-emits the joined form, so the fixpoint holds.
|
|
1254
|
+
*/
|
|
1255
|
+
function readValueMap(block) {
|
|
1256
|
+
const out = {};
|
|
1257
|
+
const t = (0, tokenize_1.default)(block);
|
|
1258
|
+
let i = 0;
|
|
1259
|
+
while (i < t.length) {
|
|
1260
|
+
const key = (0, field_parser_1.stripColon)(t[i++]);
|
|
1261
|
+
if (!key) {
|
|
1262
|
+
break;
|
|
1263
|
+
}
|
|
1264
|
+
if (t[i] === ':') {
|
|
1265
|
+
i++;
|
|
1266
|
+
}
|
|
1267
|
+
const parts = [];
|
|
1268
|
+
while (i < t.length && t[i + 1] !== ':') {
|
|
1269
|
+
parts.push((0, tokenize_2.stripWrapping)(t[i++]));
|
|
1270
|
+
}
|
|
1271
|
+
out[key] = parts.join(' ');
|
|
1272
|
+
}
|
|
1273
|
+
return out;
|
|
1274
|
+
}
|
|
1275
|
+
/** Read whitespace-separated entries (quoted phrases or bare ids). */
|
|
1276
|
+
function readStringEntries(block) {
|
|
1277
|
+
return (0, tokenize_1.default)(block)
|
|
1278
|
+
.map(tokenize_2.stripWrapping)
|
|
1279
|
+
.filter(s => s.length > 0);
|
|
1280
|
+
}
|
|
1281
|
+
/** Read `<id> in { A, B }` dimension-membership entries. */
|
|
1282
|
+
function readDimensionMap(block) {
|
|
1283
|
+
const out = {};
|
|
1284
|
+
const t = (0, tokenize_1.default)(block);
|
|
1285
|
+
let i = 0;
|
|
1286
|
+
while (i < t.length) {
|
|
1287
|
+
const key = (0, field_parser_1.stripColon)(t[i++]);
|
|
1288
|
+
if (!key) {
|
|
1289
|
+
break;
|
|
1290
|
+
}
|
|
1291
|
+
if (t[i] === ':') {
|
|
1292
|
+
i++;
|
|
1293
|
+
}
|
|
1294
|
+
if (t[i] === 'in') {
|
|
1295
|
+
i++;
|
|
1296
|
+
}
|
|
1297
|
+
if (i < t.length) {
|
|
1298
|
+
const raw = t[i++];
|
|
1299
|
+
const inner = raw.startsWith('{') ? (0, tokenize_2.unwrapBlock)(raw) : (0, tokenize_2.stripWrapping)(raw);
|
|
1300
|
+
out[key] = inner
|
|
1301
|
+
.split(/[,\s]+/)
|
|
1302
|
+
.map(s => s.trim())
|
|
1303
|
+
.filter(s => s.length > 0);
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
return out;
|
|
1307
|
+
}
|
|
1308
|
+
/**
|
|
1309
|
+
* Read `name [symbol] = derivation` characteristic entries. The
|
|
1310
|
+
* derivation is an ocl{…} expression (reassembled across whitespace by
|
|
1311
|
+
* readValueToken) or a quoted phrase; an absent derivation parses as ''
|
|
1312
|
+
* and is flagged by the linter (C7).
|
|
1313
|
+
*
|
|
1314
|
+
* The `=` separator may arrive FUSED to the name or symbol token
|
|
1315
|
+
* (`creep c_c= ocl{…}`, `drift= ocl{…}`) — the tokenizer splits on
|
|
1316
|
+
* whitespace only, so a trailing `=` on either token is treated as the
|
|
1317
|
+
* separator and the derivation is read from the next token.
|
|
1318
|
+
*
|
|
1319
|
+
* Block form (TODO.roadmap/10): an entry whose name is followed by a
|
|
1320
|
+
* `{ … }` block carries the full register entry — symbol, derivation,
|
|
1321
|
+
* behavior (the behavior it quantifies), quantity_kind, unit, source:
|
|
1322
|
+
* mdlo_normalized {
|
|
1323
|
+
* symbol "C_M"
|
|
1324
|
+
* derivation ocl{abs(c_m * t_f / delta_t * (d_max - d_min) / (n * v_min))}
|
|
1325
|
+
* behavior temp-effect-min-dead-load
|
|
1326
|
+
* quantity_kind dimensionless
|
|
1327
|
+
* source { doc "urn:oiml:pub:r:60-3:2021" clause "2.1.4" }
|
|
1328
|
+
* }
|
|
1329
|
+
*/
|
|
1330
|
+
function readCharacteristics(block) {
|
|
1331
|
+
const out = {};
|
|
1332
|
+
const t = (0, tokenize_1.default)(block);
|
|
1333
|
+
let i = 0;
|
|
1334
|
+
while (i < t.length) {
|
|
1335
|
+
let name = (0, field_parser_1.stripColon)(t[i++]);
|
|
1336
|
+
if (!name) {
|
|
1337
|
+
break;
|
|
1338
|
+
}
|
|
1339
|
+
if (i < t.length && t[i].startsWith('{')) {
|
|
1340
|
+
out[name] = readCharacteristicBlock((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
1341
|
+
continue;
|
|
1342
|
+
}
|
|
1343
|
+
let symbol = '';
|
|
1344
|
+
let derivation = '';
|
|
1345
|
+
let fused = false;
|
|
1346
|
+
if (name.length > 1 && name.endsWith('=')) {
|
|
1347
|
+
name = name.slice(0, -1);
|
|
1348
|
+
fused = true;
|
|
1349
|
+
}
|
|
1350
|
+
if (!fused && i < t.length && t[i] !== '=') {
|
|
1351
|
+
// t[i] !== '=' here, so a trailing '=' on the symbol token is fused.
|
|
1352
|
+
fused = t[i].endsWith('=');
|
|
1353
|
+
symbol = fused ? t[i].slice(0, -1) : t[i];
|
|
1354
|
+
i++;
|
|
1355
|
+
}
|
|
1356
|
+
if (fused || t[i] === '=') {
|
|
1357
|
+
if (!fused) {
|
|
1358
|
+
i++;
|
|
1359
|
+
}
|
|
1360
|
+
const read = (0, field_parser_1.readValueToken)(t, i);
|
|
1361
|
+
derivation = (0, tokenize_2.stripWrapping)(read.text);
|
|
1362
|
+
i = read.next;
|
|
1363
|
+
}
|
|
1364
|
+
out[name] = { symbol, derivation };
|
|
1365
|
+
}
|
|
1366
|
+
return out;
|
|
1367
|
+
}
|
|
1368
|
+
/** Read one block-form characteristic entry (TODO.roadmap/10). */
|
|
1369
|
+
function readCharacteristicBlock(block) {
|
|
1370
|
+
const c = { symbol: '', derivation: '' };
|
|
1371
|
+
const t = (0, tokenize_1.default)(block);
|
|
1372
|
+
let i = 0;
|
|
1373
|
+
while (i < t.length) {
|
|
1374
|
+
const cmd = t[i++];
|
|
1375
|
+
if (i >= t.length) {
|
|
1376
|
+
break;
|
|
1377
|
+
}
|
|
1378
|
+
if (cmd === 'symbol') {
|
|
1379
|
+
c.symbol = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
1380
|
+
}
|
|
1381
|
+
else if (cmd === 'derivation' || cmd === 'derive') {
|
|
1382
|
+
// ocl{…} expressions reassemble across whitespace (readValueToken).
|
|
1383
|
+
const read = (0, field_parser_1.readValueToken)(t, i);
|
|
1384
|
+
c.derivation = (0, tokenize_2.stripWrapping)(read.text);
|
|
1385
|
+
i = read.next;
|
|
1386
|
+
}
|
|
1387
|
+
else if (cmd === 'behavior') {
|
|
1388
|
+
c.behavior = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
1389
|
+
}
|
|
1390
|
+
else if (cmd === 'quantity_kind') {
|
|
1391
|
+
c.quantityKind = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
1392
|
+
}
|
|
1393
|
+
else if (cmd === 'unit') {
|
|
1394
|
+
c.unit = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
1395
|
+
}
|
|
1396
|
+
else if (cmd === 'source' || cmd === 'reference') {
|
|
1397
|
+
c.source = (0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
1398
|
+
}
|
|
1399
|
+
else {
|
|
1400
|
+
(0, tokenize_2.unwrapBlock)(t[i++]);
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
return c;
|
|
1404
|
+
}
|
|
1405
|
+
/**
|
|
1406
|
+
* Aspects whose payload is a scalar (not a `{ … }` block). When such an
|
|
1407
|
+
* aspect is misplaced, its value token must be skipped together with the
|
|
1408
|
+
* keyword — otherwise the value is re-read as another (phantom) aspect.
|
|
1409
|
+
*/
|
|
1410
|
+
const SCALAR_ASPECTS = new Set(['state', 'behavior']);
|
|
1411
|
+
/**
|
|
1412
|
+
* Misplaced-payload skipping for the twin aspects (TODO.roadmap/32):
|
|
1413
|
+
* endpoint <id> { … } — skip the id AND the block;
|
|
1414
|
+
* serve <aspect> via <op> [{ … }] — skip aspect/via/op + block.
|
|
1415
|
+
* Without the skip, a misplaced endpoint/serve cascades into phantom
|
|
1416
|
+
* aspects (the id, `via`, the operation name would each re-read as an
|
|
1417
|
+
* aspect keyword).
|
|
1418
|
+
*/
|
|
1419
|
+
function skipMisplacedPayload(aspect, t, i) {
|
|
1420
|
+
if (aspect === 'endpoint') {
|
|
1421
|
+
if (i < t.length && !t[i].startsWith('{')) {
|
|
1422
|
+
i++; // the endpoint id
|
|
1423
|
+
}
|
|
1424
|
+
if (i < t.length && t[i].startsWith('{')) {
|
|
1425
|
+
i++; // the endpoint body
|
|
1426
|
+
}
|
|
1427
|
+
return i;
|
|
1428
|
+
}
|
|
1429
|
+
if (aspect === 'serve') {
|
|
1430
|
+
if (i < t.length) {
|
|
1431
|
+
i++; // the aspect path
|
|
1432
|
+
}
|
|
1433
|
+
if (t[i] === 'via') {
|
|
1434
|
+
i += 2; // `via` + the operation name
|
|
1435
|
+
}
|
|
1436
|
+
if (i < t.length && t[i].startsWith('{')) {
|
|
1437
|
+
i++; // the freshness block
|
|
1438
|
+
}
|
|
1439
|
+
return i;
|
|
1440
|
+
}
|
|
1441
|
+
return i;
|
|
1442
|
+
}
|
|
1443
|
+
/**
|
|
1444
|
+
* Record an aspect key found under the wrong family (or undeclared) for
|
|
1445
|
+
* the linter (C6), and skip its payload: one block token, or one scalar
|
|
1446
|
+
* value token for the known-scalar aspects.
|
|
1447
|
+
*/
|
|
1448
|
+
function recordMisplaced(result, family, cmd, t, i) {
|
|
1449
|
+
const aspect = (0, field_parser_1.stripColon)(cmd);
|
|
1450
|
+
result.misplacedAspects.push({ family, aspect });
|
|
1451
|
+
if (i < t.length && t[i].startsWith('{')) {
|
|
1452
|
+
i++;
|
|
1453
|
+
}
|
|
1454
|
+
else if (SCALAR_ASPECTS.has(aspect)) {
|
|
1455
|
+
i++;
|
|
1456
|
+
}
|
|
1457
|
+
else {
|
|
1458
|
+
i = skipMisplacedPayload(aspect, t, i);
|
|
1459
|
+
}
|
|
1460
|
+
return i;
|
|
1461
|
+
}
|
|
1462
|
+
/**
|
|
1463
|
+
* Read one promise `level` value (TODO.roadmap/08). Three shapes:
|
|
1464
|
+
* level symbolic C6 → { kind: 'symbolic', symbolic }
|
|
1465
|
+
* level range { min -10 max 40 unit degC } → { kind: 'range', … }
|
|
1466
|
+
* level { value 0.7 unit v } → { kind: 'quantity', quantity }
|
|
1467
|
+
* Returns the level and the next unconsumed token index.
|
|
1468
|
+
*/
|
|
1469
|
+
function readPromiseLevel(t, i) {
|
|
1470
|
+
const tok = t[i] ?? '';
|
|
1471
|
+
if (tok === 'symbolic') {
|
|
1472
|
+
return {
|
|
1473
|
+
level: { kind: 'symbolic', symbolic: (0, tokenize_2.stripWrapping)(t[i + 1] ?? '') },
|
|
1474
|
+
next: i + 2,
|
|
1475
|
+
};
|
|
1476
|
+
}
|
|
1477
|
+
if (tok === 'range') {
|
|
1478
|
+
const level = { kind: 'range' };
|
|
1479
|
+
const inner = (0, tokenize_1.default)((0, tokenize_2.unwrapBlock)(t[i + 1] ?? ''));
|
|
1480
|
+
let j = 0;
|
|
1481
|
+
while (j < inner.length) {
|
|
1482
|
+
const cmd = inner[j++];
|
|
1483
|
+
if (j > inner.length) {
|
|
1484
|
+
break;
|
|
1485
|
+
}
|
|
1486
|
+
if (cmd === 'min') {
|
|
1487
|
+
level.min = (0, quantity_1.coerceValueToken)(inner[j++]);
|
|
1488
|
+
}
|
|
1489
|
+
else if (cmd === 'max') {
|
|
1490
|
+
level.max = (0, quantity_1.coerceValueToken)(inner[j++]);
|
|
1491
|
+
}
|
|
1492
|
+
else if (cmd === 'unit') {
|
|
1493
|
+
level.unit = (0, tokenize_2.stripWrapping)(inner[j++]);
|
|
1494
|
+
}
|
|
1495
|
+
else {
|
|
1496
|
+
(0, tokenize_2.unwrapBlock)(inner[j++]);
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
return { level, next: i + 2 };
|
|
1500
|
+
}
|
|
1501
|
+
// QuantityValue block form (the full INV-1 contract).
|
|
1502
|
+
return {
|
|
1503
|
+
level: { kind: 'quantity', quantity: (0, quantity_1.readQuantityBlock)((0, tokenize_2.unwrapBlock)(tok)) },
|
|
1504
|
+
next: i + 1,
|
|
1505
|
+
};
|
|
1506
|
+
}
|
|
1507
|
+
/**
|
|
1508
|
+
* Read is.promises entries (TODO.roadmap/08). Two entry forms:
|
|
1509
|
+
* - rich: `<id> { target … level … conditions … statement …
|
|
1510
|
+
* verified_by { … } source { … } }`
|
|
1511
|
+
* - shorthand: a quoted phrase or a bare token NOT followed by a block —
|
|
1512
|
+
* the legacy string-list form, parsed as a statement-only promise
|
|
1513
|
+
* (empty id/target/conditions; the linter's C43 flags it as
|
|
1514
|
+
* unverifiable at authoring).
|
|
1515
|
+
*/
|
|
1516
|
+
function readPromises(block) {
|
|
1517
|
+
const out = [];
|
|
1518
|
+
const t = (0, tokenize_1.default)(block);
|
|
1519
|
+
let i = 0;
|
|
1520
|
+
while (i < t.length) {
|
|
1521
|
+
const tok = t[i++];
|
|
1522
|
+
if (!tok) {
|
|
1523
|
+
break;
|
|
1524
|
+
}
|
|
1525
|
+
if (tok.startsWith('"') || i >= t.length || !t[i].startsWith('{')) {
|
|
1526
|
+
out.push({
|
|
1527
|
+
id: '',
|
|
1528
|
+
target: '',
|
|
1529
|
+
level: null,
|
|
1530
|
+
conditions: '',
|
|
1531
|
+
statement: (0, tokenize_2.stripWrapping)(tok),
|
|
1532
|
+
verifiedBy: [],
|
|
1533
|
+
source: null,
|
|
1534
|
+
});
|
|
1535
|
+
continue;
|
|
1536
|
+
}
|
|
1537
|
+
const p = {
|
|
1538
|
+
id: (0, field_parser_1.stripColon)(tok),
|
|
1539
|
+
target: '',
|
|
1540
|
+
level: null,
|
|
1541
|
+
conditions: '',
|
|
1542
|
+
statement: '',
|
|
1543
|
+
verifiedBy: [],
|
|
1544
|
+
source: null,
|
|
1545
|
+
};
|
|
1546
|
+
const inner = (0, tokenize_1.default)((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
1547
|
+
let j = 0;
|
|
1548
|
+
while (j < inner.length) {
|
|
1549
|
+
const cmd = inner[j++];
|
|
1550
|
+
if (j >= inner.length) {
|
|
1551
|
+
break;
|
|
1552
|
+
}
|
|
1553
|
+
if (cmd === 'target') {
|
|
1554
|
+
p.target = (0, tokenize_2.stripWrapping)(inner[j++]);
|
|
1555
|
+
}
|
|
1556
|
+
else if (cmd === 'level') {
|
|
1557
|
+
const read = readPromiseLevel(inner, j);
|
|
1558
|
+
p.level = read.level;
|
|
1559
|
+
j = read.next;
|
|
1560
|
+
}
|
|
1561
|
+
else if (cmd === 'conditions') {
|
|
1562
|
+
// ocl{…} expressions reassemble across whitespace (readValueToken).
|
|
1563
|
+
const read = (0, field_parser_1.readValueToken)(inner, j);
|
|
1564
|
+
p.conditions = (0, tokenize_2.stripWrapping)(read.text);
|
|
1565
|
+
j = read.next;
|
|
1566
|
+
}
|
|
1567
|
+
else if (cmd === 'statement') {
|
|
1568
|
+
p.statement = (0, tokenize_2.stripWrapping)(inner[j++]);
|
|
1569
|
+
}
|
|
1570
|
+
else if (cmd === 'verified_by') {
|
|
1571
|
+
p.verifiedBy = readIdList(inner[j++]);
|
|
1572
|
+
}
|
|
1573
|
+
else if (cmd === 'source') {
|
|
1574
|
+
p.source = (0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(inner[j++]));
|
|
1575
|
+
}
|
|
1576
|
+
else {
|
|
1577
|
+
(0, tokenize_2.unwrapBlock)(inner[j++]);
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
out.push(p);
|
|
1581
|
+
}
|
|
1582
|
+
return out;
|
|
1583
|
+
}
|
|
1584
|
+
/** A promise carrying nothing but its prose statement (the shorthand form). */
|
|
1585
|
+
function isStatementOnlyPromise(p) {
|
|
1586
|
+
return (p.id === '' &&
|
|
1587
|
+
!p.target &&
|
|
1588
|
+
!p.level &&
|
|
1589
|
+
!p.conditions &&
|
|
1590
|
+
p.verifiedBy.length === 0 &&
|
|
1591
|
+
!p.source);
|
|
1592
|
+
}
|
|
1593
|
+
function parseSubjectIs(block, result) {
|
|
1594
|
+
const t = (0, tokenize_1.default)(block);
|
|
1595
|
+
let i = 0;
|
|
1596
|
+
while (i < t.length) {
|
|
1597
|
+
const cmd = t[i++];
|
|
1598
|
+
if (i >= t.length) {
|
|
1599
|
+
break;
|
|
1600
|
+
}
|
|
1601
|
+
if (cmd === 'metadata') {
|
|
1602
|
+
result.is.metadata = readStringMap((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
1603
|
+
}
|
|
1604
|
+
else if (cmd === 'provenance') {
|
|
1605
|
+
result.is.provenance = readStringMap((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
1606
|
+
}
|
|
1607
|
+
else if (cmd === 'structure') {
|
|
1608
|
+
result.is.structure = readStringEntries((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
1609
|
+
}
|
|
1610
|
+
else if (cmd === 'design_parameters') {
|
|
1611
|
+
result.is.designParameters = readValueMap((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
1612
|
+
}
|
|
1613
|
+
else if (cmd === 'designed_conditions') {
|
|
1614
|
+
result.is.designedConditions = readStringMap((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
1615
|
+
}
|
|
1616
|
+
else if (cmd === 'promises') {
|
|
1617
|
+
result.is.promises = readPromises((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
1618
|
+
}
|
|
1619
|
+
else if (cmd === 'artifacts') {
|
|
1620
|
+
result.is.artifacts = readStringEntries((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
1621
|
+
}
|
|
1622
|
+
else if (cmd === 'endpoint') {
|
|
1623
|
+
// endpoint <id> { … } (TODO.roadmap/32) — the declared API surface.
|
|
1624
|
+
const endpointId = (0, field_parser_1.stripColon)(t[i++] ?? '');
|
|
1625
|
+
const body = i < t.length ? (0, tokenize_2.unwrapBlock)(t[i++]) : '';
|
|
1626
|
+
if (endpointId) {
|
|
1627
|
+
result.is.endpoints.push((0, twin_1.parseEndpoint)(endpointId, body));
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
else if (cmd === 'composed_of') {
|
|
1631
|
+
// composed_of { … } (TODO.integration/14) — the composition facet
|
|
1632
|
+
// of a composite subject.
|
|
1633
|
+
result.is.composedOf = (0, composition_1.parseComposedOf)((0, tokenize_2.unwrapBlock)(t[i++] ?? ''));
|
|
1634
|
+
}
|
|
1635
|
+
else {
|
|
1636
|
+
i = recordMisplaced(result, 'is', cmd, t, i);
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
function parseSubjectHas(block, result) {
|
|
1641
|
+
const t = (0, tokenize_1.default)(block);
|
|
1642
|
+
let i = 0;
|
|
1643
|
+
while (i < t.length) {
|
|
1644
|
+
const cmd = t[i++];
|
|
1645
|
+
if (i >= t.length) {
|
|
1646
|
+
break;
|
|
1647
|
+
}
|
|
1648
|
+
if (cmd === 'attributes') {
|
|
1649
|
+
result.has.attributes = readValueMap((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
1650
|
+
}
|
|
1651
|
+
else if (cmd === 'dimensions') {
|
|
1652
|
+
result.has.dimensions = readDimensionMap((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
1653
|
+
}
|
|
1654
|
+
else if (cmd === 'state') {
|
|
1655
|
+
result.has.state = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
1656
|
+
}
|
|
1657
|
+
else if (cmd === 'characteristics') {
|
|
1658
|
+
result.has.characteristics = readCharacteristics((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
1659
|
+
}
|
|
1660
|
+
else if (cmd === 'environmental_context') {
|
|
1661
|
+
result.has.environmentalContext = readStringEntries((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
1662
|
+
}
|
|
1663
|
+
else if (cmd === 'artifact_instances') {
|
|
1664
|
+
result.has.artifactInstances = readStringEntries((0, tokenize_2.unwrapBlock)(t[i++]));
|
|
1665
|
+
}
|
|
1666
|
+
else if (cmd === 'serve') {
|
|
1667
|
+
// serve <aspect> via <operation> [{ fresh_within <duration> }]
|
|
1668
|
+
// (TODO.roadmap/32) — the HAS-level binding with freshness semantics.
|
|
1669
|
+
const read = (0, twin_1.parseServeEntry)(t, i);
|
|
1670
|
+
result.has.serves.push(read.binding);
|
|
1671
|
+
i = read.next;
|
|
1672
|
+
}
|
|
1673
|
+
else {
|
|
1674
|
+
i = recordMisplaced(result, 'has', cmd, t, i);
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
function parseSubjectDoes(block, result) {
|
|
1679
|
+
const t = (0, tokenize_1.default)(block);
|
|
1680
|
+
let i = 0;
|
|
1681
|
+
while (i < t.length) {
|
|
1682
|
+
const cmd = t[i++];
|
|
1683
|
+
if (i >= t.length) {
|
|
1684
|
+
break;
|
|
1685
|
+
}
|
|
1686
|
+
if (cmd === 'behavior') {
|
|
1687
|
+
result.does.behaviors.push((0, tokenize_2.stripWrapping)(t[i++]));
|
|
1688
|
+
}
|
|
1689
|
+
else {
|
|
1690
|
+
i = recordMisplaced(result, 'does', cmd, t, i);
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
const parseSubject = function (id, data) {
|
|
1695
|
+
const result = {
|
|
1696
|
+
id,
|
|
1697
|
+
extends: '',
|
|
1698
|
+
is: {
|
|
1699
|
+
metadata: {},
|
|
1700
|
+
provenance: {},
|
|
1701
|
+
structure: [],
|
|
1702
|
+
designParameters: {},
|
|
1703
|
+
designedConditions: {},
|
|
1704
|
+
promises: [],
|
|
1705
|
+
artifacts: [],
|
|
1706
|
+
endpoints: [],
|
|
1707
|
+
},
|
|
1708
|
+
has: {
|
|
1709
|
+
attributes: {},
|
|
1710
|
+
dimensions: {},
|
|
1711
|
+
state: '',
|
|
1712
|
+
characteristics: {},
|
|
1713
|
+
environmentalContext: [],
|
|
1714
|
+
artifactInstances: [],
|
|
1715
|
+
serves: [],
|
|
1716
|
+
},
|
|
1717
|
+
does: { behaviors: [] },
|
|
1718
|
+
referenceIds: [],
|
|
1719
|
+
misplacedAspects: [],
|
|
1720
|
+
};
|
|
1721
|
+
const t = (0, tokenize_2.tokenizePackage)(data);
|
|
1722
|
+
let i = 0;
|
|
1723
|
+
while (i < t.length) {
|
|
1724
|
+
const cmd = t[i++];
|
|
1725
|
+
if (i >= t.length) {
|
|
1726
|
+
break;
|
|
1727
|
+
}
|
|
1728
|
+
if (cmd === 'extends') {
|
|
1729
|
+
result.extends = (0, tokenize_2.stripWrapping)(t[i++]);
|
|
1730
|
+
}
|
|
1731
|
+
else if (cmd === 'is') {
|
|
1732
|
+
parseSubjectIs((0, tokenize_2.unwrapBlock)(t[i++]), result);
|
|
1733
|
+
}
|
|
1734
|
+
else if (cmd === 'has') {
|
|
1735
|
+
parseSubjectHas((0, tokenize_2.unwrapBlock)(t[i++]), result);
|
|
1736
|
+
}
|
|
1737
|
+
else if (cmd === 'does') {
|
|
1738
|
+
parseSubjectDoes((0, tokenize_2.unwrapBlock)(t[i++]), result);
|
|
1739
|
+
}
|
|
1740
|
+
else if (cmd === 'reference') {
|
|
1741
|
+
result.referenceIds = readReference(t[i++]);
|
|
1742
|
+
}
|
|
1743
|
+
else {
|
|
1744
|
+
(0, tokenize_2.unwrapBlock)(t[i++]);
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
return ctx => {
|
|
1748
|
+
ctx.subjects[id] = result;
|
|
1749
|
+
return ctx;
|
|
1750
|
+
};
|
|
1751
|
+
};
|
|
1752
|
+
// ── subject extends resolution ───────────────────────────────────────
|
|
1753
|
+
/**
|
|
1754
|
+
* Merge PARENT into CHILD per aspect-kind rules (TODO.roadmap/01): maps
|
|
1755
|
+
* merge by key (child wins on conflict), lists append (parent entries
|
|
1756
|
+
* first, then child's), scalars override (child's non-empty value wins).
|
|
1757
|
+
* referenceIds and misplacedAspects are NOT merged: references stay the
|
|
1758
|
+
* declaring subject's own, and misplaced aspects are parse-time lint
|
|
1759
|
+
* capture the linter already sees on the parent itself.
|
|
1760
|
+
*/
|
|
1761
|
+
function mergeSubject(parent, child) {
|
|
1762
|
+
return {
|
|
1763
|
+
id: child.id,
|
|
1764
|
+
// The extends link is consumed by the merge — the resolved subject is
|
|
1765
|
+
// self-contained, so a dump→load cycle can never re-merge (list
|
|
1766
|
+
// aspects would duplicate). Unmerged links keep `extends` (below).
|
|
1767
|
+
extends: '',
|
|
1768
|
+
is: {
|
|
1769
|
+
metadata: { ...parent.is.metadata, ...child.is.metadata },
|
|
1770
|
+
provenance: { ...parent.is.provenance, ...child.is.provenance },
|
|
1771
|
+
structure: [...parent.is.structure, ...child.is.structure],
|
|
1772
|
+
designParameters: {
|
|
1773
|
+
...parent.is.designParameters,
|
|
1774
|
+
...child.is.designParameters,
|
|
1775
|
+
},
|
|
1776
|
+
designedConditions: {
|
|
1777
|
+
...parent.is.designedConditions,
|
|
1778
|
+
...child.is.designedConditions,
|
|
1779
|
+
},
|
|
1780
|
+
promises: [...parent.is.promises, ...child.is.promises],
|
|
1781
|
+
artifacts: [...parent.is.artifacts, ...child.is.artifacts],
|
|
1782
|
+
endpoints: [...parent.is.endpoints, ...child.is.endpoints],
|
|
1783
|
+
// The composition facet: the child's declaration wins when present
|
|
1784
|
+
// (a composite refines its composition; the parent's carries
|
|
1785
|
+
// through unchanged otherwise).
|
|
1786
|
+
...(child.is.composedOf
|
|
1787
|
+
? { composedOf: child.is.composedOf }
|
|
1788
|
+
: parent.is.composedOf
|
|
1789
|
+
? { composedOf: parent.is.composedOf }
|
|
1790
|
+
: {}),
|
|
1791
|
+
},
|
|
1792
|
+
has: {
|
|
1793
|
+
attributes: { ...parent.has.attributes, ...child.has.attributes },
|
|
1794
|
+
dimensions: { ...parent.has.dimensions, ...child.has.dimensions },
|
|
1795
|
+
state: child.has.state || parent.has.state,
|
|
1796
|
+
characteristics: {
|
|
1797
|
+
...parent.has.characteristics,
|
|
1798
|
+
...child.has.characteristics,
|
|
1799
|
+
},
|
|
1800
|
+
environmentalContext: [
|
|
1801
|
+
...parent.has.environmentalContext,
|
|
1802
|
+
...child.has.environmentalContext,
|
|
1803
|
+
],
|
|
1804
|
+
artifactInstances: [
|
|
1805
|
+
...parent.has.artifactInstances,
|
|
1806
|
+
...child.has.artifactInstances,
|
|
1807
|
+
],
|
|
1808
|
+
serves: [...parent.has.serves, ...child.has.serves],
|
|
1809
|
+
},
|
|
1810
|
+
does: { behaviors: [...parent.does.behaviors, ...child.does.behaviors] },
|
|
1811
|
+
referenceIds: child.referenceIds,
|
|
1812
|
+
misplacedAspects: child.misplacedAspects,
|
|
1813
|
+
};
|
|
1814
|
+
}
|
|
1815
|
+
/**
|
|
1816
|
+
* Resolve a subject's `extends` chain: merge each subject with its
|
|
1817
|
+
* parent from ctx.subjects, recursively when the parent itself extends.
|
|
1818
|
+
* Pure — parents are read from the raw parse table and never mutated
|
|
1819
|
+
* (several subjects may extend the same parent). Lenient links:
|
|
1820
|
+
* - missing parent → the subject is returned unmerged (the lint rule
|
|
1821
|
+
* subject-extends-resolves reports it);
|
|
1822
|
+
* - cycle → the visited set breaks the cyclic LINK (treated like a
|
|
1823
|
+
* missing parent); acyclic prefixes still merge, so resolution
|
|
1824
|
+
* always terminates.
|
|
1825
|
+
*/
|
|
1826
|
+
function resolveSubject(ctx, item) {
|
|
1827
|
+
const chain = (s, visited) => {
|
|
1828
|
+
const parentId = s.extends;
|
|
1829
|
+
if (!parentId || visited.has(parentId)) {
|
|
1830
|
+
return s;
|
|
1831
|
+
}
|
|
1832
|
+
const parent = ctx.subjects[parentId];
|
|
1833
|
+
if (!parent) {
|
|
1834
|
+
return s;
|
|
1835
|
+
}
|
|
1836
|
+
visited.add(parentId);
|
|
1837
|
+
return mergeSubject(chain(parent, visited), s);
|
|
1838
|
+
};
|
|
1839
|
+
return chain(item, new Set([item.id]));
|
|
1840
|
+
}
|
|
1841
|
+
// ── subject dumpers ──────────────────────────────────────────────────
|
|
1842
|
+
function dumpSubjectStringMap(keyword, map) {
|
|
1843
|
+
const keys = Object.keys(map);
|
|
1844
|
+
if (keys.length === 0) {
|
|
1845
|
+
return '';
|
|
1846
|
+
}
|
|
1847
|
+
return (' ' +
|
|
1848
|
+
keyword +
|
|
1849
|
+
' { ' +
|
|
1850
|
+
keys.map(k => k + ' ' + (0, field_parser_1.dumpBareSafe)(map[k])).join(' ') +
|
|
1851
|
+
' }\n');
|
|
1852
|
+
}
|
|
1853
|
+
function dumpSubjectValueMap(keyword, map) {
|
|
1854
|
+
const keys = Object.keys(map);
|
|
1855
|
+
if (keys.length === 0) {
|
|
1856
|
+
return '';
|
|
1857
|
+
}
|
|
1858
|
+
return (' ' +
|
|
1859
|
+
keyword +
|
|
1860
|
+
' { ' +
|
|
1861
|
+
// Values are free-form qualifiers — route through dumpBareSafe so
|
|
1862
|
+
// quotes/braces/whitespace can't break re-parse (same as
|
|
1863
|
+
// dumpSubjectStringMap).
|
|
1864
|
+
keys
|
|
1865
|
+
.map(k => k + ' :' + (map[k] ? ' ' + (0, field_parser_1.dumpBareSafe)(map[k]) : ''))
|
|
1866
|
+
.join(' ') +
|
|
1867
|
+
' }\n');
|
|
1868
|
+
}
|
|
1869
|
+
function dumpSubjectEntries(keyword, entries) {
|
|
1870
|
+
if (entries.length === 0) {
|
|
1871
|
+
return '';
|
|
1872
|
+
}
|
|
1873
|
+
return (' ' + keyword + ' { ' + entries.map(field_parser_1.dumpBareSafe).join(' ') + ' }\n');
|
|
1874
|
+
}
|
|
1875
|
+
function dumpSubjectDimensions(map) {
|
|
1876
|
+
const keys = Object.keys(map);
|
|
1877
|
+
if (keys.length === 0) {
|
|
1878
|
+
return '';
|
|
1879
|
+
}
|
|
1880
|
+
return (' dimensions { ' +
|
|
1881
|
+
keys.map(k => k + ' in { ' + map[k].join(', ') + ' }').join(' ') +
|
|
1882
|
+
' }\n');
|
|
1883
|
+
}
|
|
1884
|
+
/** Derivations emit bare when ocl{…}/single-token, quoted otherwise. */
|
|
1885
|
+
function dumpSubjectDerivation(d) {
|
|
1886
|
+
return /^ocl\{[\s\S]*\}$/.test(d) ? d : (0, field_parser_1.dumpBareSafe)(d);
|
|
1887
|
+
}
|
|
1888
|
+
/** Dump one promise level (TODO.roadmap/08) — the inverse of readPromiseLevel. */
|
|
1889
|
+
function dumpPromiseLevel(level) {
|
|
1890
|
+
if (level.kind === 'symbolic') {
|
|
1891
|
+
return 'symbolic ' + (0, field_parser_1.dumpBareSafe)(level.symbolic ?? '');
|
|
1892
|
+
}
|
|
1893
|
+
if (level.kind === 'range') {
|
|
1894
|
+
let inner = '';
|
|
1895
|
+
if (level.min !== undefined) {
|
|
1896
|
+
inner += 'min ' + (0, quantity_1.dumpScalarToken)(level.min) + ' ';
|
|
1897
|
+
}
|
|
1898
|
+
if (level.max !== undefined) {
|
|
1899
|
+
inner += 'max ' + (0, quantity_1.dumpScalarToken)(level.max) + ' ';
|
|
1900
|
+
}
|
|
1901
|
+
if (level.unit) {
|
|
1902
|
+
inner += 'unit "' + (0, tokenize_2.escapeString)(level.unit) + '"';
|
|
1903
|
+
}
|
|
1904
|
+
return 'range { ' + inner.trimEnd() + ' }';
|
|
1905
|
+
}
|
|
1906
|
+
return (0, quantity_1.dumpQuantityBlock)(level.quantity ?? { value: '' });
|
|
1907
|
+
}
|
|
1908
|
+
/**
|
|
1909
|
+
* Dump is.promises (TODO.roadmap/08). Byte-compat with the legacy string
|
|
1910
|
+
* list: a block of statement-only entries keeps the single-line form
|
|
1911
|
+
* (`promises { "a" "b" }`); any rich entry switches the block to the
|
|
1912
|
+
* multi-line form, one entry per `<id> { … }` block (statement-only
|
|
1913
|
+
* entries stay quoted strings on their own lines).
|
|
1914
|
+
*/
|
|
1915
|
+
function dumpSubjectPromises(promises) {
|
|
1916
|
+
if (promises.length === 0) {
|
|
1917
|
+
return '';
|
|
1918
|
+
}
|
|
1919
|
+
if (promises.every(isStatementOnlyPromise)) {
|
|
1920
|
+
return (' promises { ' +
|
|
1921
|
+
promises.map(p => (0, field_parser_1.dumpBareSafe)(p.statement)).join(' ') +
|
|
1922
|
+
' }\n');
|
|
1923
|
+
}
|
|
1924
|
+
let out = ' promises {\n';
|
|
1925
|
+
for (const p of promises) {
|
|
1926
|
+
if (isStatementOnlyPromise(p)) {
|
|
1927
|
+
out += ' ' + (0, field_parser_1.dumpBareSafe)(p.statement) + '\n';
|
|
1928
|
+
continue;
|
|
1929
|
+
}
|
|
1930
|
+
out += ' ' + (0, field_parser_1.dumpBareSafe)(p.id) + ' {\n';
|
|
1931
|
+
if (p.target) {
|
|
1932
|
+
out += ' target ' + (0, field_parser_1.dumpBareSafe)(p.target) + '\n';
|
|
1933
|
+
}
|
|
1934
|
+
if (p.level) {
|
|
1935
|
+
out += ' level ' + dumpPromiseLevel(p.level) + '\n';
|
|
1936
|
+
}
|
|
1937
|
+
if (p.conditions) {
|
|
1938
|
+
out += ' conditions ' + dumpSubjectDerivation(p.conditions) + '\n';
|
|
1939
|
+
}
|
|
1940
|
+
if (p.statement) {
|
|
1941
|
+
out += ' statement "' + (0, tokenize_2.escapeString)(p.statement) + '"\n';
|
|
1942
|
+
}
|
|
1943
|
+
out += dumpIdList('verified_by', p.verifiedBy, ' ');
|
|
1944
|
+
out += dumpSource('source', p.source ?? null, ' ');
|
|
1945
|
+
out += ' }\n';
|
|
1946
|
+
}
|
|
1947
|
+
out += ' }\n';
|
|
1948
|
+
return out;
|
|
1949
|
+
}
|
|
1950
|
+
function dumpSubjectCharacteristics(map) {
|
|
1951
|
+
const keys = Object.keys(map);
|
|
1952
|
+
if (keys.length === 0) {
|
|
1953
|
+
return '';
|
|
1954
|
+
}
|
|
1955
|
+
let out = ' characteristics {\n';
|
|
1956
|
+
for (const k of keys) {
|
|
1957
|
+
const c = map[k];
|
|
1958
|
+
const rich = c.behavior ||
|
|
1959
|
+
c.quantityKind ||
|
|
1960
|
+
c.unit ||
|
|
1961
|
+
(c.source && (c.source.doc || c.source.clause));
|
|
1962
|
+
if (rich) {
|
|
1963
|
+
// Block form (TODO.roadmap/10) — the full register entry.
|
|
1964
|
+
out += ' ' + k + ' {\n';
|
|
1965
|
+
if (c.symbol) {
|
|
1966
|
+
out += ' symbol "' + (0, tokenize_2.escapeString)(c.symbol) + '"\n';
|
|
1967
|
+
}
|
|
1968
|
+
if (c.derivation) {
|
|
1969
|
+
out +=
|
|
1970
|
+
' derivation ' + dumpSubjectDerivation(c.derivation) + '\n';
|
|
1971
|
+
}
|
|
1972
|
+
if (c.behavior) {
|
|
1973
|
+
out += ' behavior ' + (0, field_parser_1.dumpBareSafe)(c.behavior) + '\n';
|
|
1974
|
+
}
|
|
1975
|
+
if (c.quantityKind) {
|
|
1976
|
+
out += ' quantity_kind ' + (0, field_parser_1.dumpBareSafe)(c.quantityKind) + '\n';
|
|
1977
|
+
}
|
|
1978
|
+
if (c.unit) {
|
|
1979
|
+
out += ' unit "' + (0, tokenize_2.escapeString)(c.unit) + '"\n';
|
|
1980
|
+
}
|
|
1981
|
+
out += dumpSource('source', c.source ?? null, ' ');
|
|
1982
|
+
out += ' }\n';
|
|
1983
|
+
continue;
|
|
1984
|
+
}
|
|
1985
|
+
out += ' ' + k + (c.symbol ? ' ' + c.symbol : '');
|
|
1986
|
+
if (c.derivation) {
|
|
1987
|
+
out += ' = ' + dumpSubjectDerivation(c.derivation);
|
|
1988
|
+
}
|
|
1989
|
+
out += '\n';
|
|
1990
|
+
}
|
|
1991
|
+
out += ' }\n';
|
|
1992
|
+
return out;
|
|
1993
|
+
}
|
|
1994
|
+
/** Dump is.endpoints (TODO.roadmap/32) — one `endpoint <id> { … }` block per
|
|
1995
|
+
* declared endpoint, after the other IS aspects. */
|
|
1996
|
+
function dumpSubjectEndpoints(endpoints) {
|
|
1997
|
+
let out = '';
|
|
1998
|
+
for (const e of endpoints) {
|
|
1999
|
+
out += (0, twin_1.dumpEndpoint)(e, ' ');
|
|
2000
|
+
}
|
|
2001
|
+
return out;
|
|
2002
|
+
}
|
|
2003
|
+
/** Dump has.serves (TODO.roadmap/32) — one `serve … via …` line per binding. */
|
|
2004
|
+
function dumpSubjectServes(serves) {
|
|
2005
|
+
let out = '';
|
|
2006
|
+
for (const b of serves) {
|
|
2007
|
+
out += (0, twin_1.dumpServe)(b, ' ');
|
|
2008
|
+
}
|
|
2009
|
+
return out;
|
|
2010
|
+
}
|
|
2011
|
+
const dumpSubject = function (s) {
|
|
2012
|
+
let out = 'subject ' + s.id + ' {\n';
|
|
2013
|
+
if (s.extends) {
|
|
2014
|
+
out += ' extends ' + s.extends + '\n';
|
|
2015
|
+
}
|
|
2016
|
+
const isBody = dumpSubjectStringMap('metadata', s.is.metadata) +
|
|
2017
|
+
dumpSubjectStringMap('provenance', s.is.provenance) +
|
|
2018
|
+
dumpSubjectEntries('structure', s.is.structure) +
|
|
2019
|
+
dumpSubjectValueMap('design_parameters', s.is.designParameters) +
|
|
2020
|
+
dumpSubjectStringMap('designed_conditions', s.is.designedConditions) +
|
|
2021
|
+
dumpSubjectPromises(s.is.promises) +
|
|
2022
|
+
dumpSubjectEntries('artifacts', s.is.artifacts) +
|
|
2023
|
+
dumpSubjectEndpoints(s.is.endpoints) +
|
|
2024
|
+
(s.is.composedOf ? (0, composition_1.dumpComposedOf)(s.is.composedOf, ' ') : '');
|
|
2025
|
+
if (isBody) {
|
|
2026
|
+
out += ' is {\n' + isBody + ' }\n';
|
|
2027
|
+
}
|
|
2028
|
+
const hasBody = dumpSubjectValueMap('attributes', s.has.attributes) +
|
|
2029
|
+
dumpSubjectDimensions(s.has.dimensions) +
|
|
2030
|
+
(s.has.state ? ' state ' + (0, field_parser_1.dumpBareSafe)(s.has.state) + '\n' : '') +
|
|
2031
|
+
dumpSubjectCharacteristics(s.has.characteristics) +
|
|
2032
|
+
dumpSubjectEntries('environmental_context', s.has.environmentalContext) +
|
|
2033
|
+
dumpSubjectEntries('artifact_instances', s.has.artifactInstances) +
|
|
2034
|
+
dumpSubjectServes(s.has.serves);
|
|
2035
|
+
if (hasBody) {
|
|
2036
|
+
out += ' has {\n' + hasBody + ' }\n';
|
|
2037
|
+
}
|
|
2038
|
+
let doesBody = '';
|
|
2039
|
+
for (const b of s.does.behaviors) {
|
|
2040
|
+
doesBody += ' behavior ' + (0, field_parser_1.dumpBareSafe)(b) + '\n';
|
|
2041
|
+
}
|
|
2042
|
+
if (doesBody) {
|
|
2043
|
+
out += ' does {\n' + doesBody + ' }\n';
|
|
2044
|
+
}
|
|
2045
|
+
out += dumpIdList('reference', s.referenceIds, ' ');
|
|
2046
|
+
out += '}\n';
|
|
2047
|
+
return out;
|
|
2048
|
+
};
|
|
2049
|
+
// ── construct registry entries ───────────────────────────────────────
|
|
2050
|
+
exports.instrumentConstruct = {
|
|
2051
|
+
keyword: 'instrument',
|
|
2052
|
+
field: 'instruments',
|
|
2053
|
+
takesID: true,
|
|
2054
|
+
parse: parseInstrument,
|
|
2055
|
+
dump: dumpInstrument,
|
|
2056
|
+
};
|
|
2057
|
+
exports.attributeDefinitionConstruct = {
|
|
2058
|
+
keyword: 'attribute_definition',
|
|
2059
|
+
field: 'attributeDefinitions',
|
|
2060
|
+
takesID: true,
|
|
2061
|
+
parse: parseAttributeDefinition,
|
|
2062
|
+
dump: dumpAttributeDefinition,
|
|
2063
|
+
};
|
|
2064
|
+
exports.capabilityConstruct = {
|
|
2065
|
+
keyword: 'capability',
|
|
2066
|
+
field: 'capabilities',
|
|
2067
|
+
takesID: true,
|
|
2068
|
+
parse: parseCapability,
|
|
2069
|
+
dump: dumpCapability,
|
|
2070
|
+
};
|
|
2071
|
+
exports.behaviorConstruct = {
|
|
2072
|
+
keyword: 'behavior',
|
|
2073
|
+
field: 'behaviors',
|
|
2074
|
+
takesID: true,
|
|
2075
|
+
parse: parseBehavior,
|
|
2076
|
+
dump: dumpBehavior,
|
|
2077
|
+
};
|
|
2078
|
+
exports.conditionSetConstruct = {
|
|
2079
|
+
keyword: 'condition_set',
|
|
2080
|
+
field: 'conditionSets',
|
|
2081
|
+
takesID: true,
|
|
2082
|
+
parse: parseConditionSet,
|
|
2083
|
+
dump: dumpConditionSet,
|
|
2084
|
+
};
|
|
2085
|
+
exports.subjectConstruct = {
|
|
2086
|
+
keyword: 'subject',
|
|
2087
|
+
field: 'subjects',
|
|
2088
|
+
takesID: true,
|
|
2089
|
+
parse: parseSubject,
|
|
2090
|
+
resolve: resolveSubject,
|
|
2091
|
+
dump: dumpSubject,
|
|
2092
|
+
};
|
|
2093
|
+
//# sourceMappingURL=subject.js.map
|