@driftsys/markspec 0.10.2 → 0.11.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/README.md +2 -2
- package/esm/compiler/deserialize.d.ts +49 -0
- package/esm/compiler/deserialize.d.ts.map +1 -0
- package/esm/compiler/deserialize.js +139 -0
- package/esm/compiler/manifest.d.ts +3 -0
- package/esm/compiler/manifest.d.ts.map +1 -1
- package/esm/compiler/manifest.js +9 -3
- package/esm/compiler/mod.d.ts.map +1 -1
- package/esm/compiler/mod.js +16 -7
- package/esm/config/markspec.d.ts +38 -1
- package/esm/config/markspec.d.ts.map +1 -1
- package/esm/config/markspec.js +127 -2
- package/esm/config/mod.d.ts.map +1 -1
- package/esm/config/mod.js +143 -147
- package/esm/decl/duplicates.d.ts +29 -0
- package/esm/decl/duplicates.d.ts.map +1 -0
- package/esm/decl/duplicates.js +28 -0
- package/esm/decl/mod.d.ts +20 -0
- package/esm/decl/mod.d.ts.map +1 -0
- package/esm/decl/mod.js +15 -0
- package/esm/decl/resolve.d.ts +104 -0
- package/esm/decl/resolve.d.ts.map +1 -0
- package/esm/decl/resolve.js +66 -0
- package/esm/decl/surfaces.d.ts +118 -0
- package/esm/decl/surfaces.d.ts.map +1 -0
- package/esm/decl/surfaces.js +135 -0
- package/esm/decl/table.d.ts +50 -0
- package/esm/decl/table.d.ts.map +1 -0
- package/esm/decl/table.js +124 -0
- package/esm/gates/mod.d.ts +13 -2
- package/esm/gates/mod.d.ts.map +1 -1
- package/esm/gates/mod.js +38 -11
- package/esm/lint/runner.d.ts.map +1 -1
- package/esm/lint/runner.js +3 -1
- package/esm/lock/acquire_compile.d.ts +31 -0
- package/esm/lock/acquire_compile.d.ts.map +1 -0
- package/esm/lock/acquire_compile.js +83 -0
- package/esm/lock/cache_check.d.ts +28 -0
- package/esm/lock/cache_check.d.ts.map +1 -0
- package/esm/lock/cache_check.js +51 -0
- package/esm/lock/check.d.ts +14 -3
- package/esm/lock/check.d.ts.map +1 -1
- package/esm/lock/check.js +41 -3
- package/esm/lock/git_intent.d.ts +46 -0
- package/esm/lock/git_intent.d.ts.map +1 -0
- package/esm/lock/git_intent.js +111 -0
- package/esm/lock/mod.d.ts +10 -3
- package/esm/lock/mod.d.ts.map +1 -1
- package/esm/lock/mod.js +7 -1
- package/esm/lock/model.d.ts +24 -1
- package/esm/lock/model.d.ts.map +1 -1
- package/esm/lock/parser.d.ts.map +1 -1
- package/esm/lock/parser.js +32 -0
- package/esm/lock/pin_assurance.d.ts +20 -0
- package/esm/lock/pin_assurance.d.ts.map +1 -0
- package/esm/lock/pin_assurance.js +34 -0
- package/esm/lock/resolve.d.ts +8 -17
- package/esm/lock/resolve.d.ts.map +1 -1
- package/esm/lock/resolve.js +7 -67
- package/esm/lock/serializer.d.ts.map +1 -1
- package/esm/lock/serializer.js +23 -0
- package/esm/lock/upstream_common.d.ts +29 -0
- package/esm/lock/upstream_common.d.ts.map +1 -0
- package/esm/lock/upstream_common.js +38 -0
- package/esm/lock/upstream_deps.d.ts +63 -0
- package/esm/lock/upstream_deps.d.ts.map +1 -0
- package/esm/lock/upstream_deps.js +172 -0
- package/esm/lock/upstream_refs.d.ts +69 -0
- package/esm/lock/upstream_refs.d.ts.map +1 -0
- package/esm/lock/upstream_refs.js +238 -0
- package/esm/mod.d.ts +16 -8
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +15 -5
- package/esm/model/mod.d.ts +93 -28
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/mod.js +66 -13
- package/esm/model/profile.d.ts +13 -0
- package/esm/model/profile.d.ts.map +1 -1
- package/esm/parser/directives.d.ts +6 -0
- package/esm/parser/directives.d.ts.map +1 -1
- package/esm/parser/directives.js +17 -0
- package/esm/parser/markdown.d.ts.map +1 -1
- package/esm/parser/markdown.js +16 -51
- package/esm/profile/manifest.d.ts.map +1 -1
- package/esm/profile/manifest.js +20 -3
- package/esm/profile/merge.js +7 -0
- package/esm/reporter/mod.d.ts +11 -0
- package/esm/reporter/mod.d.ts.map +1 -1
- package/esm/reporter/mod.js +19 -8
- package/esm/typl/assemble.d.ts +53 -0
- package/esm/typl/assemble.d.ts.map +1 -0
- package/esm/typl/assemble.js +238 -0
- package/esm/typl/ast.d.ts +7 -1
- package/esm/typl/ast.d.ts.map +1 -1
- package/esm/typl/ast.js +3 -0
- package/esm/typl/bullet.d.ts +16 -24
- package/esm/typl/bullet.d.ts.map +1 -1
- package/esm/typl/bullet.js +9 -41
- package/esm/typl/citations.d.ts +27 -0
- package/esm/typl/citations.d.ts.map +1 -0
- package/esm/typl/citations.js +16 -0
- package/esm/typl/diagnostics.d.ts +2 -2
- package/esm/typl/diagnostics.d.ts.map +1 -1
- package/esm/typl/diagnostics.js +18 -0
- package/esm/typl/fence.d.ts +12 -21
- package/esm/typl/fence.d.ts.map +1 -1
- package/esm/typl/fence.js +5 -20
- package/esm/typl/grammar.d.ts.map +1 -1
- package/esm/typl/grammar.js +6 -0
- package/esm/typl/inline.d.ts +15 -24
- package/esm/typl/inline.d.ts.map +1 -1
- package/esm/typl/inline.js +6 -44
- package/esm/typl/lexer.d.ts.map +1 -1
- package/esm/typl/lexer.js +25 -4
- package/esm/typl/mod.d.ts +8 -2
- package/esm/typl/mod.d.ts.map +1 -1
- package/esm/typl/mod.js +5 -1
- package/esm/typl/recognize.d.ts +14 -0
- package/esm/typl/recognize.d.ts.map +1 -0
- package/esm/typl/recognize.js +19 -0
- package/esm/typl/registry.d.ts +1 -1
- package/esm/typl/resolve.d.ts +31 -0
- package/esm/typl/resolve.d.ts.map +1 -0
- package/esm/typl/resolve.js +27 -0
- package/esm/typl/table.d.ts +52 -0
- package/esm/typl/table.d.ts.map +1 -0
- package/esm/typl/table.js +69 -0
- package/esm/typl/validator.d.ts +24 -5
- package/esm/typl/validator.d.ts.map +1 -1
- package/esm/typl/validator.js +55 -75
- package/esm/upstream/mod.d.ts +45 -0
- package/esm/upstream/mod.d.ts.map +1 -0
- package/esm/upstream/mod.js +98 -0
- package/esm/upstream/project.d.ts +33 -0
- package/esm/upstream/project.d.ts.map +1 -0
- package/esm/upstream/project.js +38 -0
- package/esm/upstream/refs.d.ts +23 -0
- package/esm/upstream/refs.d.ts.map +1 -0
- package/esm/upstream/refs.js +71 -0
- package/esm/util/paths.d.ts +14 -0
- package/esm/util/paths.d.ts.map +1 -0
- package/esm/util/paths.js +22 -0
- package/esm/uxil/assemble.d.ts +38 -0
- package/esm/uxil/assemble.d.ts.map +1 -0
- package/esm/uxil/assemble.js +268 -0
- package/esm/uxil/ast.d.ts +63 -0
- package/esm/uxil/ast.d.ts.map +1 -0
- package/esm/uxil/ast.js +9 -0
- package/esm/uxil/citations.d.ts +27 -0
- package/esm/uxil/citations.d.ts.map +1 -0
- package/esm/uxil/citations.js +25 -0
- package/esm/uxil/diagnostics.d.ts +39 -0
- package/esm/uxil/diagnostics.d.ts.map +1 -0
- package/esm/uxil/diagnostics.js +135 -0
- package/esm/uxil/grammar.d.ts +72 -0
- package/esm/uxil/grammar.d.ts.map +1 -0
- package/esm/uxil/grammar.js +505 -0
- package/esm/uxil/lexer.d.ts +23 -0
- package/esm/uxil/lexer.d.ts.map +1 -0
- package/esm/uxil/lexer.js +58 -0
- package/esm/uxil/mod.d.ts +32 -0
- package/esm/uxil/mod.d.ts.map +1 -0
- package/esm/uxil/mod.js +11 -0
- package/esm/uxil/projection.d.ts +40 -0
- package/esm/uxil/projection.d.ts.map +1 -0
- package/esm/uxil/projection.js +41 -0
- package/esm/uxil/recognize.d.ts +16 -0
- package/esm/uxil/recognize.d.ts.map +1 -0
- package/esm/uxil/recognize.js +28 -0
- package/esm/uxil/registry.d.ts +37 -0
- package/esm/uxil/registry.d.ts.map +1 -0
- package/esm/uxil/registry.js +29 -0
- package/esm/uxil/surfaces.d.ts +36 -0
- package/esm/uxil/surfaces.d.ts.map +1 -0
- package/esm/uxil/surfaces.js +34 -0
- package/esm/uxil/validator.d.ts +36 -0
- package/esm/uxil/validator.d.ts.map +1 -0
- package/esm/uxil/validator.js +139 -0
- package/esm/uxil/vocab.d.ts +33 -0
- package/esm/uxil/vocab.d.ts.map +1 -0
- package/esm/uxil/vocab.js +36 -0
- package/esm/validator/body_blocks.d.ts.map +1 -1
- package/esm/validator/body_blocks.js +3 -9
- package/esm/validator/caption_convention.d.ts +2 -1
- package/esm/validator/caption_convention.d.ts.map +1 -1
- package/esm/validator/caption_convention.js +2 -1
- package/esm/validator/corpus.d.ts.map +1 -1
- package/esm/validator/corpus.js +40 -17
- package/esm/validator/discipline.d.ts +6 -4
- package/esm/validator/discipline.d.ts.map +1 -1
- package/esm/validator/discipline.js +6 -4
- package/esm/validator/mod.d.ts.map +1 -1
- package/esm/validator/mod.js +28 -15
- package/esm/validator/pipeline.d.ts +11 -1
- package/esm/validator/pipeline.d.ts.map +1 -1
- package/esm/validator/pipeline.js +68 -18
- package/esm/validator/trace_types.d.ts +9 -2
- package/esm/validator/trace_types.d.ts.map +1 -1
- package/esm/validator/trace_types.js +21 -5
- package/esm/validator/traceability.d.ts +15 -3
- package/esm/validator/traceability.d.ts.map +1 -1
- package/esm/validator/traceability.js +39 -4
- package/esm/validator/types.d.ts.map +1 -1
- package/esm/validator/types.js +11 -1
- package/esm/validator/uxil_family.d.ts +43 -0
- package/esm/validator/uxil_family.d.ts.map +1 -0
- package/esm/validator/uxil_family.js +52 -0
- package/package.json +1 -1
- package/script/compiler/deserialize.d.ts +49 -0
- package/script/compiler/deserialize.d.ts.map +1 -0
- package/script/compiler/deserialize.js +144 -0
- package/script/compiler/manifest.d.ts +3 -0
- package/script/compiler/manifest.d.ts.map +1 -1
- package/script/compiler/manifest.js +10 -3
- package/script/compiler/mod.d.ts.map +1 -1
- package/script/compiler/mod.js +15 -6
- package/script/config/markspec.d.ts +38 -1
- package/script/config/markspec.d.ts.map +1 -1
- package/script/config/markspec.js +129 -3
- package/script/config/mod.d.ts.map +1 -1
- package/script/config/mod.js +143 -147
- package/script/decl/duplicates.d.ts +29 -0
- package/script/decl/duplicates.d.ts.map +1 -0
- package/script/decl/duplicates.js +31 -0
- package/script/decl/mod.d.ts +20 -0
- package/script/decl/mod.d.ts.map +1 -0
- package/script/decl/mod.js +26 -0
- package/script/decl/resolve.d.ts +104 -0
- package/script/decl/resolve.d.ts.map +1 -0
- package/script/decl/resolve.js +70 -0
- package/script/decl/surfaces.d.ts +118 -0
- package/script/decl/surfaces.d.ts.map +1 -0
- package/script/decl/surfaces.js +141 -0
- package/script/decl/table.d.ts +50 -0
- package/script/decl/table.d.ts.map +1 -0
- package/script/decl/table.js +127 -0
- package/script/gates/mod.d.ts +13 -2
- package/script/gates/mod.d.ts.map +1 -1
- package/script/gates/mod.js +37 -10
- package/script/lint/runner.d.ts.map +1 -1
- package/script/lint/runner.js +3 -1
- package/script/lock/acquire_compile.d.ts +31 -0
- package/script/lock/acquire_compile.d.ts.map +1 -0
- package/script/lock/acquire_compile.js +86 -0
- package/script/lock/cache_check.d.ts +28 -0
- package/script/lock/cache_check.d.ts.map +1 -0
- package/script/lock/cache_check.js +54 -0
- package/script/lock/check.d.ts +14 -3
- package/script/lock/check.d.ts.map +1 -1
- package/script/lock/check.js +41 -3
- package/script/lock/git_intent.d.ts +46 -0
- package/script/lock/git_intent.d.ts.map +1 -0
- package/script/lock/git_intent.js +115 -0
- package/script/lock/mod.d.ts +10 -3
- package/script/lock/mod.d.ts.map +1 -1
- package/script/lock/mod.js +16 -2
- package/script/lock/model.d.ts +24 -1
- package/script/lock/model.d.ts.map +1 -1
- package/script/lock/parser.d.ts.map +1 -1
- package/script/lock/parser.js +32 -0
- package/script/lock/pin_assurance.d.ts +20 -0
- package/script/lock/pin_assurance.d.ts.map +1 -0
- package/script/lock/pin_assurance.js +37 -0
- package/script/lock/resolve.d.ts +8 -17
- package/script/lock/resolve.d.ts.map +1 -1
- package/script/lock/resolve.js +7 -68
- package/script/lock/serializer.d.ts.map +1 -1
- package/script/lock/serializer.js +23 -0
- package/script/lock/upstream_common.d.ts +29 -0
- package/script/lock/upstream_common.d.ts.map +1 -0
- package/script/lock/upstream_common.js +42 -0
- package/script/lock/upstream_deps.d.ts +63 -0
- package/script/lock/upstream_deps.d.ts.map +1 -0
- package/script/lock/upstream_deps.js +175 -0
- package/script/lock/upstream_refs.d.ts +69 -0
- package/script/lock/upstream_refs.d.ts.map +1 -0
- package/script/lock/upstream_refs.js +244 -0
- package/script/mod.d.ts +16 -8
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +40 -7
- package/script/model/mod.d.ts +93 -28
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/mod.js +70 -14
- package/script/model/profile.d.ts +13 -0
- package/script/model/profile.d.ts.map +1 -1
- package/script/parser/directives.d.ts +6 -0
- package/script/parser/directives.d.ts.map +1 -1
- package/script/parser/directives.js +18 -0
- package/script/parser/markdown.d.ts.map +1 -1
- package/script/parser/markdown.js +15 -50
- package/script/profile/manifest.d.ts.map +1 -1
- package/script/profile/manifest.js +20 -3
- package/script/profile/merge.js +7 -0
- package/script/reporter/mod.d.ts +11 -0
- package/script/reporter/mod.d.ts.map +1 -1
- package/script/reporter/mod.js +18 -7
- package/script/typl/assemble.d.ts +53 -0
- package/script/typl/assemble.d.ts.map +1 -0
- package/script/typl/assemble.js +241 -0
- package/script/typl/ast.d.ts +7 -1
- package/script/typl/ast.d.ts.map +1 -1
- package/script/typl/ast.js +3 -0
- package/script/typl/bullet.d.ts +16 -24
- package/script/typl/bullet.d.ts.map +1 -1
- package/script/typl/bullet.js +10 -42
- package/script/typl/citations.d.ts +27 -0
- package/script/typl/citations.d.ts.map +1 -0
- package/script/typl/citations.js +20 -0
- package/script/typl/diagnostics.d.ts +2 -2
- package/script/typl/diagnostics.d.ts.map +1 -1
- package/script/typl/diagnostics.js +18 -0
- package/script/typl/fence.d.ts +12 -21
- package/script/typl/fence.d.ts.map +1 -1
- package/script/typl/fence.js +5 -20
- package/script/typl/grammar.d.ts.map +1 -1
- package/script/typl/grammar.js +6 -0
- package/script/typl/inline.d.ts +15 -24
- package/script/typl/inline.d.ts.map +1 -1
- package/script/typl/inline.js +6 -44
- package/script/typl/lexer.d.ts.map +1 -1
- package/script/typl/lexer.js +25 -4
- package/script/typl/mod.d.ts +8 -2
- package/script/typl/mod.d.ts.map +1 -1
- package/script/typl/mod.js +14 -2
- package/script/typl/recognize.d.ts +14 -0
- package/script/typl/recognize.d.ts.map +1 -0
- package/script/typl/recognize.js +22 -0
- package/script/typl/registry.d.ts +1 -1
- package/script/typl/resolve.d.ts +31 -0
- package/script/typl/resolve.d.ts.map +1 -0
- package/script/typl/resolve.js +33 -0
- package/script/typl/table.d.ts +52 -0
- package/script/typl/table.d.ts.map +1 -0
- package/script/typl/table.js +75 -0
- package/script/typl/validator.d.ts +24 -5
- package/script/typl/validator.d.ts.map +1 -1
- package/script/typl/validator.js +55 -75
- package/script/upstream/mod.d.ts +45 -0
- package/script/upstream/mod.d.ts.map +1 -0
- package/script/upstream/mod.js +101 -0
- package/script/upstream/project.d.ts +33 -0
- package/script/upstream/project.d.ts.map +1 -0
- package/script/upstream/project.js +41 -0
- package/script/upstream/refs.d.ts +23 -0
- package/script/upstream/refs.d.ts.map +1 -0
- package/script/upstream/refs.js +74 -0
- package/script/util/paths.d.ts +14 -0
- package/script/util/paths.d.ts.map +1 -0
- package/script/util/paths.js +25 -0
- package/script/uxil/assemble.d.ts +38 -0
- package/script/uxil/assemble.d.ts.map +1 -0
- package/script/uxil/assemble.js +272 -0
- package/script/uxil/ast.d.ts +63 -0
- package/script/uxil/ast.d.ts.map +1 -0
- package/script/uxil/ast.js +10 -0
- package/script/uxil/citations.d.ts +27 -0
- package/script/uxil/citations.d.ts.map +1 -0
- package/script/uxil/citations.js +29 -0
- package/script/uxil/diagnostics.d.ts +39 -0
- package/script/uxil/diagnostics.d.ts.map +1 -0
- package/script/uxil/diagnostics.js +140 -0
- package/script/uxil/grammar.d.ts +72 -0
- package/script/uxil/grammar.d.ts.map +1 -0
- package/script/uxil/grammar.js +511 -0
- package/script/uxil/lexer.d.ts +23 -0
- package/script/uxil/lexer.d.ts.map +1 -0
- package/script/uxil/lexer.js +61 -0
- package/script/uxil/mod.d.ts +32 -0
- package/script/uxil/mod.d.ts.map +1 -0
- package/script/uxil/mod.js +37 -0
- package/script/uxil/projection.d.ts +40 -0
- package/script/uxil/projection.d.ts.map +1 -0
- package/script/uxil/projection.js +44 -0
- package/script/uxil/recognize.d.ts +16 -0
- package/script/uxil/recognize.d.ts.map +1 -0
- package/script/uxil/recognize.js +31 -0
- package/script/uxil/registry.d.ts +37 -0
- package/script/uxil/registry.d.ts.map +1 -0
- package/script/uxil/registry.js +32 -0
- package/script/uxil/surfaces.d.ts +36 -0
- package/script/uxil/surfaces.d.ts.map +1 -0
- package/script/uxil/surfaces.js +39 -0
- package/script/uxil/validator.d.ts +36 -0
- package/script/uxil/validator.d.ts.map +1 -0
- package/script/uxil/validator.js +142 -0
- package/script/uxil/vocab.d.ts +33 -0
- package/script/uxil/vocab.d.ts.map +1 -0
- package/script/uxil/vocab.js +41 -0
- package/script/validator/body_blocks.d.ts.map +1 -1
- package/script/validator/body_blocks.js +3 -9
- package/script/validator/caption_convention.d.ts +2 -1
- package/script/validator/caption_convention.d.ts.map +1 -1
- package/script/validator/caption_convention.js +2 -1
- package/script/validator/corpus.d.ts.map +1 -1
- package/script/validator/corpus.js +39 -16
- package/script/validator/discipline.d.ts +6 -4
- package/script/validator/discipline.d.ts.map +1 -1
- package/script/validator/discipline.js +6 -4
- package/script/validator/mod.d.ts.map +1 -1
- package/script/validator/mod.js +27 -14
- package/script/validator/pipeline.d.ts +11 -1
- package/script/validator/pipeline.d.ts.map +1 -1
- package/script/validator/pipeline.js +67 -17
- package/script/validator/trace_types.d.ts +9 -2
- package/script/validator/trace_types.d.ts.map +1 -1
- package/script/validator/trace_types.js +20 -4
- package/script/validator/traceability.d.ts +15 -3
- package/script/validator/traceability.d.ts.map +1 -1
- package/script/validator/traceability.js +38 -3
- package/script/validator/types.d.ts.map +1 -1
- package/script/validator/types.js +10 -0
- package/script/validator/uxil_family.d.ts +43 -0
- package/script/validator/uxil_family.d.ts.map +1 -0
- package/script/validator/uxil_family.js +56 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { checkSingleRoot, resolveRef } from "../decl/mod.js";
|
|
2
|
+
import { bridgeTyplDiagnostic } from "./bridge.js";
|
|
3
|
+
import { typlDiagnostic } from "./diagnostics.js";
|
|
4
|
+
import { extractTyplFences } from "./fence.js";
|
|
5
|
+
import { extractTyplBulletsNested } from "./bullet.js";
|
|
6
|
+
import { extractTyplInlines } from "./inline.js";
|
|
7
|
+
import { extractTyplTable, typlTableCaptionBase } from "./table.js";
|
|
8
|
+
import { parseTyplBlock } from "./grammar.js";
|
|
9
|
+
import { TYPL_REF_OPS, typlPathOf } from "./resolve.js";
|
|
10
|
+
/**
|
|
11
|
+
* Assemble one entry's typl declarations into its `Entry.types` block.
|
|
12
|
+
*
|
|
13
|
+
* Extracts declarations from the four embedding surfaces (fenced code,
|
|
14
|
+
* bullet glossary, inline code spans, table rows), resolves every relative
|
|
15
|
+
* `$.x` name against the caption/root/nested-namespace bases in scope (see
|
|
16
|
+
* the module doc's resolution rules), and aggregates the result.
|
|
17
|
+
*
|
|
18
|
+
* @param bodyAst - The entry body's parsed block AST (fence + bullet + table
|
|
19
|
+
* surfaces walk this).
|
|
20
|
+
* @param bodyTokens - The entry body's flat token stream (the inline
|
|
21
|
+
* surface walks this).
|
|
22
|
+
* @param file - Source file path, for bridging diagnostics back to
|
|
23
|
+
* file-relative positions.
|
|
24
|
+
* @param bodyStartLine - 1-based line the entry body starts on, added to
|
|
25
|
+
* each surface's body-relative range to get a file-relative line.
|
|
26
|
+
* @returns `types` — the assembled `TyplBlock`, omitted when the entry
|
|
27
|
+
* declares nothing (no bindings, no typedefs, no root namespace) — plus
|
|
28
|
+
* any diagnostics raised during extraction or resolution (TYPL-010,
|
|
29
|
+
* TYPL-012, and bridged parse diagnostics).
|
|
30
|
+
*/
|
|
31
|
+
export function assembleTyplTypes(bodyAst, bodyTokens, file, bodyStartLine) {
|
|
32
|
+
const diagnostics = [];
|
|
33
|
+
const blocks = [];
|
|
34
|
+
// Map bullet-extraction index → blocks[] index, for parent lookups.
|
|
35
|
+
const bulletBlockIndex = [];
|
|
36
|
+
for (const fence of extractTyplFences(bodyAst)) {
|
|
37
|
+
const result = parseTyplBlock(fence.source);
|
|
38
|
+
const lineOffset = bodyStartLine + fence.range.start.line - 1;
|
|
39
|
+
for (const td of result.diagnostics) {
|
|
40
|
+
diagnostics.push(bridgeTyplDiagnostic(td, file, lineOffset));
|
|
41
|
+
}
|
|
42
|
+
blocks.push({ ...result.ast, file, lineOffset });
|
|
43
|
+
}
|
|
44
|
+
const bullets = extractTyplBulletsNested(bodyAst);
|
|
45
|
+
for (const bullet of bullets) {
|
|
46
|
+
const result = parseTyplBlock(bullet.source);
|
|
47
|
+
const lineOffset = bodyStartLine + bullet.range.start.line - 2;
|
|
48
|
+
for (const td of result.diagnostics) {
|
|
49
|
+
diagnostics.push(bridgeTyplDiagnostic(td, file, lineOffset));
|
|
50
|
+
}
|
|
51
|
+
bulletBlockIndex.push(blocks.length);
|
|
52
|
+
blocks.push({
|
|
53
|
+
...result.ast,
|
|
54
|
+
file,
|
|
55
|
+
lineOffset,
|
|
56
|
+
bulletParent: bullet.parent,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
for (const inline of extractTyplInlines(bodyTokens)) {
|
|
60
|
+
const result = parseTyplBlock(inline.source);
|
|
61
|
+
const lineOffset = inline.location.line - 1;
|
|
62
|
+
for (const td of result.diagnostics) {
|
|
63
|
+
diagnostics.push(bridgeTyplDiagnostic(td, inline.location.file, lineOffset));
|
|
64
|
+
}
|
|
65
|
+
blocks.push({ ...result.ast, file: inline.location.file, lineOffset });
|
|
66
|
+
}
|
|
67
|
+
// Table rows (#724): each recognized data row is one binding. Its range
|
|
68
|
+
// points AT the row's own line (like the bullet surface, not the fence
|
|
69
|
+
// whose range points at the opening ``` a line above its content), so the
|
|
70
|
+
// diagnostic offset subtracts 2, matching the bullet path. The `Table:`
|
|
71
|
+
// caption base — when the caption text is an absolute typl name — scopes
|
|
72
|
+
// the row's relative refs (see `scopeFor`); the caption base is not a
|
|
73
|
+
// namespace binding, so it takes no part in Pass A root detection or Pass B.
|
|
74
|
+
for (const row of extractTyplTable(bodyAst)) {
|
|
75
|
+
const result = parseTyplBlock(row.source);
|
|
76
|
+
const lineOffset = bodyStartLine + row.range.start.line - 2;
|
|
77
|
+
for (const td of result.diagnostics) {
|
|
78
|
+
diagnostics.push(bridgeTyplDiagnostic(td, file, lineOffset));
|
|
79
|
+
}
|
|
80
|
+
const captionBase = row.captionText !== undefined
|
|
81
|
+
? typlTableCaptionBase(row.captionText)
|
|
82
|
+
: undefined;
|
|
83
|
+
blocks.push({
|
|
84
|
+
...result.ast,
|
|
85
|
+
file,
|
|
86
|
+
lineOffset,
|
|
87
|
+
...(captionBase !== undefined ? { captionBase } : {}),
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
// Emit a bridged typl diagnostic for a binding in blocks[i].
|
|
91
|
+
const emit = (code, params, i, position) => {
|
|
92
|
+
const td = typlDiagnostic(code, params, position);
|
|
93
|
+
diagnostics.push(bridgeTyplDiagnostic(td, blocks[i].file, blocks[i].lineOffset));
|
|
94
|
+
};
|
|
95
|
+
// blockHasNamespace / hasNamespaceAncestor are static structure checks
|
|
96
|
+
// (independent of resolution), so Pass A is order-independent.
|
|
97
|
+
const blockHasNamespace = blocks.map((b) => b.bindings.some((x) => x.kind === "namespace"));
|
|
98
|
+
const hasNamespaceAncestor = (i) => {
|
|
99
|
+
let p = blocks[i].bulletParent;
|
|
100
|
+
while (p !== undefined) {
|
|
101
|
+
const idx = bulletBlockIndex[p];
|
|
102
|
+
if (blockHasNamespace[idx])
|
|
103
|
+
return true;
|
|
104
|
+
p = blocks[idx].bulletParent;
|
|
105
|
+
}
|
|
106
|
+
return false;
|
|
107
|
+
};
|
|
108
|
+
// ── Pass A: find the root ────────────────────────────────────────────
|
|
109
|
+
// Root candidate = an ABSOLUTE namespace binding with no namespace
|
|
110
|
+
// ancestor in its bullet chain (a relative namespace can never be a
|
|
111
|
+
// root — it needs a base itself). checkSingleRoot (core/decl) enforces
|
|
112
|
+
// the one-root invariant; its bare contract also flags zero candidates
|
|
113
|
+
// as a failure ("no-root"), but an entry with no namespace binding at
|
|
114
|
+
// all is a normal, error-free shape here — only "multiple-roots"
|
|
115
|
+
// produces diagnostics, first candidate in source order wins (order-
|
|
116
|
+
// independent for authors: the root scopes the whole body).
|
|
117
|
+
const rootCandidates = [];
|
|
118
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
119
|
+
for (const binding of blocks[i].bindings) {
|
|
120
|
+
if (binding.kind !== "namespace")
|
|
121
|
+
continue;
|
|
122
|
+
if (!TYPL_REF_OPS.isAbsolute(binding.name))
|
|
123
|
+
continue;
|
|
124
|
+
if (hasNamespaceAncestor(i))
|
|
125
|
+
continue;
|
|
126
|
+
rootCandidates.push({
|
|
127
|
+
path: typlPathOf(binding.name),
|
|
128
|
+
blockIndex: i,
|
|
129
|
+
position: binding.position,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const rootCheck = checkSingleRoot(rootCandidates);
|
|
134
|
+
let rootPath;
|
|
135
|
+
if (rootCheck.ok) {
|
|
136
|
+
rootPath = rootCheck.root.path;
|
|
137
|
+
}
|
|
138
|
+
else if (rootCheck.reason === "multiple-roots") {
|
|
139
|
+
rootPath = rootCheck.roots[0].path;
|
|
140
|
+
for (let k = 1; k < rootCheck.roots.length; k++) {
|
|
141
|
+
const extra = rootCheck.roots[k];
|
|
142
|
+
emit("TYPL-012", { first: `$${rootPath}` }, extra.blockIndex, extra.position);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// "no-root" → rootPath stays undefined; not an error.
|
|
146
|
+
// basePathOfBlock[i] = the base path blocks[i] provides to its bullet
|
|
147
|
+
// subtree, or undefined. One base slot per block: a block with several
|
|
148
|
+
// namespace bindings keeps the last (bullet blocks hold a single
|
|
149
|
+
// declaration in practice).
|
|
150
|
+
const basePathOfBlock = blocks.map(() => undefined);
|
|
151
|
+
/**
|
|
152
|
+
* Scope chain for blocks[i], innermost-first, terminated by the root base.
|
|
153
|
+
* Which frames a block sees depends on its surface: a bullet block walks
|
|
154
|
+
* its bullet-ancestor bases; a table-row block contributes its `Table:`
|
|
155
|
+
* caption base (#724); fence/inline blocks have neither and see the root
|
|
156
|
+
* only. The frame kinds don't combine in practice — a table row carries no
|
|
157
|
+
* `bulletParent`, so a table nested inside a bullet-namespace subtree sees
|
|
158
|
+
* only its caption base + the root, not the enclosing bullet base (known
|
|
159
|
+
* limitation, #724). Built immutably per call.
|
|
160
|
+
*/
|
|
161
|
+
const scopeFor = (i) => {
|
|
162
|
+
const chain = []; // innermost first
|
|
163
|
+
let p = blocks[i].bulletParent;
|
|
164
|
+
while (p !== undefined) {
|
|
165
|
+
const idx = bulletBlockIndex[p];
|
|
166
|
+
const base = basePathOfBlock[idx];
|
|
167
|
+
if (base !== undefined)
|
|
168
|
+
chain.push(base);
|
|
169
|
+
p = blocks[idx].bulletParent;
|
|
170
|
+
}
|
|
171
|
+
let scope = rootPath !== undefined
|
|
172
|
+
? { base: rootPath }
|
|
173
|
+
: undefined;
|
|
174
|
+
for (let k = chain.length - 1; k >= 0; k--) {
|
|
175
|
+
scope = { base: chain[k], parent: scope };
|
|
176
|
+
}
|
|
177
|
+
// A table row resolves against its caption base first (#722 rule 3):
|
|
178
|
+
// innermost, above the bullet chain and the root.
|
|
179
|
+
const captionBase = blocks[i].captionBase;
|
|
180
|
+
if (captionBase !== undefined)
|
|
181
|
+
scope = { base: captionBase, parent: scope };
|
|
182
|
+
return scope;
|
|
183
|
+
};
|
|
184
|
+
// ── Pass B: establish bases ──────────────────────────────────────────
|
|
185
|
+
// Source order is parents-before-children (bullet extraction is
|
|
186
|
+
// depth-first), so an ancestor's base is always resolved before its
|
|
187
|
+
// descendants need it. A relative namespace resolves against its own
|
|
188
|
+
// chain (TYPL-010 when there is none). Extra roots (TYPL-012 in Pass A)
|
|
189
|
+
// establish no base.
|
|
190
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
191
|
+
for (const binding of blocks[i].bindings) {
|
|
192
|
+
if (binding.kind !== "namespace")
|
|
193
|
+
continue;
|
|
194
|
+
if (TYPL_REF_OPS.isAbsolute(binding.name)) {
|
|
195
|
+
const path = typlPathOf(binding.name);
|
|
196
|
+
const isExtraRoot = !hasNamespaceAncestor(i) && path !== rootPath;
|
|
197
|
+
if (!isExtraRoot)
|
|
198
|
+
basePathOfBlock[i] = path;
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
const res = resolveRef(binding.name, scopeFor(i), TYPL_REF_OPS);
|
|
202
|
+
if (!res.ok) {
|
|
203
|
+
emit("TYPL-010", { name: binding.name }, i, binding.position);
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
basePathOfBlock[i] = typlPathOf(res.ref);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
// ── Pass C: resolve every non-namespace binding to an absolute name ──
|
|
210
|
+
const allBindings = [];
|
|
211
|
+
const allTypedefs = [];
|
|
212
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
213
|
+
const block = blocks[i];
|
|
214
|
+
for (const binding of block.bindings) {
|
|
215
|
+
if (binding.kind === "namespace")
|
|
216
|
+
continue; // scaffolding (D8)
|
|
217
|
+
const res = resolveRef(binding.name, scopeFor(i), TYPL_REF_OPS);
|
|
218
|
+
if (!res.ok) {
|
|
219
|
+
emit("TYPL-010", { name: binding.name }, i, binding.position);
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
allBindings.push(res.ref === binding.name ? binding : { ...binding, name: res.ref });
|
|
223
|
+
}
|
|
224
|
+
allTypedefs.push(...block.typedefs);
|
|
225
|
+
}
|
|
226
|
+
if (allBindings.length === 0 && allTypedefs.length === 0 &&
|
|
227
|
+
rootPath === undefined) {
|
|
228
|
+
return { diagnostics };
|
|
229
|
+
}
|
|
230
|
+
return {
|
|
231
|
+
types: {
|
|
232
|
+
bindings: allBindings,
|
|
233
|
+
typedefs: allTypedefs,
|
|
234
|
+
...(rootPath !== undefined ? { rootNamespace: rootPath } : {}),
|
|
235
|
+
},
|
|
236
|
+
diagnostics,
|
|
237
|
+
};
|
|
238
|
+
}
|
package/esm/typl/ast.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* Closed kind vocabulary. `value` is the default kind when an author omits
|
|
9
9
|
* it from a binding.
|
|
10
10
|
*/
|
|
11
|
-
export declare const KINDS: readonly ["value", "event", "signal", "command", "state", "const", "config", "document", "stream"];
|
|
11
|
+
export declare const KINDS: readonly ["value", "event", "signal", "command", "state", "const", "config", "document", "stream", "namespace"];
|
|
12
12
|
export type Kind = typeof KINDS[number];
|
|
13
13
|
/** Schema AST — one discriminated union covering all shape variants. */
|
|
14
14
|
export type Shape = {
|
|
@@ -83,5 +83,11 @@ export type Statement = Binding | Typedef;
|
|
|
83
83
|
export interface TyplBlock {
|
|
84
84
|
readonly bindings: readonly Binding[];
|
|
85
85
|
readonly typedefs: readonly Typedef[];
|
|
86
|
+
/**
|
|
87
|
+
* The entry's root namespace path (no `$`, e.g. `"powertrain.brake"`),
|
|
88
|
+
* when the entry declares one (#723). The validator resolves relative
|
|
89
|
+
* citations against it.
|
|
90
|
+
*/
|
|
91
|
+
readonly rootNamespace?: string;
|
|
86
92
|
}
|
|
87
93
|
//# sourceMappingURL=ast.d.ts.map
|
package/esm/typl/ast.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/typl/ast.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,eAAO,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/typl/ast.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,eAAO,MAAM,KAAK,iHAaR,CAAC;AACX,MAAM,MAAM,IAAI,GAAG,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC;AAExC,wEAAwE;AACxE,MAAM,MAAM,KAAK,GACb;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAA;CAAE,GAC1E;IACA,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,KAAK,GAAG,OAAO,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GACC;IACA,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GACC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAClD;IACA,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,KAAK,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GACC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,CAAA;CAAE,GAChE;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAA;CAAE,GAC3D;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;CAAE,GACrD;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC7B;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAEvC,uEAAuE;AACvE,MAAM,WAAW,QAAQ;IACvB,2CAA2C;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,sBAAsB;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,yCAAyC;AACzC,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,aAAa,EAAE,SAAS,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;CAC7B;AAED,sCAAsC;AACtC,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,aAAa,EAAE,SAAS,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;CAC7B;AAED,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;AAE1C,iCAAiC;AACjC,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;IACtC,QAAQ,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;IACtC;;;;OAIG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC"}
|
package/esm/typl/ast.js
CHANGED
package/esm/typl/bullet.d.ts
CHANGED
|
@@ -2,33 +2,25 @@
|
|
|
2
2
|
* @module typl/bullet
|
|
3
3
|
*
|
|
4
4
|
* Bullet-glossary surface adapter — recognises CommonMark bullet list
|
|
5
|
-
* items whose first paragraph
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* integration calls parseTyplBlock on each `source` independently.
|
|
12
|
-
* Per-item position-bridging uses the item's range and formula
|
|
13
|
-
* documented in bridgeTyplDiagnostic.
|
|
5
|
+
* items whose first paragraph is a typl declaration (`$X : …` binding or
|
|
6
|
+
* `type X = …` typedef). A thin wrapper over the shared
|
|
7
|
+
* declaration-surface machinery (core/decl): it supplies typl's text
|
|
8
|
+
* recognizer and re-exports the common declaration node as
|
|
9
|
+
* {@linkcode TyplNestedBulletExtraction}. Mixed lists are supported —
|
|
10
|
+
* matching items are extracted, non-matching bullets are left alone.
|
|
14
11
|
*
|
|
15
12
|
* See ADR-019.
|
|
16
13
|
*/
|
|
17
|
-
import type { BodyBlock
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
readonly source: string;
|
|
22
|
-
/** Source range of the bullet's first paragraph. */
|
|
23
|
-
readonly range: SourceRange;
|
|
24
|
-
}
|
|
14
|
+
import type { BodyBlock } from "../ast/nodes.js";
|
|
15
|
+
import { type NestedBlockDeclaration } from "../decl/mod.js";
|
|
16
|
+
/** A typl bullet declaration with its structural parent link (#723). */
|
|
17
|
+
export type TyplNestedBulletExtraction = NestedBlockDeclaration;
|
|
25
18
|
/**
|
|
26
|
-
* Walk a body AST and return every bullet-list item whose first
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* Returns matches in source order (depth-first).
|
|
19
|
+
* Walk a body AST and return every bullet-list item whose first paragraph
|
|
20
|
+
* is a typl declaration, in source order (depth-first, recursing into
|
|
21
|
+
* nested lists), each with a `parent` link for base-resolution scope
|
|
22
|
+
* chains. Delegates traversal to
|
|
23
|
+
* {@linkcode extractNestedBulletDeclarations}.
|
|
32
24
|
*/
|
|
33
|
-
export declare function
|
|
25
|
+
export declare function extractTyplBulletsNested(blocks: readonly BodyBlock[]): readonly TyplNestedBulletExtraction[];
|
|
34
26
|
//# sourceMappingURL=bullet.d.ts.map
|
package/esm/typl/bullet.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bullet.d.ts","sourceRoot":"","sources":["../../src/typl/bullet.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"bullet.d.ts","sourceRoot":"","sources":["../../src/typl/bullet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,gBAAgB,CAAC;AAGxB,wEAAwE;AACxE,MAAM,MAAM,0BAA0B,GAAG,sBAAsB,CAAC;AAEhE;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,SAAS,SAAS,EAAE,GAC3B,SAAS,0BAA0B,EAAE,CAEvC"}
|
package/esm/typl/bullet.js
CHANGED
|
@@ -1,44 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/** Matches a typl typedef bullet (paragraph text). */
|
|
4
|
-
const BULLET_TYPEDEF_RE = /^type\s+[A-Za-z_][A-Za-z0-9_]*\s*=/;
|
|
5
|
-
function isTyplBulletText(text) {
|
|
6
|
-
return BULLET_BINDING_RE.test(text) || BULLET_TYPEDEF_RE.test(text);
|
|
7
|
-
}
|
|
1
|
+
import { extractNestedBulletDeclarations, } from "../decl/mod.js";
|
|
2
|
+
import { isTyplDeclarationText } from "./recognize.js";
|
|
8
3
|
/**
|
|
9
|
-
* Walk a body AST and return every bullet-list item whose first
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* Returns matches in source order (depth-first).
|
|
4
|
+
* Walk a body AST and return every bullet-list item whose first paragraph
|
|
5
|
+
* is a typl declaration, in source order (depth-first, recursing into
|
|
6
|
+
* nested lists), each with a `parent` link for base-resolution scope
|
|
7
|
+
* chains. Delegates traversal to
|
|
8
|
+
* {@linkcode extractNestedBulletDeclarations}.
|
|
15
9
|
*/
|
|
16
|
-
export function
|
|
17
|
-
|
|
18
|
-
for (const block of blocks) {
|
|
19
|
-
if (block.kind === "list") {
|
|
20
|
-
for (const item of block.items) {
|
|
21
|
-
if (item.blocks.length === 0)
|
|
22
|
-
continue;
|
|
23
|
-
const first = item.blocks[0];
|
|
24
|
-
if (first.kind === "paragraph") {
|
|
25
|
-
const para = first;
|
|
26
|
-
if (isTyplBulletText(para.content.text)) {
|
|
27
|
-
results.push({
|
|
28
|
-
source: para.content.text,
|
|
29
|
-
range: para.range,
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
// Recurse into nested blocks (the item may itself contain a list)
|
|
34
|
-
if (item.blocks.length > 1) {
|
|
35
|
-
results.push(...extractTyplBullets(item.blocks.slice(1)));
|
|
36
|
-
}
|
|
37
|
-
else if (first.kind === "list") {
|
|
38
|
-
results.push(...extractTyplBullets([first]));
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return results;
|
|
10
|
+
export function extractTyplBulletsNested(blocks) {
|
|
11
|
+
return extractNestedBulletDeclarations(blocks, isTyplDeclarationText);
|
|
44
12
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module typl/citations
|
|
3
|
+
*
|
|
4
|
+
* Citation extraction for the published tier (#723): a *citation* is a
|
|
5
|
+
* bare published-shaped ref in an inline code span — absolute
|
|
6
|
+
* (`` `$powertrain.brake.pedal_position` ``) or relative
|
|
7
|
+
* (`` `$.pedal_position` ``) — with no declaration clause. Plain `$Name`
|
|
8
|
+
* spans are entry-local mentions and deliberately not validated
|
|
9
|
+
* (unchanged pre-#723 behavior). The validator resolves relative
|
|
10
|
+
* citations against the entry's root namespace and checks resolved names
|
|
11
|
+
* against the corpus registry (TYPL-010 / TYPL-011).
|
|
12
|
+
*/
|
|
13
|
+
import type { BodyToken, SourceLocation } from "../model/mod.js";
|
|
14
|
+
/** One published-tier citation: the ref text and its file location. */
|
|
15
|
+
export interface TyplCitation {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly location: SourceLocation;
|
|
18
|
+
}
|
|
19
|
+
/** True when a code span's (trimmed) text is a bare published-shaped ref. */
|
|
20
|
+
export declare function isTyplCitationText(text: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Filter `Entry.bodyTokens` to published-tier citations, in source order.
|
|
23
|
+
* Reuses the shared inline-declaration walker with the citation
|
|
24
|
+
* recognizer — the walker strips backtick delimiters before matching.
|
|
25
|
+
*/
|
|
26
|
+
export declare function extractTyplCitations(bodyTokens: readonly BodyToken[]): readonly TyplCitation[];
|
|
27
|
+
//# sourceMappingURL=citations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"citations.d.ts","sourceRoot":"","sources":["../../src/typl/citations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjE,uEAAuE;AACvE,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;CACnC;AAED,6EAA6E;AAC7E,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGxD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,SAAS,SAAS,EAAE,GAC/B,SAAS,YAAY,EAAE,CAGzB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { extractInlineDeclarations } from "../decl/mod.js";
|
|
2
|
+
import { isPublishedTyplName, isRelativeTyplName } from "./resolve.js";
|
|
3
|
+
/** True when a code span's (trimmed) text is a bare published-shaped ref. */
|
|
4
|
+
export function isTyplCitationText(text) {
|
|
5
|
+
const t = text.trim();
|
|
6
|
+
return isPublishedTyplName(t) || isRelativeTyplName(t);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Filter `Entry.bodyTokens` to published-tier citations, in source order.
|
|
10
|
+
* Reuses the shared inline-declaration walker with the citation
|
|
11
|
+
* recognizer — the walker strips backtick delimiters before matching.
|
|
12
|
+
*/
|
|
13
|
+
export function extractTyplCitations(bodyTokens) {
|
|
14
|
+
return extractInlineDeclarations(bodyTokens, isTyplCitationText)
|
|
15
|
+
.map((d) => ({ name: d.source.trim(), location: d.location }));
|
|
16
|
+
}
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* @module typl/diagnostics
|
|
3
3
|
*
|
|
4
4
|
* Diagnostic codes emitted by the typl parser and validator (TYPL-001
|
|
5
|
-
* through TYPL-
|
|
5
|
+
* through TYPL-012). Each code carries a severity and a template; the
|
|
6
6
|
* `typlDiagnostic` helper performs `${var}` substitution.
|
|
7
7
|
*/
|
|
8
8
|
import type { Position } from "./ast.js";
|
|
9
9
|
import type { Severity } from "../model/mod.js";
|
|
10
10
|
/** Union of all valid TYPL diagnostic codes. */
|
|
11
|
-
export type TyplCode = "TYPL-001" | "TYPL-002" | "TYPL-003" | "TYPL-004" | "TYPL-005" | "TYPL-006" | "TYPL-007" | "TYPL-008";
|
|
11
|
+
export type TyplCode = "TYPL-001" | "TYPL-002" | "TYPL-003" | "TYPL-004" | "TYPL-005" | "TYPL-006" | "TYPL-007" | "TYPL-008" | "TYPL-009" | "TYPL-010" | "TYPL-011" | "TYPL-012";
|
|
12
12
|
/** Shape of each entry in {@linkcode TYPL_CODES}. */
|
|
13
13
|
export interface TyplCodeEntry {
|
|
14
14
|
readonly severity: Severity;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../src/typl/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAWhD,gDAAgD;AAChD,MAAM,MAAM,QAAQ,GAChB,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,CAAC;AAEf,qDAAqD;AACrD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;CAC7B;AAED,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,QAAQ,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../src/typl/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAWhD,gDAAgD;AAChD,MAAM,MAAM,QAAQ,GAChB,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,CAAC;AAEf,qDAAqD;AACrD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;CAC7B;AAED,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,QAAQ,EAAE,aAAa,CAyDtD,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EACvC,QAAQ,EAAE,QAAQ,GACjB,cAAc,CAUhB"}
|
package/esm/typl/diagnostics.js
CHANGED
|
@@ -10,10 +10,12 @@ export const TYPL_CODES = {
|
|
|
10
10
|
severity: "error",
|
|
11
11
|
template: "Duplicate binding for ${name} in the same entry (first wins, this is a duplicate).",
|
|
12
12
|
},
|
|
13
|
+
// Deprecated (#723): retired by the published tier. Kept resolvable for tooling; never emitted.
|
|
13
14
|
"TYPL-002": {
|
|
14
15
|
severity: "error",
|
|
15
16
|
template: "${name} is declared as kind ${kindA} here and ${kindB} in ${otherFile}:${otherLine}.",
|
|
16
17
|
},
|
|
18
|
+
// Deprecated (#723): retired by the published tier. Kept resolvable for tooling; never emitted.
|
|
17
19
|
"TYPL-003": {
|
|
18
20
|
severity: "error",
|
|
19
21
|
template: "${name} is declared with a different shape than in ${otherFile}:${otherLine}.",
|
|
@@ -38,6 +40,22 @@ export const TYPL_CODES = {
|
|
|
38
40
|
severity: "error",
|
|
39
41
|
template: "Literal ${value} violates declared ${constraint} (${detail}).",
|
|
40
42
|
},
|
|
43
|
+
"TYPL-009": {
|
|
44
|
+
severity: "error",
|
|
45
|
+
template: "${name} is already declared in ${otherFile}:${otherLine} (published symbols are declared exactly once).",
|
|
46
|
+
},
|
|
47
|
+
"TYPL-010": {
|
|
48
|
+
severity: "error",
|
|
49
|
+
template: "Relative reference ${name} has no namespace base in scope.",
|
|
50
|
+
},
|
|
51
|
+
"TYPL-011": {
|
|
52
|
+
severity: "error",
|
|
53
|
+
template: "Citation of undeclared published symbol ${name}.",
|
|
54
|
+
},
|
|
55
|
+
"TYPL-012": {
|
|
56
|
+
severity: "error",
|
|
57
|
+
template: "Multiple root namespace declarations in one entry (root is ${first}).",
|
|
58
|
+
},
|
|
41
59
|
};
|
|
42
60
|
/**
|
|
43
61
|
* Construct a typl diagnostic by substituting `${var}` placeholders in the
|
package/esm/typl/fence.d.ts
CHANGED
|
@@ -2,30 +2,21 @@
|
|
|
2
2
|
* @module typl/fence
|
|
3
3
|
*
|
|
4
4
|
* Fence surface adapter — extracts typl source from fenced code blocks
|
|
5
|
-
* whose info-string is "typl".
|
|
6
|
-
* (
|
|
5
|
+
* whose info-string is "typl". A thin wrapper over the shared
|
|
6
|
+
* declaration-surface machinery (core/decl): it supplies typl's fence
|
|
7
|
+
* recognizer and re-exports the common declaration node as
|
|
8
|
+
* {@linkcode TyplFenceExtraction}.
|
|
7
9
|
*
|
|
8
|
-
*
|
|
9
|
-
* its source range. PR 3 will wire the extracted source through
|
|
10
|
-
* parseTyplBlock and attach results to Entry.types.
|
|
10
|
+
* See ADR-019.
|
|
11
11
|
*/
|
|
12
|
-
import type { BodyBlock
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
readonly source: string;
|
|
17
|
-
/** Source range of the whole fence (opening ``` through closing ```). */
|
|
18
|
-
readonly range: SourceRange;
|
|
19
|
-
}
|
|
12
|
+
import type { BodyBlock } from "../ast/nodes.js";
|
|
13
|
+
import { type BlockDeclaration } from "../decl/mod.js";
|
|
14
|
+
/** A single typl fence found inside a body: `{ source, range }`. */
|
|
15
|
+
export type TyplFenceExtraction = BlockDeclaration;
|
|
20
16
|
/**
|
|
21
|
-
* Walk a body AST and return every typl fence found
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* BlockquoteNode and NoteNode carry only InlineContent (not nested
|
|
26
|
-
* BodyBlock[]), so they are not recursed into.
|
|
27
|
-
*
|
|
28
|
-
* Returns fences in source order (depth-first traversal).
|
|
17
|
+
* Walk a body AST and return every typl fence (```typl) found, in source
|
|
18
|
+
* order (depth-first, recursing into list items). Delegates traversal to
|
|
19
|
+
* {@linkcode extractFenceDeclarations}.
|
|
29
20
|
*/
|
|
30
21
|
export declare function extractTyplFences(blocks: readonly BodyBlock[]): readonly TyplFenceExtraction[];
|
|
31
22
|
//# sourceMappingURL=fence.d.ts.map
|
package/esm/typl/fence.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fence.d.ts","sourceRoot":"","sources":["../../src/typl/fence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"fence.d.ts","sourceRoot":"","sources":["../../src/typl/fence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EACL,KAAK,gBAAgB,EAEtB,MAAM,gBAAgB,CAAC;AAExB,oEAAoE;AACpE,MAAM,MAAM,mBAAmB,GAAG,gBAAgB,CAAC;AAEnD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,SAAS,EAAE,GAC3B,SAAS,mBAAmB,EAAE,CAEhC"}
|
package/esm/typl/fence.js
CHANGED
|
@@ -1,24 +1,9 @@
|
|
|
1
|
+
import { extractFenceDeclarations, } from "../decl/mod.js";
|
|
1
2
|
/**
|
|
2
|
-
* Walk a body AST and return every typl fence found
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* BlockquoteNode and NoteNode carry only InlineContent (not nested
|
|
7
|
-
* BodyBlock[]), so they are not recursed into.
|
|
8
|
-
*
|
|
9
|
-
* Returns fences in source order (depth-first traversal).
|
|
3
|
+
* Walk a body AST and return every typl fence (```typl) found, in source
|
|
4
|
+
* order (depth-first, recursing into list items). Delegates traversal to
|
|
5
|
+
* {@linkcode extractFenceDeclarations}.
|
|
10
6
|
*/
|
|
11
7
|
export function extractTyplFences(blocks) {
|
|
12
|
-
|
|
13
|
-
for (const block of blocks) {
|
|
14
|
-
if (block.kind === "code" && block.lang === "typl") {
|
|
15
|
-
results.push({ source: block.text, range: block.range });
|
|
16
|
-
}
|
|
17
|
-
else if (block.kind === "list") {
|
|
18
|
-
for (const item of block.items) {
|
|
19
|
-
results.push(...extractTyplFences(item.blocks));
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return results;
|
|
8
|
+
return extractFenceDeclarations(blocks, (lang) => lang === "typl");
|
|
24
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grammar.d.ts","sourceRoot":"","sources":["../../src/typl/grammar.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAOL,KAAK,SAAS,EACf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,KAAK,cAAc,EAAkB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"grammar.d.ts","sourceRoot":"","sources":["../../src/typl/grammar.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAOL,KAAK,SAAS,EACf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,KAAK,cAAc,EAAkB,MAAM,kBAAkB,CAAC;AAqgBvE;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,GACb;IAAE,GAAG,EAAE,SAAS,CAAC;IAAC,WAAW,EAAE,SAAS,cAAc,EAAE,CAAA;CAAE,CAK5D"}
|
package/esm/typl/grammar.js
CHANGED
|
@@ -125,6 +125,12 @@ class Parser {
|
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
const shape = this.parseShapeOptional();
|
|
128
|
+
// A namespace declaration (#723) is scaffolding — it establishes a
|
|
129
|
+
// base for relative refs and must not carry a shape.
|
|
130
|
+
if (kind === "namespace" && shape !== undefined) {
|
|
131
|
+
this.diagnostics.push(typlDiagnostic("TYPL-006", { detail: "a namespace declaration carries no shape" }, nameTok.position));
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
128
134
|
return {
|
|
129
135
|
statementKind: "binding",
|
|
130
136
|
name: nameTok.value,
|