@driftsys/markspec 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -20
- package/esm/ast/build.d.ts +11 -21
- package/esm/ast/build.d.ts.map +1 -1
- package/esm/ast/build.js +50 -139
- package/esm/ast/nodes.d.ts +11 -43
- package/esm/ast/nodes.d.ts.map +1 -1
- package/esm/ast/nodes.js +6 -1
- package/esm/ast/normalize.d.ts +8 -17
- package/esm/ast/normalize.d.ts.map +1 -1
- package/esm/ast/normalize.js +14 -72
- package/esm/compiler/constants.d.ts +16 -0
- package/esm/compiler/constants.d.ts.map +1 -0
- package/esm/compiler/constants.js +26 -0
- package/esm/compiler/discipline_classifier.d.ts +55 -0
- package/esm/compiler/discipline_classifier.d.ts.map +1 -0
- package/esm/compiler/discipline_classifier.js +191 -0
- package/esm/compiler/inverses.d.ts +7 -0
- package/esm/compiler/inverses.d.ts.map +1 -1
- package/esm/compiler/inverses.js +1 -18
- package/esm/compiler/mod.d.ts +30 -1
- package/esm/compiler/mod.d.ts.map +1 -1
- package/esm/compiler/mod.js +198 -65
- package/esm/compiler/schema.d.ts +15 -0
- package/esm/compiler/schema.d.ts.map +1 -1
- package/esm/compiler/schema.js +12 -0
- package/esm/config/markspec.d.ts +5 -0
- package/esm/config/markspec.d.ts.map +1 -1
- package/esm/config/markspec.js +17 -2
- package/esm/formatter/mod.d.ts +9 -3
- package/esm/formatter/mod.d.ts.map +1 -1
- package/esm/formatter/mod.js +97 -49
- package/esm/lexicons/loader.d.ts +35 -0
- package/esm/lexicons/loader.d.ts.map +1 -0
- package/esm/lexicons/loader.js +51 -0
- package/esm/lexicons/mod.d.ts +13 -0
- package/esm/lexicons/mod.d.ts.map +1 -0
- package/esm/lexicons/mod.js +12 -0
- package/esm/lint/glossary.d.ts +45 -0
- package/esm/lint/glossary.d.ts.map +1 -0
- package/esm/lint/glossary.js +85 -0
- package/esm/lint/mod.d.ts +4 -0
- package/esm/lint/mod.d.ts.map +1 -1
- package/esm/lint/mod.js +2 -0
- package/esm/lint/range_util.d.ts +25 -0
- package/esm/lint/range_util.d.ts.map +1 -0
- package/esm/lint/range_util.js +50 -0
- package/esm/lint/rules/ears.d.ts +39 -0
- package/esm/lint/rules/ears.d.ts.map +1 -0
- package/esm/lint/rules/ears.js +316 -0
- package/esm/lint/rules/incose_sentence.d.ts +46 -0
- package/esm/lint/rules/incose_sentence.d.ts.map +1 -0
- package/esm/lint/rules/incose_sentence.js +417 -0
- package/esm/lint/rules/modal_sentence.d.ts +46 -0
- package/esm/lint/rules/modal_sentence.d.ts.map +1 -0
- package/esm/lint/rules/modal_sentence.js +146 -0
- package/esm/lint/rules/passive.d.ts +64 -0
- package/esm/lint/rules/passive.d.ts.map +1 -0
- package/esm/lint/rules/passive.js +282 -0
- package/esm/lint/rules/suppression.d.ts +38 -3
- package/esm/lint/rules/suppression.d.ts.map +1 -1
- package/esm/lint/rules/suppression.js +58 -4
- package/esm/lint/rules/xref.d.ts +19 -0
- package/esm/lint/rules/xref.d.ts.map +1 -0
- package/esm/lint/rules/xref.js +248 -0
- package/esm/lint/runner.d.ts +31 -11
- package/esm/lint/runner.d.ts.map +1 -1
- package/esm/lint/runner.js +67 -26
- package/esm/lint/score.d.ts +64 -0
- package/esm/lint/score.d.ts.map +1 -0
- package/esm/lint/score.js +163 -0
- package/esm/lint/segmenter.d.ts +32 -0
- package/esm/lint/segmenter.d.ts.map +1 -0
- package/esm/lint/segmenter.js +79 -0
- package/esm/lint/types.d.ts +12 -0
- package/esm/lint/types.d.ts.map +1 -1
- package/esm/lock/canonical_edges.d.ts +31 -0
- package/esm/lock/canonical_edges.d.ts.map +1 -0
- package/esm/lock/canonical_edges.js +57 -0
- package/esm/lock/check.d.ts +24 -0
- package/esm/lock/check.d.ts.map +1 -0
- package/esm/lock/check.js +127 -0
- package/esm/lock/hash.d.ts +12 -0
- package/esm/lock/hash.d.ts.map +1 -0
- package/esm/lock/hash.js +32 -0
- package/esm/lock/mod.d.ts +19 -0
- package/esm/lock/mod.d.ts.map +1 -0
- package/esm/lock/mod.js +14 -0
- package/esm/lock/model.d.ts +81 -0
- package/esm/lock/model.d.ts.map +1 -0
- package/esm/lock/model.js +7 -0
- package/esm/lock/parser.d.ts +26 -0
- package/esm/lock/parser.d.ts.map +1 -0
- package/esm/lock/parser.js +195 -0
- package/esm/lock/resolve.d.ts +142 -0
- package/esm/lock/resolve.d.ts.map +1 -0
- package/esm/lock/resolve.js +389 -0
- package/esm/lock/serializer.d.ts +14 -0
- package/esm/lock/serializer.d.ts.map +1 -0
- package/esm/lock/serializer.js +104 -0
- package/esm/mod.d.ts +16 -9
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +12 -4
- package/esm/model/attributes.d.ts +6 -0
- package/esm/model/attributes.d.ts.map +1 -1
- package/esm/model/attributes.js +37 -0
- package/esm/model/discipline.d.ts +53 -0
- package/esm/model/discipline.d.ts.map +1 -0
- package/esm/model/discipline.js +50 -0
- package/esm/model/mod.d.ts +188 -30
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/mod.js +42 -1
- package/esm/model/profile.d.ts +69 -0
- package/esm/model/profile.d.ts.map +1 -1
- package/esm/parser/attributes.d.ts.map +1 -1
- package/esm/parser/attributes.js +1 -10
- package/esm/parser/body_tokens.d.ts +35 -0
- package/esm/parser/body_tokens.d.ts.map +1 -0
- package/esm/parser/body_tokens.js +232 -0
- package/esm/parser/glossary.d.ts +8 -0
- package/esm/parser/glossary.d.ts.map +1 -1
- package/esm/parser/glossary.js +6 -4
- package/esm/parser/grammars.d.ts +5 -3
- package/esm/parser/grammars.d.ts.map +1 -1
- package/esm/parser/grammars.js +18 -4
- package/esm/parser/language_spec.d.ts +55 -0
- package/esm/parser/language_spec.d.ts.map +1 -0
- package/esm/parser/language_spec.js +419 -0
- package/esm/parser/line_map.d.ts +60 -0
- package/esm/parser/line_map.d.ts.map +1 -0
- package/esm/parser/line_map.js +41 -0
- package/esm/parser/markdown.d.ts +9 -0
- package/esm/parser/markdown.d.ts.map +1 -1
- package/esm/parser/markdown.js +97 -31
- package/esm/parser/mod.d.ts +4 -0
- package/esm/parser/mod.d.ts.map +1 -1
- package/esm/parser/mod.js +30 -8
- package/esm/parser/source.d.ts +39 -8
- package/esm/parser/source.d.ts.map +1 -1
- package/esm/parser/source.js +155 -65
- package/esm/parser/translate.d.ts +24 -0
- package/esm/parser/translate.d.ts.map +1 -0
- package/esm/parser/translate.js +99 -0
- package/esm/profile/chain.d.ts +8 -0
- package/esm/profile/chain.d.ts.map +1 -1
- package/esm/profile/chain.js +29 -1
- package/esm/profile/default_profile.d.ts +25 -0
- package/esm/profile/default_profile.d.ts.map +1 -0
- package/esm/profile/default_profile.js +43 -0
- package/esm/profile/discipline_mode.d.ts +64 -0
- package/esm/profile/discipline_mode.d.ts.map +1 -0
- package/esm/profile/discipline_mode.js +133 -0
- package/esm/profile/discipline_registry.d.ts +41 -0
- package/esm/profile/discipline_registry.d.ts.map +1 -0
- package/esm/profile/discipline_registry.js +67 -0
- package/esm/profile/load.d.ts +3 -1
- package/esm/profile/load.d.ts.map +1 -1
- package/esm/profile/load.js +24 -5
- package/esm/profile/manifest.d.ts.map +1 -1
- package/esm/profile/manifest.js +253 -20
- package/esm/profile/merge.d.ts.map +1 -1
- package/esm/profile/merge.js +112 -0
- package/esm/profile/mod.d.ts +2 -0
- package/esm/profile/mod.d.ts.map +1 -1
- package/esm/profile/mod.js +2 -0
- package/esm/sync/locked_attributes.d.ts +19 -0
- package/esm/sync/locked_attributes.d.ts.map +1 -0
- package/esm/sync/locked_attributes.js +27 -0
- package/esm/sync/log.d.ts +34 -0
- package/esm/sync/log.d.ts.map +1 -0
- package/esm/sync/log.js +48 -0
- package/esm/sync/mapping.d.ts +66 -0
- package/esm/sync/mapping.d.ts.map +1 -0
- package/esm/sync/mapping.js +165 -0
- package/esm/sync/mod.d.ts +16 -0
- package/esm/sync/mod.d.ts.map +1 -0
- package/esm/sync/mod.js +12 -0
- package/esm/sync/status.d.ts +23 -0
- package/esm/sync/status.d.ts.map +1 -0
- package/esm/sync/status.js +21 -0
- package/esm/typl/ast.d.ts +87 -0
- package/esm/typl/ast.d.ts.map +1 -0
- package/esm/typl/ast.js +21 -0
- package/esm/typl/bridge.d.ts +32 -0
- package/esm/typl/bridge.d.ts.map +1 -0
- package/esm/typl/bridge.js +27 -0
- package/esm/typl/bullet.d.ts +34 -0
- package/esm/typl/bullet.d.ts.map +1 -0
- package/esm/typl/bullet.js +44 -0
- package/esm/typl/diagnostics.d.ts +43 -0
- package/esm/typl/diagnostics.d.ts.map +1 -0
- package/esm/typl/diagnostics.js +61 -0
- package/esm/typl/fence.d.ts +31 -0
- package/esm/typl/fence.d.ts.map +1 -0
- package/esm/typl/fence.js +24 -0
- package/esm/typl/grammar.d.ts +20 -0
- package/esm/typl/grammar.d.ts.map +1 -0
- package/esm/typl/grammar.js +471 -0
- package/esm/typl/inline.d.ts +34 -0
- package/esm/typl/inline.d.ts.map +1 -0
- package/esm/typl/inline.js +48 -0
- package/esm/typl/lexer.d.ts +37 -0
- package/esm/typl/lexer.d.ts.map +1 -0
- package/esm/typl/lexer.js +234 -0
- package/esm/typl/mod.d.ts +23 -0
- package/esm/typl/mod.d.ts.map +1 -0
- package/esm/typl/mod.js +16 -0
- package/esm/typl/registry.d.ts +42 -0
- package/esm/typl/registry.d.ts.map +1 -0
- package/esm/typl/registry.js +26 -0
- package/esm/typl/validator.d.ts +29 -0
- package/esm/typl/validator.d.ts.map +1 -0
- package/esm/typl/validator.js +141 -0
- package/esm/util/line_endings.d.ts +33 -0
- package/esm/util/line_endings.d.ts.map +1 -0
- package/esm/util/line_endings.js +53 -0
- package/esm/util/modals.d.ts +29 -0
- package/esm/util/modals.d.ts.map +1 -0
- package/esm/util/modals.js +38 -0
- package/esm/validator/discipline.d.ts +35 -0
- package/esm/validator/discipline.d.ts.map +1 -0
- package/esm/validator/discipline.js +204 -0
- package/esm/validator/mod.d.ts +1 -1
- package/esm/validator/mod.d.ts.map +1 -1
- package/esm/validator/mod.js +23 -2
- package/esm/validator/modal_keywords.d.ts +15 -13
- package/esm/validator/modal_keywords.d.ts.map +1 -1
- package/esm/validator/modal_keywords.js +26 -109
- package/esm/validator/pattern.d.ts +15 -8
- package/esm/validator/pattern.d.ts.map +1 -1
- package/esm/validator/pattern.js +42 -19
- package/esm/validator/per_type_attrs.d.ts +2 -2
- package/esm/validator/per_type_attrs.d.ts.map +1 -1
- package/esm/validator/per_type_attrs.js +2 -2
- package/esm/validator/pipeline.d.ts +11 -0
- package/esm/validator/pipeline.d.ts.map +1 -1
- package/esm/validator/pipeline.js +37 -15
- package/esm/validator/type_resolution.d.ts +3 -3
- package/esm/validator/type_resolution.d.ts.map +1 -1
- package/esm/validator/type_resolution.js +31 -9
- package/package.json +2 -2
- package/script/ast/build.d.ts +11 -21
- package/script/ast/build.d.ts.map +1 -1
- package/script/ast/build.js +51 -140
- package/script/ast/nodes.d.ts +11 -43
- package/script/ast/nodes.d.ts.map +1 -1
- package/script/ast/nodes.js +6 -1
- package/script/ast/normalize.d.ts +8 -17
- package/script/ast/normalize.d.ts.map +1 -1
- package/script/ast/normalize.js +16 -74
- package/script/compiler/constants.d.ts +16 -0
- package/script/compiler/constants.d.ts.map +1 -0
- package/script/compiler/constants.js +29 -0
- package/script/compiler/discipline_classifier.d.ts +55 -0
- package/script/compiler/discipline_classifier.d.ts.map +1 -0
- package/script/compiler/discipline_classifier.js +196 -0
- package/script/compiler/inverses.d.ts +7 -0
- package/script/compiler/inverses.d.ts.map +1 -1
- package/script/compiler/inverses.js +2 -19
- package/script/compiler/mod.d.ts +30 -1
- package/script/compiler/mod.d.ts.map +1 -1
- package/script/compiler/mod.js +202 -69
- package/script/compiler/schema.d.ts +15 -0
- package/script/compiler/schema.d.ts.map +1 -1
- package/script/compiler/schema.js +12 -0
- package/script/config/markspec.d.ts +5 -0
- package/script/config/markspec.d.ts.map +1 -1
- package/script/config/markspec.js +17 -2
- package/script/formatter/mod.d.ts +9 -3
- package/script/formatter/mod.d.ts.map +1 -1
- package/script/formatter/mod.js +99 -51
- package/script/lexicons/loader.d.ts +35 -0
- package/script/lexicons/loader.d.ts.map +1 -0
- package/script/lexicons/loader.js +55 -0
- package/script/lexicons/mod.d.ts +13 -0
- package/script/lexicons/mod.d.ts.map +1 -0
- package/script/lexicons/mod.js +17 -0
- package/script/lint/glossary.d.ts +45 -0
- package/script/lint/glossary.d.ts.map +1 -0
- package/script/lint/glossary.js +88 -0
- package/script/lint/mod.d.ts +4 -0
- package/script/lint/mod.d.ts.map +1 -1
- package/script/lint/mod.js +6 -1
- package/script/lint/range_util.d.ts +25 -0
- package/script/lint/range_util.d.ts.map +1 -0
- package/script/lint/range_util.js +53 -0
- package/script/lint/rules/ears.d.ts +39 -0
- package/script/lint/rules/ears.d.ts.map +1 -0
- package/script/lint/rules/ears.js +320 -0
- package/script/lint/rules/incose_sentence.d.ts +46 -0
- package/script/lint/rules/incose_sentence.d.ts.map +1 -0
- package/script/lint/rules/incose_sentence.js +421 -0
- package/script/lint/rules/modal_sentence.d.ts +46 -0
- package/script/lint/rules/modal_sentence.d.ts.map +1 -0
- package/script/lint/rules/modal_sentence.js +150 -0
- package/script/lint/rules/passive.d.ts +64 -0
- package/script/lint/rules/passive.d.ts.map +1 -0
- package/script/lint/rules/passive.js +286 -0
- package/script/lint/rules/suppression.d.ts +38 -3
- package/script/lint/rules/suppression.d.ts.map +1 -1
- package/script/lint/rules/suppression.js +59 -3
- package/script/lint/rules/xref.d.ts +19 -0
- package/script/lint/rules/xref.d.ts.map +1 -0
- package/script/lint/rules/xref.js +251 -0
- package/script/lint/runner.d.ts +31 -11
- package/script/lint/runner.d.ts.map +1 -1
- package/script/lint/runner.js +67 -26
- package/script/lint/score.d.ts +64 -0
- package/script/lint/score.d.ts.map +1 -0
- package/script/lint/score.js +167 -0
- package/script/lint/segmenter.d.ts +32 -0
- package/script/lint/segmenter.d.ts.map +1 -0
- package/script/lint/segmenter.js +82 -0
- package/script/lint/types.d.ts +12 -0
- package/script/lint/types.d.ts.map +1 -1
- package/script/lock/canonical_edges.d.ts +31 -0
- package/script/lock/canonical_edges.d.ts.map +1 -0
- package/script/lock/canonical_edges.js +61 -0
- package/script/lock/check.d.ts +24 -0
- package/script/lock/check.d.ts.map +1 -0
- package/script/lock/check.js +130 -0
- package/script/lock/hash.d.ts +12 -0
- package/script/lock/hash.d.ts.map +1 -0
- package/script/lock/hash.js +36 -0
- package/script/lock/mod.d.ts +19 -0
- package/script/lock/mod.d.ts.map +1 -0
- package/script/lock/mod.js +31 -0
- package/script/lock/model.d.ts +81 -0
- package/script/lock/model.d.ts.map +1 -0
- package/script/lock/model.js +10 -0
- package/script/lock/parser.d.ts +26 -0
- package/script/lock/parser.d.ts.map +1 -0
- package/script/lock/parser.js +198 -0
- package/script/lock/resolve.d.ts +142 -0
- package/script/lock/resolve.d.ts.map +1 -0
- package/script/lock/resolve.js +397 -0
- package/script/lock/serializer.d.ts +14 -0
- package/script/lock/serializer.d.ts.map +1 -0
- package/script/lock/serializer.js +107 -0
- package/script/mod.d.ts +16 -9
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +111 -38
- package/script/model/attributes.d.ts +6 -0
- package/script/model/attributes.d.ts.map +1 -1
- package/script/model/attributes.js +38 -1
- package/script/model/discipline.d.ts +53 -0
- package/script/model/discipline.d.ts.map +1 -0
- package/script/model/discipline.js +53 -0
- package/script/model/mod.d.ts +188 -30
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/mod.js +48 -1
- package/script/model/profile.d.ts +69 -0
- package/script/model/profile.d.ts.map +1 -1
- package/script/parser/attributes.d.ts.map +1 -1
- package/script/parser/attributes.js +1 -10
- package/script/parser/body_tokens.d.ts +35 -0
- package/script/parser/body_tokens.d.ts.map +1 -0
- package/script/parser/body_tokens.js +235 -0
- package/script/parser/glossary.d.ts +8 -0
- package/script/parser/glossary.d.ts.map +1 -1
- package/script/parser/glossary.js +7 -4
- package/script/parser/grammars.d.ts +5 -3
- package/script/parser/grammars.d.ts.map +1 -1
- package/script/parser/grammars.js +21 -8
- package/script/parser/language_spec.d.ts +55 -0
- package/script/parser/language_spec.d.ts.map +1 -0
- package/script/parser/language_spec.js +423 -0
- package/script/parser/line_map.d.ts +60 -0
- package/script/parser/line_map.d.ts.map +1 -0
- package/script/parser/line_map.js +44 -0
- package/script/parser/markdown.d.ts +9 -0
- package/script/parser/markdown.d.ts.map +1 -1
- package/script/parser/markdown.js +95 -29
- package/script/parser/mod.d.ts +4 -0
- package/script/parser/mod.d.ts.map +1 -1
- package/script/parser/mod.js +32 -7
- package/script/parser/source.d.ts +39 -8
- package/script/parser/source.d.ts.map +1 -1
- package/script/parser/source.js +156 -69
- package/script/parser/translate.d.ts +24 -0
- package/script/parser/translate.d.ts.map +1 -0
- package/script/parser/translate.js +102 -0
- package/script/profile/chain.d.ts +8 -0
- package/script/profile/chain.d.ts.map +1 -1
- package/script/profile/chain.js +29 -1
- package/script/profile/default_profile.d.ts +25 -0
- package/script/profile/default_profile.d.ts.map +1 -0
- package/script/profile/default_profile.js +46 -0
- package/script/profile/discipline_mode.d.ts +64 -0
- package/script/profile/discipline_mode.d.ts.map +1 -0
- package/script/profile/discipline_mode.js +138 -0
- package/script/profile/discipline_registry.d.ts +41 -0
- package/script/profile/discipline_registry.d.ts.map +1 -0
- package/script/profile/discipline_registry.js +70 -0
- package/script/profile/load.d.ts +3 -1
- package/script/profile/load.d.ts.map +1 -1
- package/script/profile/load.js +24 -5
- package/script/profile/manifest.d.ts.map +1 -1
- package/script/profile/manifest.js +252 -19
- package/script/profile/merge.d.ts.map +1 -1
- package/script/profile/merge.js +112 -0
- package/script/profile/mod.d.ts +2 -0
- package/script/profile/mod.d.ts.map +1 -1
- package/script/profile/mod.js +6 -1
- package/script/sync/locked_attributes.d.ts +19 -0
- package/script/sync/locked_attributes.d.ts.map +1 -0
- package/script/sync/locked_attributes.js +30 -0
- package/script/sync/log.d.ts +34 -0
- package/script/sync/log.d.ts.map +1 -0
- package/script/sync/log.js +52 -0
- package/script/sync/mapping.d.ts +66 -0
- package/script/sync/mapping.d.ts.map +1 -0
- package/script/sync/mapping.js +169 -0
- package/script/sync/mod.d.ts +16 -0
- package/script/sync/mod.d.ts.map +1 -0
- package/script/sync/mod.js +21 -0
- package/script/sync/status.d.ts +23 -0
- package/script/sync/status.d.ts.map +1 -0
- package/script/sync/status.js +24 -0
- package/script/typl/ast.d.ts +87 -0
- package/script/typl/ast.d.ts.map +1 -0
- package/script/typl/ast.js +24 -0
- package/script/typl/bridge.d.ts +32 -0
- package/script/typl/bridge.d.ts.map +1 -0
- package/script/typl/bridge.js +30 -0
- package/script/typl/bullet.d.ts +34 -0
- package/script/typl/bullet.d.ts.map +1 -0
- package/script/typl/bullet.js +47 -0
- package/script/typl/diagnostics.d.ts +43 -0
- package/script/typl/diagnostics.d.ts.map +1 -0
- package/script/typl/diagnostics.js +65 -0
- package/script/typl/fence.d.ts +31 -0
- package/script/typl/fence.d.ts.map +1 -0
- package/script/typl/fence.js +27 -0
- package/script/typl/grammar.d.ts +20 -0
- package/script/typl/grammar.d.ts.map +1 -0
- package/script/typl/grammar.js +474 -0
- package/script/typl/inline.d.ts +34 -0
- package/script/typl/inline.d.ts.map +1 -0
- package/script/typl/inline.js +51 -0
- package/script/typl/lexer.d.ts +37 -0
- package/script/typl/lexer.d.ts.map +1 -0
- package/script/typl/lexer.js +237 -0
- package/script/typl/mod.d.ts +23 -0
- package/script/typl/mod.d.ts.map +1 -0
- package/script/typl/mod.js +29 -0
- package/script/typl/registry.d.ts +42 -0
- package/script/typl/registry.d.ts.map +1 -0
- package/script/typl/registry.js +29 -0
- package/script/typl/validator.d.ts +29 -0
- package/script/typl/validator.d.ts.map +1 -0
- package/script/typl/validator.js +144 -0
- package/script/util/line_endings.d.ts +33 -0
- package/script/util/line_endings.d.ts.map +1 -0
- package/script/util/line_endings.js +58 -0
- package/script/util/modals.d.ts +29 -0
- package/script/util/modals.d.ts.map +1 -0
- package/script/util/modals.js +42 -0
- package/script/validator/discipline.d.ts +35 -0
- package/script/validator/discipline.d.ts.map +1 -0
- package/script/validator/discipline.js +207 -0
- package/script/validator/mod.d.ts +1 -1
- package/script/validator/mod.d.ts.map +1 -1
- package/script/validator/mod.js +23 -1
- package/script/validator/modal_keywords.d.ts +15 -13
- package/script/validator/modal_keywords.d.ts.map +1 -1
- package/script/validator/modal_keywords.js +26 -109
- package/script/validator/pattern.d.ts +15 -8
- package/script/validator/pattern.d.ts.map +1 -1
- package/script/validator/pattern.js +42 -19
- package/script/validator/per_type_attrs.d.ts +2 -2
- package/script/validator/per_type_attrs.d.ts.map +1 -1
- package/script/validator/per_type_attrs.js +2 -2
- package/script/validator/pipeline.d.ts +11 -0
- package/script/validator/pipeline.d.ts.map +1 -1
- package/script/validator/pipeline.js +40 -17
- package/script/validator/type_resolution.d.ts +3 -3
- package/script/validator/type_resolution.d.ts.map +1 -1
- package/script/validator/type_resolution.js +31 -9
- package/esm/parser/entity_refs.d.ts +0 -53
- package/esm/parser/entity_refs.d.ts.map +0 -1
- package/esm/parser/entity_refs.js +0 -151
- package/script/parser/entity_refs.d.ts +0 -53
- package/script/parser/entity_refs.d.ts.map +0 -1
- package/script/parser/entity_refs.js +0 -155
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"body_tokens.d.ts","sourceRoot":"","sources":["../../src/parser/body_tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,SAAS,EAET,cAAc,EACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAAE,IAAI,EAAe,MAAM,cAAc,CAAC;AA+JtD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,SAAS,SAAS,EAAE,EAC7B,YAAY,EAAE,cAAc,EAC5B,YAAY,SAAI,EAChB,SAAS,CAAC,EAAE,IAAI,GACf,SAAS,SAAS,EAAE,CAsEtB"}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module core/parser/body_tokens
|
|
4
|
+
*
|
|
5
|
+
* Inline-construct token extraction (ADR-016). Scans entry body prose for
|
|
6
|
+
* the six BodyTokenKind variants, skipping verbatim regions (code, math,
|
|
7
|
+
* inline-code spans). Inside ` ```feature ` / ` ```gherkin ` fences the
|
|
8
|
+
* modal/EARS/entity-ref scanners are suppressed and the gherkin
|
|
9
|
+
* section/step scanners run instead.
|
|
10
|
+
*
|
|
11
|
+
* Single source of truth for inline-construct extraction. Replaces the
|
|
12
|
+
* pre-ADR-016 marker mechanism (`InlineContent.markers`) and the
|
|
13
|
+
* `Entry.entityRefs` field.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.extractBodyTokens = extractBodyTokens;
|
|
17
|
+
const remark_js_1 = require("./remark.js");
|
|
18
|
+
/**
|
|
19
|
+
* Decide the case convention of an entity-reference identifier per spec
|
|
20
|
+
* §2.5.2:
|
|
21
|
+
*
|
|
22
|
+
* - `constant` — all-uppercase letters/digits/underscores, contains at
|
|
23
|
+
* least one underscore or digit, ends with `[A-Z0-9]`. Distinguishes
|
|
24
|
+
* `$DEBOUNCE_WINDOW` from a single-segment PascalCase like `$ASIL`.
|
|
25
|
+
* - `type` — starts with an uppercase letter (PascalCase / single
|
|
26
|
+
* uppercase segment).
|
|
27
|
+
* - `instance` — starts with a lowercase letter (camelCase).
|
|
28
|
+
*/
|
|
29
|
+
function classifyConvention(ident) {
|
|
30
|
+
if (/^[A-Z][A-Z0-9_]*[A-Z0-9]$/.test(ident) && /[_0-9]/.test(ident)) {
|
|
31
|
+
return "constant";
|
|
32
|
+
}
|
|
33
|
+
if (/^[A-Z]/.test(ident))
|
|
34
|
+
return "type";
|
|
35
|
+
return "instance";
|
|
36
|
+
}
|
|
37
|
+
/** RFC 2119 modal verbs — matched case-insensitively as whole words.
|
|
38
|
+
* Multi-word compounds (shall not, should not, must not) come first
|
|
39
|
+
* so the leftmost-eager JS regex engine picks them before the bare verb. */
|
|
40
|
+
const MODAL_RE = /\b(shall not|should not|must not|shall|should|may|must|will)\b/gi;
|
|
41
|
+
/** EARS pattern triggers — capital-initial, whole word, case-sensitive. */
|
|
42
|
+
const EARS_RE = /\b(When|While|If|Where|Then)\b/g;
|
|
43
|
+
/** `$Identifier` entity reference (spec §2.5.2). */
|
|
44
|
+
const ENTITY_REF_RE = /\$([A-Za-z][A-Za-z0-9_]*)/g;
|
|
45
|
+
/** Gherkin section headers — class-like tokens. */
|
|
46
|
+
const GHERKIN_SECTION_RE = /\b(Feature|Background|Rule|Scenario Outline|Scenario Template|Scenarios|Examples|Scenario)\b/g;
|
|
47
|
+
/** Gherkin step keywords. */
|
|
48
|
+
const GHERKIN_STEP_RE = /\b(Given|When|Then|And|But)\b/g;
|
|
49
|
+
/**
|
|
50
|
+
* Collect body-relative 1-based line numbers that fall inside verbatim
|
|
51
|
+
* blocks: fenced code, fenced feature, math. Lines in this set are
|
|
52
|
+
* skipped by the modal / EARS / entity-ref scanner.
|
|
53
|
+
*
|
|
54
|
+
* Recurses through list items so nested verbatim blocks (e.g., a code
|
|
55
|
+
* fence inside a list item) are also captured.
|
|
56
|
+
*/
|
|
57
|
+
function collectVerbatimLines(blocks) {
|
|
58
|
+
const lines = new Set();
|
|
59
|
+
for (const block of blocks) {
|
|
60
|
+
if (block.kind === "code" || block.kind === "feature" ||
|
|
61
|
+
block.kind === "math") {
|
|
62
|
+
for (let ln = block.range.start.line; ln <= block.range.end.line; ln++) {
|
|
63
|
+
lines.add(ln);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else if (block.kind === "list") {
|
|
67
|
+
for (const item of block.items) {
|
|
68
|
+
for (const ln of collectVerbatimLines(item.blocks))
|
|
69
|
+
lines.add(ln);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return lines;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Walk `bodyAst` for `feature` nodes. For each, scan its source text for
|
|
77
|
+
* Gherkin section + step keywords. Positions are body-relative based on
|
|
78
|
+
* the node's `range.start.line`.
|
|
79
|
+
*/
|
|
80
|
+
function emitGherkin(blocks, out, baseLocation, columnOffset) {
|
|
81
|
+
for (const block of blocks) {
|
|
82
|
+
if (block.kind === "feature") {
|
|
83
|
+
const startLine = block.range.start.line;
|
|
84
|
+
const lines = block.source.split("\n");
|
|
85
|
+
for (let li = 0; li < lines.length; li++) {
|
|
86
|
+
const line = lines[li];
|
|
87
|
+
// Body-relative line; feature fence's opening ``` line is at startLine,
|
|
88
|
+
// content begins at startLine + 1.
|
|
89
|
+
const lineNo = baseLocation.line + (startLine - 1) + (li + 1);
|
|
90
|
+
let m;
|
|
91
|
+
GHERKIN_SECTION_RE.lastIndex = 0;
|
|
92
|
+
while ((m = GHERKIN_SECTION_RE.exec(line)) !== null) {
|
|
93
|
+
out.push({
|
|
94
|
+
kind: "gherkin-section",
|
|
95
|
+
text: m[1],
|
|
96
|
+
location: {
|
|
97
|
+
file: baseLocation.file,
|
|
98
|
+
line: lineNo,
|
|
99
|
+
column: m.index + 1 + columnOffset,
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
GHERKIN_STEP_RE.lastIndex = 0;
|
|
104
|
+
while ((m = GHERKIN_STEP_RE.exec(line)) !== null) {
|
|
105
|
+
out.push({
|
|
106
|
+
kind: "gherkin-step",
|
|
107
|
+
text: m[1],
|
|
108
|
+
location: {
|
|
109
|
+
file: baseLocation.file,
|
|
110
|
+
line: lineNo,
|
|
111
|
+
column: m.index + 1 + columnOffset,
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else if (block.kind === "list") {
|
|
118
|
+
for (const item of block.items) {
|
|
119
|
+
emitGherkin(item.blocks, out, baseLocation, columnOffset);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Walk the mdast for the body and emit one `inline-code` token per
|
|
126
|
+
* `inlineCode` node. Markdown line/column positions translate directly
|
|
127
|
+
* to body-relative line/column.
|
|
128
|
+
*/
|
|
129
|
+
function emitInlineCode(tree, out, baseLocation, columnOffset) {
|
|
130
|
+
const visit = (node) => {
|
|
131
|
+
if (node.type === "inlineCode" && node.position &&
|
|
132
|
+
node.value !== undefined) {
|
|
133
|
+
out.push({
|
|
134
|
+
kind: "inline-code",
|
|
135
|
+
text: `\`${node.value}\``,
|
|
136
|
+
location: {
|
|
137
|
+
file: baseLocation.file,
|
|
138
|
+
line: baseLocation.line + node.position.start.line - 1,
|
|
139
|
+
column: node.position.start.column + columnOffset,
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if ("children" in node && Array.isArray(node.children)) {
|
|
145
|
+
for (const child of node.children)
|
|
146
|
+
visit(child);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
visit(tree);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Extract body-token stream from an entry body.
|
|
153
|
+
*
|
|
154
|
+
* @param body - entry body string (post-`splitBodyAndAttributes`)
|
|
155
|
+
* @param bodyAst - canonical body AST for the same body (drives
|
|
156
|
+
* code/math/feature fence detection)
|
|
157
|
+
* @param baseLocation - `SourceLocation` of the body's first line; the
|
|
158
|
+
* `file` field is propagated to every emitted token
|
|
159
|
+
* @param columnOffset - Number of source characters stripped from the
|
|
160
|
+
* start of each body line before the body string was built. Added to
|
|
161
|
+
* every emitted column value so columns are relative to the containing
|
|
162
|
+
* buffer line, not the stripped body text. Defaults to 0. Source-file
|
|
163
|
+
* callers (via parseMarkdown's lineMap path) supply the list-item
|
|
164
|
+
* indent width so the LineMap receives buffer-relative columns.
|
|
165
|
+
* @returns tokens sorted by `(line, column)`. Empty when no constructs
|
|
166
|
+
* are recognised.
|
|
167
|
+
*/
|
|
168
|
+
function extractBodyTokens(body, bodyAst, baseLocation, columnOffset = 0, mdastTree) {
|
|
169
|
+
const tokens = [];
|
|
170
|
+
const verbatimLines = collectVerbatimLines(bodyAst);
|
|
171
|
+
const lines = body.split("\n");
|
|
172
|
+
for (let li = 0; li < lines.length; li++) {
|
|
173
|
+
const line = lines[li];
|
|
174
|
+
const lineNo = baseLocation.line + li;
|
|
175
|
+
if (verbatimLines.has(li + 1))
|
|
176
|
+
continue;
|
|
177
|
+
MODAL_RE.lastIndex = 0;
|
|
178
|
+
let m;
|
|
179
|
+
while ((m = MODAL_RE.exec(line)) !== null) {
|
|
180
|
+
const text = m[1];
|
|
181
|
+
tokens.push({
|
|
182
|
+
kind: "modal",
|
|
183
|
+
text,
|
|
184
|
+
case: text === text.toLowerCase() ? "lower" : "upper",
|
|
185
|
+
location: {
|
|
186
|
+
file: baseLocation.file,
|
|
187
|
+
line: lineNo,
|
|
188
|
+
column: m.index + 1 + columnOffset,
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
EARS_RE.lastIndex = 0;
|
|
193
|
+
while ((m = EARS_RE.exec(line)) !== null) {
|
|
194
|
+
const text = m[1];
|
|
195
|
+
tokens.push({
|
|
196
|
+
kind: "ears-trigger",
|
|
197
|
+
text,
|
|
198
|
+
trigger: text,
|
|
199
|
+
location: {
|
|
200
|
+
file: baseLocation.file,
|
|
201
|
+
line: lineNo,
|
|
202
|
+
column: m.index + 1 + columnOffset,
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
ENTITY_REF_RE.lastIndex = 0;
|
|
207
|
+
while ((m = ENTITY_REF_RE.exec(line)) !== null) {
|
|
208
|
+
// Skip second half of `$$…$$` math fence
|
|
209
|
+
if (m.index > 0 && line[m.index - 1] === "$")
|
|
210
|
+
continue;
|
|
211
|
+
// Skip escaped `\$`
|
|
212
|
+
if (m.index > 0 && line[m.index - 1] === "\\")
|
|
213
|
+
continue;
|
|
214
|
+
const ident = m[0]; // includes leading `$`
|
|
215
|
+
const bare = m[1];
|
|
216
|
+
tokens.push({
|
|
217
|
+
kind: "entity-ref",
|
|
218
|
+
text: ident,
|
|
219
|
+
convention: classifyConvention(bare),
|
|
220
|
+
location: {
|
|
221
|
+
file: baseLocation.file,
|
|
222
|
+
line: lineNo,
|
|
223
|
+
column: m.index + 1 + columnOffset,
|
|
224
|
+
},
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
emitGherkin(bodyAst, tokens, baseLocation, columnOffset);
|
|
229
|
+
const tree = mdastTree ?? remark_js_1.processor.parse(body);
|
|
230
|
+
emitInlineCode(tree, tokens, baseLocation, columnOffset);
|
|
231
|
+
tokens.sort((a, b) => a.location.line !== b.location.line
|
|
232
|
+
? a.location.line - b.location.line
|
|
233
|
+
: a.location.column - b.location.column);
|
|
234
|
+
return tokens;
|
|
235
|
+
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* blocks. This module walks the mdast AST to validate the four structural
|
|
8
8
|
* rules (R4-a through R4-e) and emits MSL-L020–L024 diagnostics.
|
|
9
9
|
*/
|
|
10
|
+
import type { Heading } from "@types/mdast";
|
|
10
11
|
import type { Diagnostic } from "../model/mod.js";
|
|
11
12
|
/** Options for {@linkcode validateGlossaryStructure}. */
|
|
12
13
|
export interface GlossaryValidationOptions {
|
|
@@ -25,6 +26,13 @@ export interface GlossaryValidationResult {
|
|
|
25
26
|
* drop chars outside [a-z0-9._/-]
|
|
26
27
|
*/
|
|
27
28
|
export declare function deriveTermSlug(text: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Extract the plain-text content from a heading node by walking its
|
|
31
|
+
* inline children and concatenating `text` and `inlineCode` node values.
|
|
32
|
+
* Exported so the lint pipeline (`core/lint/glossary.ts`) can reuse the
|
|
33
|
+
* same convention without duplicating the walk.
|
|
34
|
+
*/
|
|
35
|
+
export declare function extractHeadingText(node: Heading): string;
|
|
28
36
|
/**
|
|
29
37
|
* Walk a glossary document's mdast AST and validate the H1/H2/H3
|
|
30
38
|
* heading-shape grammar (spec §4.2).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glossary.d.ts","sourceRoot":"","sources":["../../src/parser/glossary.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"glossary.d.ts","sourceRoot":"","sources":["../../src/parser/glossary.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAQ,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,iBAAiB,CAAC;AAGlE,yDAAyD;AACzD,MAAM,WAAW,yBAAyB;IACxC,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,+CAA+C;AAC/C,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,0EAA0E;IAC1E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMnD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAUxD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,yBAAyB,GAClC,wBAAwB,CAoN1B"}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.deriveTermSlug = deriveTermSlug;
|
|
13
|
+
exports.extractHeadingText = extractHeadingText;
|
|
13
14
|
exports.validateGlossaryStructure = validateGlossaryStructure;
|
|
14
15
|
const remark_js_1 = require("./remark.js");
|
|
15
16
|
/**
|
|
@@ -26,9 +27,11 @@ function deriveTermSlug(text) {
|
|
|
26
27
|
}
|
|
27
28
|
/**
|
|
28
29
|
* Extract the plain-text content from a heading node by walking its
|
|
29
|
-
* inline children and concatenating
|
|
30
|
+
* inline children and concatenating `text` and `inlineCode` node values.
|
|
31
|
+
* Exported so the lint pipeline (`core/lint/glossary.ts`) can reuse the
|
|
32
|
+
* same convention without duplicating the walk.
|
|
30
33
|
*/
|
|
31
|
-
function
|
|
34
|
+
function extractHeadingText(node) {
|
|
32
35
|
let text = "";
|
|
33
36
|
for (const child of node.children) {
|
|
34
37
|
if (child.type === "text") {
|
|
@@ -64,7 +67,7 @@ function validateGlossaryStructure(markdown, options) {
|
|
|
64
67
|
const h = node;
|
|
65
68
|
nodes.push({
|
|
66
69
|
depth: h.depth,
|
|
67
|
-
text:
|
|
70
|
+
text: extractHeadingText(h),
|
|
68
71
|
line: h.position?.start.line ?? 1,
|
|
69
72
|
column: h.position?.start.column ?? 1,
|
|
70
73
|
});
|
|
@@ -109,7 +112,7 @@ function validateGlossaryStructure(markdown, options) {
|
|
|
109
112
|
events.push({
|
|
110
113
|
kind: "heading",
|
|
111
114
|
depth: h.depth,
|
|
112
|
-
text:
|
|
115
|
+
text: extractHeadingText(h),
|
|
113
116
|
line: h.position?.start.line ?? 1,
|
|
114
117
|
col: h.position?.start.column ?? 1,
|
|
115
118
|
});
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Lazy-loading tree-sitter grammar resolver. Maps file extensions to
|
|
5
5
|
* grammar WASM files and caches loaded languages for reuse.
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
7
|
+
import { Language } from "web-tree-sitter";
|
|
8
8
|
/** Check whether a file extension has a supported grammar. */
|
|
9
9
|
export declare function isSupportedExtension(ext: string): boolean;
|
|
10
10
|
/**
|
|
@@ -12,11 +12,13 @@ export declare function isSupportedExtension(ext: string): boolean;
|
|
|
12
12
|
*
|
|
13
13
|
* Initializes the Parser WASM runtime on first call. Grammar languages
|
|
14
14
|
* are cached — repeated calls with the same extension return the
|
|
15
|
-
* same `
|
|
15
|
+
* same `Language` instance. Concurrent-safe: stores the loading
|
|
16
16
|
* promise so parallel calls await the same load.
|
|
17
17
|
*
|
|
18
18
|
* @param ext - File extension including the dot (e.g., `.rs`, `.java`)
|
|
19
19
|
* @throws If the extension is unsupported or the WASM file cannot be loaded
|
|
20
20
|
*/
|
|
21
|
-
export declare function loadGrammar(ext: string): Promise<
|
|
21
|
+
export declare function loadGrammar(ext: string): Promise<Language>;
|
|
22
|
+
export { languageIdForExtension } from "./language_spec.js";
|
|
23
|
+
export type { SupportedLanguage } from "./language_spec.js";
|
|
22
24
|
//# sourceMappingURL=grammars.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grammars.d.ts","sourceRoot":"","sources":["../../src/parser/grammars.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"grammars.d.ts","sourceRoot":"","sources":["../../src/parser/grammars.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAU,MAAM,iBAAiB,CAAC;AAsCnD,8DAA8D;AAC9D,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAY1D;AA2BD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -5,13 +5,11 @@
|
|
|
5
5
|
* Lazy-loading tree-sitter grammar resolver. Maps file extensions to
|
|
6
6
|
* grammar WASM files and caches loaded languages for reuse.
|
|
7
7
|
*/
|
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.languageIdForExtension = void 0;
|
|
12
10
|
exports.isSupportedExtension = isSupportedExtension;
|
|
13
11
|
exports.loadGrammar = loadGrammar;
|
|
14
|
-
const web_tree_sitter_1 =
|
|
12
|
+
const web_tree_sitter_1 = require("web-tree-sitter");
|
|
15
13
|
const path_1 = require("@std/path");
|
|
16
14
|
/** Map file extensions to grammar WASM file names. */
|
|
17
15
|
const EXT_TO_GRAMMAR = {
|
|
@@ -26,6 +24,13 @@ const EXT_TO_GRAMMAR = {
|
|
|
26
24
|
".cxx": "tree-sitter-cpp",
|
|
27
25
|
".hpp": "tree-sitter-cpp",
|
|
28
26
|
".hxx": "tree-sitter-cpp",
|
|
27
|
+
".ts": "tree-sitter-typescript",
|
|
28
|
+
".tsx": "tree-sitter-tsx",
|
|
29
|
+
".jsx": "tree-sitter-tsx",
|
|
30
|
+
".js": "tree-sitter-javascript",
|
|
31
|
+
".mjs": "tree-sitter-javascript",
|
|
32
|
+
".cjs": "tree-sitter-javascript",
|
|
33
|
+
".cs": "tree-sitter-c-sharp",
|
|
29
34
|
};
|
|
30
35
|
/** Directory containing grammar WASM files. */
|
|
31
36
|
const GRAMMARS_DIR = (0, path_1.join)(globalThis[Symbol.for("import-meta-ponyfill-commonjs")](require, module).dirname, "..", "..", "..", "..", "grammars");
|
|
@@ -40,7 +45,7 @@ function isSupportedExtension(ext) {
|
|
|
40
45
|
*
|
|
41
46
|
* Initializes the Parser WASM runtime on first call. Grammar languages
|
|
42
47
|
* are cached — repeated calls with the same extension return the
|
|
43
|
-
* same `
|
|
48
|
+
* same `Language` instance. Concurrent-safe: stores the loading
|
|
44
49
|
* promise so parallel calls await the same load.
|
|
45
50
|
*
|
|
46
51
|
* @param ext - File extension including the dot (e.g., `.rs`, `.java`)
|
|
@@ -60,18 +65,26 @@ function loadGrammar(ext) {
|
|
|
60
65
|
}
|
|
61
66
|
async function doLoad(grammarName) {
|
|
62
67
|
if (!initialized) {
|
|
63
|
-
await web_tree_sitter_1.
|
|
68
|
+
await web_tree_sitter_1.Parser.init();
|
|
64
69
|
initialized = true;
|
|
65
70
|
}
|
|
66
71
|
// The compiled binary embeds grammars as .wasm.bin to bypass Deno's
|
|
67
72
|
// WASM-import resolver (see scripts/compile_binary.ts). Prefer the
|
|
68
73
|
// mirror when present; fall back to .wasm in dev mode.
|
|
74
|
+
//
|
|
75
|
+
// We always read bytes first with Deno.readFile() and pass Uint8Array to
|
|
76
|
+
// Language.load(). Passing a path string directly causes a NotSupported
|
|
77
|
+
// crash in compiled binaries: web-tree-sitter uses the Node.js fs shim
|
|
78
|
+
// internally, which cannot access Deno's virtual embedded filesystem.
|
|
79
|
+
// (readFileFromFd in ext:deno_node/fs.ts:320 — issue #513)
|
|
69
80
|
const binPath = (0, path_1.join)(GRAMMARS_DIR, `${grammarName}.wasm.bin`);
|
|
70
81
|
try {
|
|
71
82
|
await Deno.stat(binPath);
|
|
72
|
-
return web_tree_sitter_1.
|
|
83
|
+
return web_tree_sitter_1.Language.load(await Deno.readFile(binPath));
|
|
73
84
|
}
|
|
74
85
|
catch {
|
|
75
|
-
return web_tree_sitter_1.
|
|
86
|
+
return web_tree_sitter_1.Language.load(await Deno.readFile((0, path_1.join)(GRAMMARS_DIR, `${grammarName}.wasm`)));
|
|
76
87
|
}
|
|
77
88
|
}
|
|
89
|
+
var language_spec_js_1 = require("./language_spec.js");
|
|
90
|
+
Object.defineProperty(exports, "languageIdForExtension", { enumerable: true, get: function () { return language_spec_js_1.languageIdForExtension; } });
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module parser/language_spec
|
|
3
|
+
*
|
|
4
|
+
* Per-grammar doc-comment dispatch table. Each tree-sitter grammar names
|
|
5
|
+
* its comment nodes differently (Rust splits `line_comment`/`block_comment`;
|
|
6
|
+
* Kotlin uses `multiline_comment` for block; C/C++ collapses all comments
|
|
7
|
+
* to a single `comment` node), so the walker reads node-type names plus
|
|
8
|
+
* text predicates from this table rather than hard-coding them.
|
|
9
|
+
*
|
|
10
|
+
* Adding a new language is a single row here plus an extension entry in
|
|
11
|
+
* {@linkcode languageIdForExtension}.
|
|
12
|
+
*/
|
|
13
|
+
import type { Node as SyntaxNode } from "web-tree-sitter";
|
|
14
|
+
import type { SupportedLanguage } from "../model/mod.js";
|
|
15
|
+
export type { SupportedLanguage };
|
|
16
|
+
export interface LanguageDocCommentSpec {
|
|
17
|
+
/** Tree-sitter node type(s) for block (multi-line) comments. */
|
|
18
|
+
readonly blockCommentTypes: readonly string[];
|
|
19
|
+
/** Tree-sitter node type(s) for line (single-line) comments. */
|
|
20
|
+
readonly lineCommentTypes: readonly string[];
|
|
21
|
+
/** Predicate: this block-comment node text starts a doc block. */
|
|
22
|
+
isDocBlock(text: string): boolean;
|
|
23
|
+
/** Predicate: this line-comment node text is a doc-line comment. */
|
|
24
|
+
isDocLine(text: string): boolean;
|
|
25
|
+
/** Tree-sitter node types that an enclosing "item" (function, class,
|
|
26
|
+
* struct, impl, mod, etc.) might be. Walker searches the doc comment's
|
|
27
|
+
* next sibling for one of these. */
|
|
28
|
+
readonly enclosingItemTypes: readonly string[];
|
|
29
|
+
/** Tree-sitter node types to skip during the enclosing-item walk
|
|
30
|
+
* (attributes, annotations, comments). */
|
|
31
|
+
readonly attributeSkipTypes: readonly string[];
|
|
32
|
+
/** Extract a name from an enclosing-item node. Each grammar uses a
|
|
33
|
+
* different convention. Returns undefined for anonymous items or
|
|
34
|
+
* extraction failures (operator overloads, destructors, etc.). */
|
|
35
|
+
itemName(node: SyntaxNode): string | undefined;
|
|
36
|
+
}
|
|
37
|
+
/** Set of every enclosing-item node type across TypeScript, TSX, and JS.
|
|
38
|
+
* Used by {@linkcode jsLikeItemName} when unwrapping `export_statement`
|
|
39
|
+
* and `expression_statement` to recognise the real item among the
|
|
40
|
+
* wrapper's children. Probe-verified against tree-sitter-typescript@0.23.2
|
|
41
|
+
* and tree-sitter-javascript@0.23.1.
|
|
42
|
+
*
|
|
43
|
+
* Exported for the drift-guard test in `language_spec_test.ts` — every
|
|
44
|
+
* non-wrapper member of `typescriptSpec.enclosingItemTypes` and
|
|
45
|
+
* `javascriptSpec.enclosingItemTypes` must appear here. */
|
|
46
|
+
export declare const JS_LIKE_ENCLOSING_TYPES: Set<string>;
|
|
47
|
+
/**
|
|
48
|
+
* Closed-form table indexed by {@linkcode SupportedLanguage}. The walker in
|
|
49
|
+
* `parser/source.ts` consults this map to know which AST node types to
|
|
50
|
+
* inspect and how to discriminate doc comments from regular ones.
|
|
51
|
+
*/
|
|
52
|
+
export declare const LANGUAGE_SPECS: Record<SupportedLanguage, LanguageDocCommentSpec>;
|
|
53
|
+
/** Map a file extension (including the dot) to its language id. */
|
|
54
|
+
export declare function languageIdForExtension(ext: string): SupportedLanguage | undefined;
|
|
55
|
+
//# sourceMappingURL=language_spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language_spec.d.ts","sourceRoot":"","sources":["../../src/parser/language_spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,YAAY,EAAE,iBAAiB,EAAE,CAAC;AAElC,MAAM,WAAW,sBAAsB;IACrC,gEAAgE;IAChE,QAAQ,CAAC,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9C,gEAAgE;IAChE,QAAQ,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C,kEAAkE;IAClE,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAClC,oEAAoE;IACpE,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACjC;;wCAEoC;IACpC,QAAQ,CAAC,kBAAkB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/C;8CAC0C;IAC1C,QAAQ,CAAC,kBAAkB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/C;;sEAEkE;IAClE,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;CAChD;AAqGD;;;;;;;;2DAQ2D;AAC3D,eAAO,MAAM,uBAAuB,aAYlC,CAAC;AA0IH;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,iBAAiB,EAAE,sBAAsB,CAgI1E,CAAC;AAEJ,mEAAmE;AACnE,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,MAAM,GACV,iBAAiB,GAAG,SAAS,CAgC/B"}
|