@driftsys/markspec 0.4.0 → 0.6.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 +74 -20
- package/esm/ast/build.d.ts +60 -0
- package/esm/ast/build.d.ts.map +1 -0
- package/esm/ast/build.js +516 -0
- package/esm/ast/equivalence.d.ts +18 -0
- package/esm/ast/equivalence.d.ts.map +1 -0
- package/esm/ast/equivalence.js +56 -0
- package/esm/ast/nodes.d.ts +189 -0
- package/esm/ast/nodes.d.ts.map +1 -0
- package/esm/ast/nodes.js +17 -0
- package/esm/ast/normalize.d.ts +58 -0
- package/esm/ast/normalize.d.ts.map +1 -0
- package/esm/ast/normalize.js +197 -0
- package/esm/ast/render.d.ts +34 -0
- package/esm/ast/render.d.ts.map +1 -0
- package/esm/ast/render.js +215 -0
- 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 +2 -1
- package/esm/compiler/inverses.d.ts.map +1 -1
- package/esm/compiler/inverses.js +33 -14
- package/esm/compiler/manifest.d.ts +59 -0
- package/esm/compiler/manifest.d.ts.map +1 -0
- package/esm/compiler/manifest.js +48 -0
- package/esm/compiler/mod.d.ts +38 -1
- package/esm/compiler/mod.d.ts.map +1 -1
- package/esm/compiler/mod.js +202 -50
- package/esm/compiler/ndjson_writer.d.ts +50 -0
- package/esm/compiler/ndjson_writer.d.ts.map +1 -0
- package/esm/compiler/ndjson_writer.js +73 -0
- package/esm/compiler/schema.d.ts +33 -1
- package/esm/compiler/schema.d.ts.map +1 -1
- package/esm/compiler/schema.js +30 -9
- 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/config/mod.d.ts.map +1 -1
- package/esm/config/mod.js +54 -0
- package/esm/formatter/mod.d.ts +55 -4
- package/esm/formatter/mod.d.ts.map +1 -1
- package/esm/formatter/mod.js +423 -46
- package/esm/formatter/synth_ulid.d.ts +21 -0
- package/esm/formatter/synth_ulid.d.ts.map +1 -0
- package/esm/formatter/synth_ulid.js +64 -0
- 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 +14 -0
- package/esm/lint/mod.d.ts.map +1 -0
- package/esm/lint/mod.js +9 -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/lexicon.d.ts +24 -0
- package/esm/lint/rules/lexicon.d.ts.map +1 -0
- package/esm/lint/rules/lexicon.js +236 -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/struct.d.ts +17 -0
- package/esm/lint/rules/struct.d.ts.map +1 -0
- package/esm/lint/rules/struct.js +55 -0
- package/esm/lint/rules/suppression.d.ts +54 -0
- package/esm/lint/rules/suppression.d.ts.map +1 -0
- package/esm/lint/rules/suppression.js +129 -0
- 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 +59 -0
- package/esm/lint/runner.d.ts.map +1 -0
- package/esm/lint/runner.js +153 -0
- 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 +31 -0
- package/esm/lint/types.d.ts.map +1 -0
- package/esm/lint/types.js +9 -0
- 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 +28 -8
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +23 -4
- package/esm/model/attributes.d.ts +6 -0
- package/esm/model/attributes.d.ts.map +1 -1
- package/esm/model/attributes.js +200 -2
- 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/discriminating_attr.d.ts +33 -0
- package/esm/model/discriminating_attr.d.ts.map +1 -0
- package/esm/model/discriminating_attr.js +74 -0
- package/esm/model/mod.d.ts +267 -14
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/mod.js +99 -3
- package/esm/model/profile.d.ts +102 -27
- package/esm/model/profile.d.ts.map +1 -1
- package/esm/model/source_introspection.d.ts +26 -0
- package/esm/model/source_introspection.d.ts.map +1 -0
- package/esm/model/source_introspection.js +77 -0
- package/esm/model/type_hierarchy.d.ts +51 -0
- package/esm/model/type_hierarchy.d.ts.map +1 -0
- package/esm/model/type_hierarchy.js +126 -0
- package/esm/model/uri_scheme_map.d.ts +21 -0
- package/esm/model/uri_scheme_map.d.ts.map +1 -0
- package/esm/model/uri_scheme_map.js +66 -0
- package/esm/parser/attributes.d.ts.map +1 -1
- package/esm/parser/attributes.js +10 -16
- 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 +51 -0
- package/esm/parser/glossary.d.ts.map +1 -0
- package/esm/parser/glossary.js +219 -0
- package/esm/parser/grammars.d.ts +5 -3
- package/esm/parser/grammars.d.ts.map +1 -1
- package/esm/parser/grammars.js +12 -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 +317 -25
- package/esm/parser/mod.d.ts +5 -0
- package/esm/parser/mod.d.ts.map +1 -1
- package/esm/parser/mod.js +31 -8
- package/esm/parser/source.d.ts +53 -2
- package/esm/parser/source.d.ts.map +1 -1
- package/esm/parser/source.js +158 -68
- 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 +32 -14
- package/esm/profile/colors.js +1 -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/introspect.d.ts +135 -0
- package/esm/profile/introspect.d.ts.map +1 -0
- package/esm/profile/introspect.js +378 -0
- package/esm/profile/load.d.ts +3 -1
- package/esm/profile/load.d.ts.map +1 -1
- package/esm/profile/load.js +91 -5
- package/esm/profile/manifest.d.ts.map +1 -1
- package/esm/profile/manifest.js +512 -90
- package/esm/profile/merge.d.ts.map +1 -1
- package/esm/profile/merge.js +251 -39
- package/esm/profile/mod.d.ts +4 -4
- package/esm/profile/mod.d.ts.map +1 -1
- package/esm/profile/mod.js +7 -2
- package/esm/reporter/mod.js +4 -4
- 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/fence.d.ts +30 -0
- package/esm/util/fence.d.ts.map +1 -0
- package/esm/util/fence.js +40 -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/attributes.d.ts +3 -3
- package/esm/validator/attributes.d.ts.map +1 -1
- package/esm/validator/attributes.js +1 -18
- package/esm/validator/body_blocks.d.ts +38 -0
- package/esm/validator/body_blocks.d.ts.map +1 -0
- package/esm/validator/body_blocks.js +218 -0
- package/esm/validator/caption_convention.d.ts +29 -0
- package/esm/validator/caption_convention.d.ts.map +1 -0
- package/esm/validator/caption_convention.js +58 -0
- package/esm/validator/captions.d.ts +22 -0
- package/esm/validator/captions.d.ts.map +1 -0
- package/esm/validator/captions.js +137 -0
- package/esm/validator/component_schemes.d.ts +73 -0
- package/esm/validator/component_schemes.d.ts.map +1 -0
- package/esm/validator/component_schemes.js +375 -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/feature_ac.d.ts +28 -0
- package/esm/validator/feature_ac.d.ts.map +1 -0
- package/esm/validator/feature_ac.js +102 -0
- package/esm/validator/listing.d.ts +42 -0
- package/esm/validator/listing.d.ts.map +1 -0
- package/esm/validator/listing.js +295 -0
- package/esm/validator/mod.d.ts +3 -1
- package/esm/validator/mod.d.ts.map +1 -1
- package/esm/validator/mod.js +275 -13
- package/esm/validator/modal_keywords.d.ts +25 -0
- package/esm/validator/modal_keywords.d.ts.map +1 -0
- package/esm/validator/modal_keywords.js +54 -0
- 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 +29 -0
- package/esm/validator/per_type_attrs.d.ts.map +1 -0
- package/esm/validator/per_type_attrs.js +75 -0
- package/esm/validator/pipeline.d.ts +18 -2
- package/esm/validator/pipeline.d.ts.map +1 -1
- package/esm/validator/pipeline.js +76 -21
- package/esm/validator/trace_types.d.ts +26 -0
- package/esm/validator/trace_types.d.ts.map +1 -0
- package/esm/validator/trace_types.js +232 -0
- package/esm/validator/traceability.d.ts +3 -4
- package/esm/validator/traceability.d.ts.map +1 -1
- package/esm/validator/traceability.js +5 -10
- package/esm/validator/type_resolution.d.ts +67 -0
- package/esm/validator/type_resolution.d.ts.map +1 -0
- package/esm/validator/type_resolution.js +162 -0
- package/esm/validator/types.d.ts +45 -0
- package/esm/validator/types.d.ts.map +1 -1
- package/esm/validator/types.js +128 -16
- package/esm/validator/value_types.d.ts +8 -0
- package/esm/validator/value_types.d.ts.map +1 -1
- package/esm/validator/value_types.js +8 -1
- package/package.json +2 -2
- package/script/ast/build.d.ts +60 -0
- package/script/ast/build.d.ts.map +1 -0
- package/script/ast/build.js +521 -0
- package/script/ast/equivalence.d.ts +18 -0
- package/script/ast/equivalence.d.ts.map +1 -0
- package/script/ast/equivalence.js +59 -0
- package/script/ast/nodes.d.ts +189 -0
- package/script/ast/nodes.d.ts.map +1 -0
- package/script/ast/nodes.js +18 -0
- package/script/ast/normalize.d.ts +58 -0
- package/script/ast/normalize.d.ts.map +1 -0
- package/script/ast/normalize.js +200 -0
- package/script/ast/render.d.ts +34 -0
- package/script/ast/render.d.ts.map +1 -0
- package/script/ast/render.js +218 -0
- 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 +2 -1
- package/script/compiler/inverses.d.ts.map +1 -1
- package/script/compiler/inverses.js +33 -14
- package/script/compiler/manifest.d.ts +59 -0
- package/script/compiler/manifest.d.ts.map +1 -0
- package/script/compiler/manifest.js +51 -0
- package/script/compiler/mod.d.ts +38 -1
- package/script/compiler/mod.d.ts.map +1 -1
- package/script/compiler/mod.js +206 -54
- package/script/compiler/ndjson_writer.d.ts +50 -0
- package/script/compiler/ndjson_writer.d.ts.map +1 -0
- package/script/compiler/ndjson_writer.js +78 -0
- package/script/compiler/schema.d.ts +33 -1
- package/script/compiler/schema.d.ts.map +1 -1
- package/script/compiler/schema.js +30 -8
- 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/config/mod.d.ts.map +1 -1
- package/script/config/mod.js +54 -0
- package/script/formatter/mod.d.ts +55 -4
- package/script/formatter/mod.d.ts.map +1 -1
- package/script/formatter/mod.js +426 -46
- package/script/formatter/synth_ulid.d.ts +21 -0
- package/script/formatter/synth_ulid.d.ts.map +1 -0
- package/script/formatter/synth_ulid.js +67 -0
- 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 +14 -0
- package/script/lint/mod.d.ts.map +1 -0
- package/script/lint/mod.js +17 -0
- 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/lexicon.d.ts +24 -0
- package/script/lint/rules/lexicon.d.ts.map +1 -0
- package/script/lint/rules/lexicon.js +240 -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/struct.d.ts +17 -0
- package/script/lint/rules/struct.d.ts.map +1 -0
- package/script/lint/rules/struct.js +59 -0
- package/script/lint/rules/suppression.d.ts +54 -0
- package/script/lint/rules/suppression.d.ts.map +1 -0
- package/script/lint/rules/suppression.js +136 -0
- 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 +59 -0
- package/script/lint/runner.d.ts.map +1 -0
- package/script/lint/runner.js +157 -0
- 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 +31 -0
- package/script/lint/types.d.ts.map +1 -0
- package/script/lint/types.js +10 -0
- 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 +28 -8
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +129 -32
- package/script/model/attributes.d.ts +6 -0
- package/script/model/attributes.d.ts.map +1 -1
- package/script/model/attributes.js +201 -3
- 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/discriminating_attr.d.ts +33 -0
- package/script/model/discriminating_attr.d.ts.map +1 -0
- package/script/model/discriminating_attr.js +77 -0
- package/script/model/mod.d.ts +267 -14
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/mod.js +111 -3
- package/script/model/profile.d.ts +102 -27
- package/script/model/profile.d.ts.map +1 -1
- package/script/model/source_introspection.d.ts +26 -0
- package/script/model/source_introspection.d.ts.map +1 -0
- package/script/model/source_introspection.js +80 -0
- package/script/model/type_hierarchy.d.ts +51 -0
- package/script/model/type_hierarchy.d.ts.map +1 -0
- package/script/model/type_hierarchy.js +130 -0
- package/script/model/uri_scheme_map.d.ts +21 -0
- package/script/model/uri_scheme_map.d.ts.map +1 -0
- package/script/model/uri_scheme_map.js +69 -0
- package/script/parser/attributes.d.ts.map +1 -1
- package/script/parser/attributes.js +10 -16
- 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 +51 -0
- package/script/parser/glossary.d.ts.map +1 -0
- package/script/parser/glossary.js +224 -0
- package/script/parser/grammars.d.ts +5 -3
- package/script/parser/grammars.d.ts.map +1 -1
- package/script/parser/grammars.js +15 -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 +315 -23
- package/script/parser/mod.d.ts +5 -0
- package/script/parser/mod.d.ts.map +1 -1
- package/script/parser/mod.js +36 -7
- package/script/parser/source.d.ts +53 -2
- package/script/parser/source.d.ts.map +1 -1
- package/script/parser/source.js +159 -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 +32 -14
- package/script/profile/colors.js +1 -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/introspect.d.ts +135 -0
- package/script/profile/introspect.d.ts.map +1 -0
- package/script/profile/introspect.js +381 -0
- package/script/profile/load.d.ts +3 -1
- package/script/profile/load.d.ts.map +1 -1
- package/script/profile/load.js +91 -5
- package/script/profile/manifest.d.ts.map +1 -1
- package/script/profile/manifest.js +511 -89
- package/script/profile/merge.d.ts.map +1 -1
- package/script/profile/merge.js +251 -39
- package/script/profile/mod.d.ts +4 -4
- package/script/profile/mod.d.ts.map +1 -1
- package/script/profile/mod.js +12 -6
- package/script/reporter/mod.js +4 -4
- 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/fence.d.ts +30 -0
- package/script/util/fence.d.ts.map +1 -0
- package/script/util/fence.js +44 -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/attributes.d.ts +3 -3
- package/script/validator/attributes.d.ts.map +1 -1
- package/script/validator/attributes.js +1 -18
- package/script/validator/body_blocks.d.ts +38 -0
- package/script/validator/body_blocks.d.ts.map +1 -0
- package/script/validator/body_blocks.js +221 -0
- package/script/validator/caption_convention.d.ts +29 -0
- package/script/validator/caption_convention.d.ts.map +1 -0
- package/script/validator/caption_convention.js +61 -0
- package/script/validator/captions.d.ts +22 -0
- package/script/validator/captions.d.ts.map +1 -0
- package/script/validator/captions.js +140 -0
- package/script/validator/component_schemes.d.ts +73 -0
- package/script/validator/component_schemes.d.ts.map +1 -0
- package/script/validator/component_schemes.js +384 -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/feature_ac.d.ts +28 -0
- package/script/validator/feature_ac.d.ts.map +1 -0
- package/script/validator/feature_ac.js +105 -0
- package/script/validator/listing.d.ts +42 -0
- package/script/validator/listing.d.ts.map +1 -0
- package/script/validator/listing.js +298 -0
- package/script/validator/mod.d.ts +3 -1
- package/script/validator/mod.d.ts.map +1 -1
- package/script/validator/mod.js +278 -14
- package/script/validator/modal_keywords.d.ts +25 -0
- package/script/validator/modal_keywords.d.ts.map +1 -0
- package/script/validator/modal_keywords.js +57 -0
- 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 +29 -0
- package/script/validator/per_type_attrs.d.ts.map +1 -0
- package/script/validator/per_type_attrs.js +78 -0
- package/script/validator/pipeline.d.ts +18 -2
- package/script/validator/pipeline.d.ts.map +1 -1
- package/script/validator/pipeline.js +78 -22
- package/script/validator/trace_types.d.ts +26 -0
- package/script/validator/trace_types.d.ts.map +1 -0
- package/script/validator/trace_types.js +235 -0
- package/script/validator/traceability.d.ts +3 -4
- package/script/validator/traceability.d.ts.map +1 -1
- package/script/validator/traceability.js +5 -10
- package/script/validator/type_resolution.d.ts +67 -0
- package/script/validator/type_resolution.d.ts.map +1 -0
- package/script/validator/type_resolution.js +168 -0
- package/script/validator/types.d.ts +45 -0
- package/script/validator/types.d.ts.map +1 -1
- package/script/validator/types.js +131 -16
- package/script/validator/value_types.d.ts +8 -0
- package/script/validator/value_types.d.ts.map +1 -1
- package/script/validator/value_types.js +10 -2
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module typl/diagnostics
|
|
3
|
+
*
|
|
4
|
+
* Diagnostic codes emitted by the typl parser and validator (TYPL-001
|
|
5
|
+
* through TYPL-008). Each code carries a severity and a template; the
|
|
6
|
+
* `typlDiagnostic` helper performs `${var}` substitution.
|
|
7
|
+
*/
|
|
8
|
+
import type { Position } from "./ast.js";
|
|
9
|
+
import type { Severity } from "../model/mod.js";
|
|
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";
|
|
12
|
+
/** Shape of each entry in {@linkcode TYPL_CODES}. */
|
|
13
|
+
export interface TyplCodeEntry {
|
|
14
|
+
readonly severity: Severity;
|
|
15
|
+
readonly template: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A diagnostic emitted by the typl parser.
|
|
19
|
+
*
|
|
20
|
+
* Carries only line/column position because the parser operates on raw
|
|
21
|
+
* typl source strings (extracted from fences, bullets, or inline code
|
|
22
|
+
* spans) without knowing the host file. Surface adapters bridge
|
|
23
|
+
* TyplDiagnostic to the core `Diagnostic` type by attaching the
|
|
24
|
+
* containing file path; see PR 6 in the implementation plan.
|
|
25
|
+
*/
|
|
26
|
+
export interface TyplDiagnostic {
|
|
27
|
+
readonly code: TyplCode;
|
|
28
|
+
readonly severity: Severity;
|
|
29
|
+
readonly message: string;
|
|
30
|
+
readonly position: Position;
|
|
31
|
+
}
|
|
32
|
+
export declare const TYPL_CODES: Record<TyplCode, TyplCodeEntry>;
|
|
33
|
+
/**
|
|
34
|
+
* Construct a typl diagnostic by substituting `${var}` placeholders in the
|
|
35
|
+
* code's template with the supplied params.
|
|
36
|
+
*
|
|
37
|
+
* Note: param keys are not type-checked against the template — a missing
|
|
38
|
+
* key leaves a raw `${key}` placeholder in the message. Compile-time
|
|
39
|
+
* mapping per code is possible with conditional types but is deferred;
|
|
40
|
+
* for now, callers should test message-formatting for each code.
|
|
41
|
+
*/
|
|
42
|
+
export declare function typlDiagnostic(code: TyplCode, params: Record<string, string | number>, position: Position): TyplDiagnostic;
|
|
43
|
+
//# sourceMappingURL=diagnostics.d.ts.map
|
|
@@ -0,0 +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,CAqCtD,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"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TYPL_CODES = void 0;
|
|
4
|
+
exports.typlDiagnostic = typlDiagnostic;
|
|
5
|
+
const ast_js_1 = require("./ast.js");
|
|
6
|
+
/**
|
|
7
|
+
* The explicit-kind list used in TYPL-007 error messages. Derived from
|
|
8
|
+
* `KINDS` (excluding the implicit default "value") so the message stays
|
|
9
|
+
* in sync with the authoritative vocabulary automatically.
|
|
10
|
+
*/
|
|
11
|
+
const EXPLICIT_KIND_LIST = ast_js_1.KINDS.filter((k) => k !== "value").join(", ");
|
|
12
|
+
exports.TYPL_CODES = {
|
|
13
|
+
"TYPL-001": {
|
|
14
|
+
severity: "error",
|
|
15
|
+
template: "Duplicate binding for ${name} in the same entry (first wins, this is a duplicate).",
|
|
16
|
+
},
|
|
17
|
+
"TYPL-002": {
|
|
18
|
+
severity: "error",
|
|
19
|
+
template: "${name} is declared as kind ${kindA} here and ${kindB} in ${otherFile}:${otherLine}.",
|
|
20
|
+
},
|
|
21
|
+
"TYPL-003": {
|
|
22
|
+
severity: "error",
|
|
23
|
+
template: "${name} is declared with a different shape than in ${otherFile}:${otherLine}.",
|
|
24
|
+
},
|
|
25
|
+
"TYPL-004": {
|
|
26
|
+
severity: "error",
|
|
27
|
+
template: "Typedef ${name} is redefined within the same entry.",
|
|
28
|
+
},
|
|
29
|
+
"TYPL-005": {
|
|
30
|
+
severity: "error",
|
|
31
|
+
template: "Reference to undefined typedef ${name}.",
|
|
32
|
+
},
|
|
33
|
+
"TYPL-006": {
|
|
34
|
+
severity: "error",
|
|
35
|
+
template: "Malformed schema: ${detail}.",
|
|
36
|
+
},
|
|
37
|
+
"TYPL-007": {
|
|
38
|
+
severity: "error",
|
|
39
|
+
template: `Unknown kind keyword \${keyword}. Expected one of: ${EXPLICIT_KIND_LIST}.`,
|
|
40
|
+
},
|
|
41
|
+
"TYPL-008": {
|
|
42
|
+
severity: "error",
|
|
43
|
+
template: "Literal ${value} violates declared ${constraint} (${detail}).",
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Construct a typl diagnostic by substituting `${var}` placeholders in the
|
|
48
|
+
* code's template with the supplied params.
|
|
49
|
+
*
|
|
50
|
+
* Note: param keys are not type-checked against the template — a missing
|
|
51
|
+
* key leaves a raw `${key}` placeholder in the message. Compile-time
|
|
52
|
+
* mapping per code is possible with conditional types but is deferred;
|
|
53
|
+
* for now, callers should test message-formatting for each code.
|
|
54
|
+
*/
|
|
55
|
+
function typlDiagnostic(code, params, position) {
|
|
56
|
+
const entry = exports.TYPL_CODES[code];
|
|
57
|
+
if (!entry) {
|
|
58
|
+
throw new Error(`Unknown TYPL code: ${code}`);
|
|
59
|
+
}
|
|
60
|
+
let message = entry.template;
|
|
61
|
+
for (const [k, v] of Object.entries(params)) {
|
|
62
|
+
message = message.replaceAll(`\${${k}}`, String(v));
|
|
63
|
+
}
|
|
64
|
+
return { code, severity: entry.severity, message, position };
|
|
65
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module typl/fence
|
|
3
|
+
*
|
|
4
|
+
* Fence surface adapter — extracts typl source from fenced code blocks
|
|
5
|
+
* whose info-string is "typl". Operates on the canonical body AST
|
|
6
|
+
* (BodyBlock[]) produced by core/ast/build.ts.
|
|
7
|
+
*
|
|
8
|
+
* This module is parser-side only — it returns the raw typl source and
|
|
9
|
+
* its source range. PR 3 will wire the extracted source through
|
|
10
|
+
* parseTyplBlock and attach results to Entry.types.
|
|
11
|
+
*/
|
|
12
|
+
import type { BodyBlock, SourceRange } from "../ast/nodes.js";
|
|
13
|
+
/** A single typl fence found inside a body. */
|
|
14
|
+
export interface TyplFenceExtraction {
|
|
15
|
+
/** The verbatim typl source from inside the fence (CodeNode.text). */
|
|
16
|
+
readonly source: string;
|
|
17
|
+
/** Source range of the whole fence (opening ``` through closing ```). */
|
|
18
|
+
readonly range: SourceRange;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Walk a body AST and return every typl fence found. Recurses into
|
|
22
|
+
* container nodes (ListNode via ListItemNode.blocks) so typl fences
|
|
23
|
+
* nested inside list items are discovered.
|
|
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).
|
|
29
|
+
*/
|
|
30
|
+
export declare function extractTyplFences(blocks: readonly BodyBlock[]): readonly TyplFenceExtraction[];
|
|
31
|
+
//# sourceMappingURL=fence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fence.d.ts","sourceRoot":"","sources":["../../src/typl/fence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9D,+CAA+C;AAC/C,MAAM,WAAW,mBAAmB;IAClC,sEAAsE;IACtE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,yEAAyE;IACzE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC7B;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,SAAS,EAAE,GAC3B,SAAS,mBAAmB,EAAE,CAYhC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractTyplFences = extractTyplFences;
|
|
4
|
+
/**
|
|
5
|
+
* Walk a body AST and return every typl fence found. Recurses into
|
|
6
|
+
* container nodes (ListNode via ListItemNode.blocks) so typl fences
|
|
7
|
+
* nested inside list items are discovered.
|
|
8
|
+
*
|
|
9
|
+
* BlockquoteNode and NoteNode carry only InlineContent (not nested
|
|
10
|
+
* BodyBlock[]), so they are not recursed into.
|
|
11
|
+
*
|
|
12
|
+
* Returns fences in source order (depth-first traversal).
|
|
13
|
+
*/
|
|
14
|
+
function extractTyplFences(blocks) {
|
|
15
|
+
const results = [];
|
|
16
|
+
for (const block of blocks) {
|
|
17
|
+
if (block.kind === "code" && block.lang === "typl") {
|
|
18
|
+
results.push({ source: block.text, range: block.range });
|
|
19
|
+
}
|
|
20
|
+
else if (block.kind === "list") {
|
|
21
|
+
for (const item of block.items) {
|
|
22
|
+
results.push(...extractTyplFences(item.blocks));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return results;
|
|
27
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module typl/grammar
|
|
3
|
+
*
|
|
4
|
+
* Statement-level parser for the typl DSL. Converts a flat `Token[]`
|
|
5
|
+
* stream (from the lexer) into a `TyplBlock` AST containing `Binding[]`
|
|
6
|
+
* and `Typedef[]` statements.
|
|
7
|
+
*/
|
|
8
|
+
import { type TyplBlock } from "./ast.js";
|
|
9
|
+
import { type TyplDiagnostic } from "./diagnostics.js";
|
|
10
|
+
/**
|
|
11
|
+
* Parse a typl source block into a `TyplBlock` AST.
|
|
12
|
+
*
|
|
13
|
+
* @param source - Raw typl text (may be multi-line).
|
|
14
|
+
* @returns Parsed AST and any diagnostics emitted during parsing.
|
|
15
|
+
*/
|
|
16
|
+
export declare function parseTyplBlock(source: string): {
|
|
17
|
+
ast: TyplBlock;
|
|
18
|
+
diagnostics: readonly TyplDiagnostic[];
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=grammar.d.ts.map
|
|
@@ -0,0 +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;AAufvE;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,GACb;IAAE,GAAG,EAAE,SAAS,CAAC;IAAC,WAAW,EAAE,SAAS,cAAc,EAAE,CAAA;CAAE,CAK5D"}
|
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module typl/grammar
|
|
4
|
+
*
|
|
5
|
+
* Statement-level parser for the typl DSL. Converts a flat `Token[]`
|
|
6
|
+
* stream (from the lexer) into a `TyplBlock` AST containing `Binding[]`
|
|
7
|
+
* and `Typedef[]` statements.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.parseTyplBlock = parseTyplBlock;
|
|
11
|
+
const ast_js_1 = require("./ast.js");
|
|
12
|
+
const diagnostics_js_1 = require("./diagnostics.js");
|
|
13
|
+
const lexer_js_1 = require("./lexer.js");
|
|
14
|
+
/** Fast set of valid kind keywords (excluding "value" which is the implicit default). */
|
|
15
|
+
const KIND_NAMES = new Set(ast_js_1.KINDS);
|
|
16
|
+
/**
|
|
17
|
+
* Lowercase primitive type names. Used in the kind-detection heuristic to
|
|
18
|
+
* distinguish a primitive type token from an unknown kind keyword.
|
|
19
|
+
*/
|
|
20
|
+
const PRIMITIVE_NAMES = new Set([
|
|
21
|
+
"int",
|
|
22
|
+
"float",
|
|
23
|
+
"bool",
|
|
24
|
+
"string",
|
|
25
|
+
"bytes",
|
|
26
|
+
]);
|
|
27
|
+
/** Recursive-descent parser for a typl source block. */
|
|
28
|
+
class Parser {
|
|
29
|
+
constructor(tokens) {
|
|
30
|
+
Object.defineProperty(this, "tokens", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
configurable: true,
|
|
33
|
+
writable: true,
|
|
34
|
+
value: tokens
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(this, "i", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
configurable: true,
|
|
39
|
+
writable: true,
|
|
40
|
+
value: 0
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(this, "diagnostics", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
configurable: true,
|
|
45
|
+
writable: true,
|
|
46
|
+
value: []
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
parseBlock() {
|
|
50
|
+
const bindings = [];
|
|
51
|
+
const typedefs = [];
|
|
52
|
+
const seenBindingNames = new Set();
|
|
53
|
+
const seenTypedefNames = new Set();
|
|
54
|
+
while (this.peek().kind !== "EOF") {
|
|
55
|
+
const lineBefore = this.peek().position.line;
|
|
56
|
+
const stmt = this.parseStatement();
|
|
57
|
+
if (stmt) {
|
|
58
|
+
if (stmt.statementKind === "binding") {
|
|
59
|
+
if (seenBindingNames.has(stmt.name)) {
|
|
60
|
+
this.diagnostics.push((0, diagnostics_js_1.typlDiagnostic)("TYPL-001", { name: stmt.name }, stmt.position));
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
seenBindingNames.add(stmt.name);
|
|
64
|
+
bindings.push(stmt);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
if (seenTypedefNames.has(stmt.name)) {
|
|
69
|
+
this.diagnostics.push((0, diagnostics_js_1.typlDiagnostic)("TYPL-004", { name: stmt.name }, stmt.position));
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
seenTypedefNames.add(stmt.name);
|
|
73
|
+
typedefs.push(stmt);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// Only skip remaining tokens on the same line. If the cursor has
|
|
78
|
+
// already advanced past lineBefore (parseStatement consumed the whole
|
|
79
|
+
// line), we're already at the next statement — don't eat into it.
|
|
80
|
+
if (this.peek().kind !== "EOF" &&
|
|
81
|
+
this.peek().position.line === lineBefore) {
|
|
82
|
+
this.skipToNextLine();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return { ast: { bindings, typedefs }, diagnostics: this.diagnostics };
|
|
86
|
+
}
|
|
87
|
+
parseStatement() {
|
|
88
|
+
const t = this.peek();
|
|
89
|
+
if (t.kind === "COMMENT") {
|
|
90
|
+
this.advance();
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
if (t.kind === "DOLLAR_IDENT")
|
|
94
|
+
return this.parseBinding();
|
|
95
|
+
if (t.kind === "TYPE")
|
|
96
|
+
return this.parseTypedef();
|
|
97
|
+
this.diagnostics.push((0, diagnostics_js_1.typlDiagnostic)("TYPL-006", { detail: `unexpected token ${t.kind}` }, t.position));
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
parseBinding() {
|
|
101
|
+
const nameTok = this.expect("DOLLAR_IDENT");
|
|
102
|
+
if (!nameTok)
|
|
103
|
+
return undefined;
|
|
104
|
+
if (!this.expect("COLON"))
|
|
105
|
+
return undefined;
|
|
106
|
+
const next = this.peek();
|
|
107
|
+
let kind = "value";
|
|
108
|
+
if (next.kind === "IDENT") {
|
|
109
|
+
if (KIND_NAMES.has(next.value)) {
|
|
110
|
+
// Known kind keyword — consume and record.
|
|
111
|
+
kind = next.value;
|
|
112
|
+
this.advance();
|
|
113
|
+
}
|
|
114
|
+
else if (!PRIMITIVE_NAMES.has(next.value)) {
|
|
115
|
+
// Not a primitive. Apply the heuristic: lowercase-starting tokens
|
|
116
|
+
// that are not known primitives are likely mistyped kind keywords.
|
|
117
|
+
// PascalCase tokens are typedef references and are left for the
|
|
118
|
+
// shape parser.
|
|
119
|
+
const firstChar = next.value[0];
|
|
120
|
+
if (firstChar >= "a" && firstChar <= "z") {
|
|
121
|
+
// Lowercase non-primitive non-kind → likely a typo on a kind keyword.
|
|
122
|
+
// _-prefixed identifiers are typedef references, not kind keywords.
|
|
123
|
+
this.diagnostics.push((0, diagnostics_js_1.typlDiagnostic)("TYPL-007", { keyword: next.value }, next.position));
|
|
124
|
+
// Consume the bad keyword so the shape parser does not trip on it.
|
|
125
|
+
this.advance();
|
|
126
|
+
}
|
|
127
|
+
// PascalCase or _-prefixed identifier: typedef ref — leave for parseShapeOptional.
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const shape = this.parseShapeOptional();
|
|
131
|
+
return {
|
|
132
|
+
statementKind: "binding",
|
|
133
|
+
name: nameTok.value,
|
|
134
|
+
kind,
|
|
135
|
+
shape,
|
|
136
|
+
position: nameTok.position,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
parseTypedef() {
|
|
140
|
+
const typeTok = this.expect("TYPE");
|
|
141
|
+
if (!typeTok)
|
|
142
|
+
return undefined;
|
|
143
|
+
const nameTok = this.expect("IDENT");
|
|
144
|
+
if (!nameTok)
|
|
145
|
+
return undefined;
|
|
146
|
+
if (!this.expect("EQUALS"))
|
|
147
|
+
return undefined;
|
|
148
|
+
const shape = this.parseShape();
|
|
149
|
+
if (!shape)
|
|
150
|
+
return undefined;
|
|
151
|
+
return {
|
|
152
|
+
statementKind: "typedef",
|
|
153
|
+
name: nameTok.value,
|
|
154
|
+
shape,
|
|
155
|
+
position: typeTok.position,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
// -----------------------------------------------------------------------
|
|
159
|
+
// Shape parsing
|
|
160
|
+
// -----------------------------------------------------------------------
|
|
161
|
+
/**
|
|
162
|
+
* Parse an optional shape expression. Returns `undefined` when no shape
|
|
163
|
+
* token follows (e.g. `$Idle : state` with no payload).
|
|
164
|
+
*/
|
|
165
|
+
parseShapeOptional() {
|
|
166
|
+
if (this.peek().kind === "EOF" || this.peek().kind === "COMMENT") {
|
|
167
|
+
return undefined;
|
|
168
|
+
}
|
|
169
|
+
return this.parseShape();
|
|
170
|
+
}
|
|
171
|
+
/** Parse a mandatory shape expression. Returns `undefined` when absent. */
|
|
172
|
+
parseShape() {
|
|
173
|
+
const base = this.parsePrimary();
|
|
174
|
+
if (!base)
|
|
175
|
+
return undefined;
|
|
176
|
+
return this.wrapArrayOrOptional(base);
|
|
177
|
+
}
|
|
178
|
+
parsePrimary() {
|
|
179
|
+
const t = this.peek();
|
|
180
|
+
// Pattern
|
|
181
|
+
if (t.kind === "REGEX") {
|
|
182
|
+
this.advance();
|
|
183
|
+
const flagsTok = this.peek().kind === "REGEX_FLAGS"
|
|
184
|
+
? this.advance()
|
|
185
|
+
: undefined;
|
|
186
|
+
return flagsTok
|
|
187
|
+
? { kind: "pattern", regex: t.value, flags: flagsTok.value }
|
|
188
|
+
: { kind: "pattern", regex: t.value };
|
|
189
|
+
}
|
|
190
|
+
// Record
|
|
191
|
+
if (t.kind === "LBRACE")
|
|
192
|
+
return this.parseRecord();
|
|
193
|
+
// Enum (literal followed by PIPE) — also handles a single literal
|
|
194
|
+
if (t.kind === "STRING" || t.kind === "NUMBER" || t.kind === "BOOL") {
|
|
195
|
+
return this.parseEnumOrLiteral();
|
|
196
|
+
}
|
|
197
|
+
// Primitive | typedef ref
|
|
198
|
+
if (t.kind === "IDENT") {
|
|
199
|
+
const name = t.value;
|
|
200
|
+
if (["int", "float"].includes(name)) {
|
|
201
|
+
this.advance();
|
|
202
|
+
if (this.peek().kind === "LBRACKET") {
|
|
203
|
+
// `[]` empty brackets → array (never a range). Leave for wrapArrayOrOptional.
|
|
204
|
+
// For float, `[N]` (no DOTDOT) is also an array-exact. Leave for wrapper.
|
|
205
|
+
// For int, `[N]` (no DOTDOT) is a range-exact → enter parseRangeBody.
|
|
206
|
+
const isEmpty = this.tokens[this.i + 1]?.kind === "RBRACKET";
|
|
207
|
+
const hasDotDot = this.bracketHasDotDot();
|
|
208
|
+
if (!isEmpty && (name === "int" || hasDotDot)) {
|
|
209
|
+
return this.parseRangeBody(name);
|
|
210
|
+
}
|
|
211
|
+
// Otherwise leave `[…]` for wrapArrayOrOptional.
|
|
212
|
+
}
|
|
213
|
+
return { kind: "primitive", type: name };
|
|
214
|
+
}
|
|
215
|
+
if (["string", "bytes"].includes(name)) {
|
|
216
|
+
this.advance();
|
|
217
|
+
if (this.peek().kind === "LBRACKET") {
|
|
218
|
+
// `[]` empty brackets → array (never a length). Leave for wrapArrayOrOptional.
|
|
219
|
+
// `[N]` single number → length exact → enter parseLengthBody.
|
|
220
|
+
// `[N..M]` range form → length range → enter parseLengthBody.
|
|
221
|
+
const isEmpty = this.tokens[this.i + 1]?.kind === "RBRACKET";
|
|
222
|
+
const hasDotDot = this.bracketHasDotDot();
|
|
223
|
+
if (!isEmpty &&
|
|
224
|
+
(hasDotDot || this.tokens[this.i + 1]?.kind === "NUMBER")) {
|
|
225
|
+
return this.parseLengthBody(name);
|
|
226
|
+
}
|
|
227
|
+
// Otherwise (empty `[]`) leave for wrapArrayOrOptional.
|
|
228
|
+
}
|
|
229
|
+
return { kind: "primitive", type: name };
|
|
230
|
+
}
|
|
231
|
+
if (name === "bool") {
|
|
232
|
+
this.advance();
|
|
233
|
+
return { kind: "primitive", type: "bool" };
|
|
234
|
+
}
|
|
235
|
+
this.advance();
|
|
236
|
+
return { kind: "ref", name };
|
|
237
|
+
}
|
|
238
|
+
return undefined;
|
|
239
|
+
}
|
|
240
|
+
parseRangeBody(type) {
|
|
241
|
+
if (!this.expect("LBRACKET"))
|
|
242
|
+
return undefined;
|
|
243
|
+
const first = this.peek();
|
|
244
|
+
if (first.kind === "NUMBER" && this.tokens[this.i + 1].kind === "RBRACKET") {
|
|
245
|
+
const n = Number(this.advance().value);
|
|
246
|
+
this.expect("RBRACKET");
|
|
247
|
+
return { kind: "range", type, exact: n };
|
|
248
|
+
}
|
|
249
|
+
let min;
|
|
250
|
+
let max;
|
|
251
|
+
if (this.peek().kind === "NUMBER")
|
|
252
|
+
min = Number(this.advance().value);
|
|
253
|
+
if (this.peek().kind !== "DOTDOT") {
|
|
254
|
+
this.diagnostics.push((0, diagnostics_js_1.typlDiagnostic)("TYPL-006", { detail: "expected '..'" }, this.peek().position));
|
|
255
|
+
return undefined;
|
|
256
|
+
}
|
|
257
|
+
this.advance();
|
|
258
|
+
if (this.peek().kind === "NUMBER")
|
|
259
|
+
max = Number(this.advance().value);
|
|
260
|
+
if (!this.expect("RBRACKET"))
|
|
261
|
+
return undefined;
|
|
262
|
+
if (type === "int") {
|
|
263
|
+
if (min !== undefined && !Number.isInteger(min)) {
|
|
264
|
+
this.diagnostics.push((0, diagnostics_js_1.typlDiagnostic)("TYPL-008", {
|
|
265
|
+
value: min,
|
|
266
|
+
constraint: "int range",
|
|
267
|
+
detail: "non-integer literal",
|
|
268
|
+
}, first.position));
|
|
269
|
+
}
|
|
270
|
+
if (max !== undefined && !Number.isInteger(max)) {
|
|
271
|
+
this.diagnostics.push((0, diagnostics_js_1.typlDiagnostic)("TYPL-008", {
|
|
272
|
+
value: max,
|
|
273
|
+
constraint: "int range",
|
|
274
|
+
detail: "non-integer literal",
|
|
275
|
+
}, first.position));
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return {
|
|
279
|
+
kind: "range",
|
|
280
|
+
type,
|
|
281
|
+
...(min !== undefined ? { min } : {}),
|
|
282
|
+
...(max !== undefined ? { max } : {}),
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
parseLengthBody(type) {
|
|
286
|
+
if (!this.expect("LBRACKET"))
|
|
287
|
+
return undefined;
|
|
288
|
+
if (this.peek().kind === "NUMBER" &&
|
|
289
|
+
this.tokens[this.i + 1].kind === "RBRACKET") {
|
|
290
|
+
const exact = Number(this.advance().value);
|
|
291
|
+
this.expect("RBRACKET");
|
|
292
|
+
return { kind: "length", type, exact };
|
|
293
|
+
}
|
|
294
|
+
let min;
|
|
295
|
+
let max;
|
|
296
|
+
if (this.peek().kind === "NUMBER")
|
|
297
|
+
min = Number(this.advance().value);
|
|
298
|
+
if (this.peek().kind !== "DOTDOT") {
|
|
299
|
+
this.diagnostics.push((0, diagnostics_js_1.typlDiagnostic)("TYPL-006", { detail: "expected '..'" }, this.peek().position));
|
|
300
|
+
return undefined;
|
|
301
|
+
}
|
|
302
|
+
this.advance();
|
|
303
|
+
if (this.peek().kind === "NUMBER")
|
|
304
|
+
max = Number(this.advance().value);
|
|
305
|
+
if (!this.expect("RBRACKET"))
|
|
306
|
+
return undefined;
|
|
307
|
+
return {
|
|
308
|
+
kind: "length",
|
|
309
|
+
type,
|
|
310
|
+
...(min !== undefined ? { min } : {}),
|
|
311
|
+
...(max !== undefined ? { max } : {}),
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
parseRecord() {
|
|
315
|
+
if (!this.expect("LBRACE"))
|
|
316
|
+
return undefined;
|
|
317
|
+
const fields = {};
|
|
318
|
+
while (this.peek().kind !== "RBRACE" && this.peek().kind !== "EOF") {
|
|
319
|
+
const nameTok = this.expect("IDENT");
|
|
320
|
+
if (!nameTok)
|
|
321
|
+
break;
|
|
322
|
+
// shorthand `{ a, b }` => fields with ref to typedef of same name
|
|
323
|
+
if (this.peek().kind === "COMMA" || this.peek().kind === "RBRACE") {
|
|
324
|
+
fields[nameTok.value] = { kind: "ref", name: nameTok.value };
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
if (!this.expect("COLON"))
|
|
328
|
+
break;
|
|
329
|
+
const fieldShape = this.parseShape();
|
|
330
|
+
if (!fieldShape)
|
|
331
|
+
break;
|
|
332
|
+
fields[nameTok.value] = fieldShape;
|
|
333
|
+
}
|
|
334
|
+
if (this.peek().kind === "COMMA")
|
|
335
|
+
this.advance();
|
|
336
|
+
}
|
|
337
|
+
this.expect("RBRACE");
|
|
338
|
+
return { kind: "record", fields };
|
|
339
|
+
}
|
|
340
|
+
parseEnumOrLiteral() {
|
|
341
|
+
const values = [];
|
|
342
|
+
const t = this.advance();
|
|
343
|
+
values.push(this.literalValue(t));
|
|
344
|
+
while (this.peek().kind === "PIPE") {
|
|
345
|
+
this.advance();
|
|
346
|
+
const next = this.peek();
|
|
347
|
+
if (next.kind !== "STRING" && next.kind !== "NUMBER" &&
|
|
348
|
+
next.kind !== "BOOL") {
|
|
349
|
+
this.diagnostics.push((0, diagnostics_js_1.typlDiagnostic)("TYPL-006", { detail: "expected literal after '|'" }, next.position));
|
|
350
|
+
break;
|
|
351
|
+
}
|
|
352
|
+
values.push(this.literalValue(this.advance()));
|
|
353
|
+
}
|
|
354
|
+
if (values.length === 1)
|
|
355
|
+
return { kind: "literal", value: values[0] };
|
|
356
|
+
return { kind: "enum", values };
|
|
357
|
+
}
|
|
358
|
+
literalValue(t) {
|
|
359
|
+
if (t.kind === "STRING")
|
|
360
|
+
return t.value;
|
|
361
|
+
if (t.kind === "BOOL")
|
|
362
|
+
return t.value === "true";
|
|
363
|
+
return Number(t.value);
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Lookahead: does the upcoming `[…]` bracket contain a DOTDOT token?
|
|
367
|
+
* Used to disambiguate `float[4]` (array-exact) from `float[0..300]` (range).
|
|
368
|
+
* Scans forward from `i+1` (the token after LBRACKET) without consuming.
|
|
369
|
+
*/
|
|
370
|
+
bracketHasDotDot() {
|
|
371
|
+
let j = this.i + 1; // skip over the LBRACKET itself (not yet consumed here)
|
|
372
|
+
while (j < this.tokens.length) {
|
|
373
|
+
const k = this.tokens[j].kind;
|
|
374
|
+
if (k === "RBRACKET" || k === "EOF")
|
|
375
|
+
return false;
|
|
376
|
+
if (k === "DOTDOT")
|
|
377
|
+
return true;
|
|
378
|
+
j++;
|
|
379
|
+
}
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
wrapArrayOrOptional(base) {
|
|
383
|
+
let s = base;
|
|
384
|
+
while (true) {
|
|
385
|
+
if (this.peek().kind === "LBRACKET") {
|
|
386
|
+
this.advance();
|
|
387
|
+
if (this.peek().kind === "RBRACKET") {
|
|
388
|
+
this.advance();
|
|
389
|
+
s = { kind: "array", element: s };
|
|
390
|
+
if (this.peek().kind === "LPAREN") {
|
|
391
|
+
this.advance();
|
|
392
|
+
let min;
|
|
393
|
+
let max;
|
|
394
|
+
if (this.peek().kind === "NUMBER") {
|
|
395
|
+
min = Number(this.advance().value);
|
|
396
|
+
}
|
|
397
|
+
if (this.peek().kind === "DOTDOT") {
|
|
398
|
+
this.advance();
|
|
399
|
+
if (this.peek().kind === "NUMBER") {
|
|
400
|
+
max = Number(this.advance().value);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
this.expect("RPAREN");
|
|
404
|
+
const arr = s;
|
|
405
|
+
if (min !== undefined)
|
|
406
|
+
arr.min = min;
|
|
407
|
+
if (max !== undefined)
|
|
408
|
+
arr.max = max;
|
|
409
|
+
s = arr;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
else if (this.peek().kind === "NUMBER") {
|
|
413
|
+
const exact = Number(this.advance().value);
|
|
414
|
+
this.expect("RBRACKET");
|
|
415
|
+
s = { kind: "array", element: s, exact };
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
this.diagnostics.push((0, diagnostics_js_1.typlDiagnostic)("TYPL-006", { detail: `unexpected token ${this.peek().kind} inside '['` }, this.peek().position));
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
else if (this.peek().kind === "QUESTION") {
|
|
423
|
+
this.advance();
|
|
424
|
+
s = { kind: "optional", inner: s };
|
|
425
|
+
}
|
|
426
|
+
else {
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
return s;
|
|
431
|
+
}
|
|
432
|
+
// -----------------------------------------------------------------------
|
|
433
|
+
// Low-level helpers
|
|
434
|
+
// -----------------------------------------------------------------------
|
|
435
|
+
peek() {
|
|
436
|
+
return this.tokens[this.i];
|
|
437
|
+
}
|
|
438
|
+
advance() {
|
|
439
|
+
return this.tokens[this.i++];
|
|
440
|
+
}
|
|
441
|
+
expect(kind) {
|
|
442
|
+
const t = this.peek();
|
|
443
|
+
if (t.kind !== kind) {
|
|
444
|
+
this.diagnostics.push((0, diagnostics_js_1.typlDiagnostic)("TYPL-006", { detail: `expected ${kind} but got ${t.kind}` }, t.position));
|
|
445
|
+
return undefined;
|
|
446
|
+
}
|
|
447
|
+
return this.advance();
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Advance past all remaining tokens on the current line so that a parse
|
|
451
|
+
* error on one statement does not cascade into the next. Stops at the
|
|
452
|
+
* first token whose line number is greater than the current peek's line,
|
|
453
|
+
* or at EOF.
|
|
454
|
+
*/
|
|
455
|
+
skipToNextLine() {
|
|
456
|
+
const startLine = this.peek().position.line;
|
|
457
|
+
while (this.peek().kind !== "EOF" &&
|
|
458
|
+
this.peek().position.line === startLine) {
|
|
459
|
+
this.advance();
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Parse a typl source block into a `TyplBlock` AST.
|
|
465
|
+
*
|
|
466
|
+
* @param source - Raw typl text (may be multi-line).
|
|
467
|
+
* @returns Parsed AST and any diagnostics emitted during parsing.
|
|
468
|
+
*/
|
|
469
|
+
function parseTyplBlock(source) {
|
|
470
|
+
const { tokens, diagnostics: lexDiagnostics } = (0, lexer_js_1.tokenize)(source);
|
|
471
|
+
const { ast, diagnostics: parseDiagnostics } = new Parser(tokens)
|
|
472
|
+
.parseBlock();
|
|
473
|
+
return { ast, diagnostics: [...lexDiagnostics, ...parseDiagnostics] };
|
|
474
|
+
}
|