@mpeggroup/mpeg-sdl-parser 4.0.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/LICENSE +21 -0
- package/README.md +337 -0
- package/bun.lock +65 -0
- package/dist/index.js +11829 -0
- package/grammar/sdl.ebnf.grammar +399 -0
- package/grammar/sdl.lezer.grammar +629 -0
- package/index.ts +83 -0
- package/package.json +61 -0
- package/src/analyser/checks/check-array-definition.ts +90 -0
- package/src/analyser/checks/check-array-element-access.ts +31 -0
- package/src/analyser/checks/check-class-declaration.ts +417 -0
- package/src/analyser/checks/check-computed-array-definition.ts +44 -0
- package/src/analyser/checks/check-computed-elementary-type-definition.ts +45 -0
- package/src/analyser/checks/check-elementary-type-definition.ts +167 -0
- package/src/analyser/checks/check-expression-binary.ts +242 -0
- package/src/analyser/checks/check-expression-lengthof.ts +34 -0
- package/src/analyser/checks/check-expression-unary.ts +166 -0
- package/src/analyser/checks/check-identifier.ts +71 -0
- package/src/analyser/checks/check-if-statement.ts +164 -0
- package/src/analyser/checks/check-map-declaration.ts +180 -0
- package/src/analyser/checks/check-map-definition.ts +118 -0
- package/src/analyser/checks/check-number-literal-float.ts +28 -0
- package/src/analyser/checks/check-parameter-list.ts +42 -0
- package/src/analyser/checks/check-specification.ts +53 -0
- package/src/analyser/checks/check-switch-statement.ts +206 -0
- package/src/analyser/checks/check.ts +20 -0
- package/src/analyser/create-sdl-analyser.ts +85 -0
- package/src/analyser/node-handler/abstract-analysis-node-handler.ts +626 -0
- package/src/analyser/node-handler/build-symbol-table-node-handler.ts +649 -0
- package/src/analyser/node-handler/specific-check-node-handler.ts +46 -0
- package/src/analyser/node-handler/validate-scope-node-handler.ts +290 -0
- package/src/analyser/node-handler/validate-type-node-handler.ts +497 -0
- package/src/analyser/sdl-analyser.ts +119 -0
- package/src/analyser/symbol-table.ts +388 -0
- package/src/analyser/util/symbol-table-utils.ts +458 -0
- package/src/analyser/util/type-utils.ts +238 -0
- package/src/ast/build/consume/consume-abstract-node.ts +199 -0
- package/src/ast/build/consume/consume-ast-node.ts +400 -0
- package/src/ast/build/consume/consume-primitive.ts +59 -0
- package/src/ast/build/consume/consume-trivia.ts +96 -0
- package/src/ast/build/consume/consume-white-space-and-missing-errors.ts +27 -0
- package/src/ast/build/node/build-aggregate-output-value.ts +57 -0
- package/src/ast/build/node/build-aligned-modifier.ts +99 -0
- package/src/ast/build/node/build-array-definition.ts +131 -0
- package/src/ast/build/node/build-array-element-access.ts +45 -0
- package/src/ast/build/node/build-base64-string-literal.ts +41 -0
- package/src/ast/build/node/build-binary-expression.ts +113 -0
- package/src/ast/build/node/build-binary-literal.ts +37 -0
- package/src/ast/build/node/build-bit-modifier.ts +86 -0
- package/src/ast/build/node/build-case-clause.ts +101 -0
- package/src/ast/build/node/build-class-declaration.ts +124 -0
- package/src/ast/build/node/build-class-definition.ts +56 -0
- package/src/ast/build/node/build-class-id-range.ts +32 -0
- package/src/ast/build/node/build-class-id.ts +19 -0
- package/src/ast/build/node/build-class-member-access.ts +27 -0
- package/src/ast/build/node/build-compound-statement.ts +33 -0
- package/src/ast/build/node/build-computed-array-definition.ts +53 -0
- package/src/ast/build/node/build-computed-elementary-type-definition.ts +100 -0
- package/src/ast/build/node/build-decimal-literal.ts +15 -0
- package/src/ast/build/node/build-default-clause.ts +76 -0
- package/src/ast/build/node/build-do-statement.ts +71 -0
- package/src/ast/build/node/build-elementary-type-definition.ts +164 -0
- package/src/ast/build/node/build-elementary-type-output-value.ts +25 -0
- package/src/ast/build/node/build-elementary-type.ts +36 -0
- package/src/ast/build/node/build-expandable-modifier.ts +68 -0
- package/src/ast/build/node/build-explicit-array-dimension.ts +37 -0
- package/src/ast/build/node/build-expression-statement.ts +31 -0
- package/src/ast/build/node/build-extended-class-id-range.ts +27 -0
- package/src/ast/build/node/build-extends-modifier.ts +41 -0
- package/src/ast/build/node/build-floating-point-literal.ts +15 -0
- package/src/ast/build/node/build-for-statement.ts +117 -0
- package/src/ast/build/node/build-hexadecimal-literal.ts +38 -0
- package/src/ast/build/node/build-identifier.ts +8 -0
- package/src/ast/build/node/build-if-statement.ts +82 -0
- package/src/ast/build/node/build-implicit-array-dimension.ts +78 -0
- package/src/ast/build/node/build-integer-literal.ts +15 -0
- package/src/ast/build/node/build-length-attribute.ts +48 -0
- package/src/ast/build/node/build-lengthof-expression.ts +45 -0
- package/src/ast/build/node/build-map-declaration.ts +110 -0
- package/src/ast/build/node/build-map-definition.ts +103 -0
- package/src/ast/build/node/build-map-entry.ts +33 -0
- package/src/ast/build/node/build-missing-error.ts +10 -0
- package/src/ast/build/node/build-multiple-character-literal.ts +65 -0
- package/src/ast/build/node/build-parameter-list.ts +50 -0
- package/src/ast/build/node/build-parameter-value-list.ts +54 -0
- package/src/ast/build/node/build-parameter.ts +47 -0
- package/src/ast/build/node/build-partial-array-dimension.ts +55 -0
- package/src/ast/build/node/build-specification.ts +24 -0
- package/src/ast/build/node/build-string-definition.ts +106 -0
- package/src/ast/build/node/build-switch-statement.ts +84 -0
- package/src/ast/build/node/build-token.ts +26 -0
- package/src/ast/build/node/build-unary-expression.ts +109 -0
- package/src/ast/build/node/build-unexpected-error.ts +14 -0
- package/src/ast/build/node/build-utf-string-literal.ts +110 -0
- package/src/ast/build/node/build-while-statement.ts +55 -0
- package/src/ast/build/util/array-dimension-kind-by-token-type-id-map.ts +167 -0
- package/src/ast/build/util/binary-operator-kind-by-token-type-id-map.ts +152 -0
- package/src/ast/build/util/build-context.ts +36 -0
- package/src/ast/build/util/class-id-kind-by-token-type-id-map.ts +160 -0
- package/src/ast/build/util/expression-kind-by-token-type-id-map.ts +168 -0
- package/src/ast/build/util/fetch-node.ts +433 -0
- package/src/ast/build/util/node-kind-by-token-type-id-map.ts +202 -0
- package/src/ast/build/util/statement-kind-by-token-type-id-map.ts +210 -0
- package/src/ast/build/util/string-literal-kind-by-token-type-id-map.ts +162 -0
- package/src/ast/build/util/token-kind-by-token-type-id-map.ts +337 -0
- package/src/ast/build-ast.ts +114 -0
- package/src/ast/node/abstract-array-definition.ts +17 -0
- package/src/ast/node/abstract-array-dimension.ts +20 -0
- package/src/ast/node/abstract-class-id.ts +13 -0
- package/src/ast/node/abstract-composite-node.ts +58 -0
- package/src/ast/node/abstract-elementary-type-definition.ts +29 -0
- package/src/ast/node/abstract-expression.ts +13 -0
- package/src/ast/node/abstract-leaf-node.ts +10 -0
- package/src/ast/node/abstract-node.ts +16 -0
- package/src/ast/node/abstract-statement.ts +13 -0
- package/src/ast/node/aggregate-output-value.ts +28 -0
- package/src/ast/node/aligned-modifier.ts +21 -0
- package/src/ast/node/array-definition.ts +44 -0
- package/src/ast/node/array-element-access.ts +24 -0
- package/src/ast/node/binary-expression.ts +28 -0
- package/src/ast/node/bit-modifier.ts +24 -0
- package/src/ast/node/case-clause.ts +30 -0
- package/src/ast/node/class-declaration.ts +39 -0
- package/src/ast/node/class-definition.ts +23 -0
- package/src/ast/node/class-id-range.ts +17 -0
- package/src/ast/node/class-id.ts +14 -0
- package/src/ast/node/class-member-access.ts +19 -0
- package/src/ast/node/compound-statement.ts +19 -0
- package/src/ast/node/computed-array-definition.ts +26 -0
- package/src/ast/node/computed-elementary-type-definition.ts +34 -0
- package/src/ast/node/default-clause.ts +26 -0
- package/src/ast/node/do-statement.ts +28 -0
- package/src/ast/node/elementary-type-definition.ts +49 -0
- package/src/ast/node/elementary-type-output-value.ts +19 -0
- package/src/ast/node/elementary-type.ts +18 -0
- package/src/ast/node/enum/array-dimension-kind.ts +11 -0
- package/src/ast/node/enum/binary-operator-kind.ts +41 -0
- package/src/ast/node/enum/class-id-kind.ts +12 -0
- package/src/ast/node/enum/elementary-type-kind.ts +13 -0
- package/src/ast/node/enum/expression-kind.ts +11 -0
- package/src/ast/node/enum/node-kind.ts +57 -0
- package/src/ast/node/enum/number-literal-kind.ts +17 -0
- package/src/ast/node/enum/statement-kind.ts +37 -0
- package/src/ast/node/enum/string-literal-kind.ts +13 -0
- package/src/ast/node/enum/string-variable-kind.ts +25 -0
- package/src/ast/node/enum/token-kind.ts +87 -0
- package/src/ast/node/expandable-modifier.ts +21 -0
- package/src/ast/node/explicit-array-dimension.ts +26 -0
- package/src/ast/node/expression-statement.ts +23 -0
- package/src/ast/node/extended-class-id-range.ts +20 -0
- package/src/ast/node/extends-modifier.ts +21 -0
- package/src/ast/node/for-statement.ts +29 -0
- package/src/ast/node/identifier.ts +12 -0
- package/src/ast/node/if-statement.ts +28 -0
- package/src/ast/node/implicit-array-dimension.ts +34 -0
- package/src/ast/node/length-attribute.ts +24 -0
- package/src/ast/node/length-of-expression.ts +21 -0
- package/src/ast/node/map-declaration.ts +34 -0
- package/src/ast/node/map-definition.ts +27 -0
- package/src/ast/node/map-entry.ts +18 -0
- package/src/ast/node/missing-error.ts +9 -0
- package/src/ast/node/number-literal.ts +18 -0
- package/src/ast/node/parameter-list.ts +25 -0
- package/src/ast/node/parameter-value-list.ts +29 -0
- package/src/ast/node/parameter.ts +20 -0
- package/src/ast/node/partial-array-dimension.ts +28 -0
- package/src/ast/node/specification.ts +21 -0
- package/src/ast/node/string-definition.ts +28 -0
- package/src/ast/node/string-literal.ts +21 -0
- package/src/ast/node/switch-statement.ts +32 -0
- package/src/ast/node/token.ts +20 -0
- package/src/ast/node/trivia.ts +13 -0
- package/src/ast/node/unary-expression.ts +31 -0
- package/src/ast/node/unexpected-error.ts +12 -0
- package/src/ast/node/while-statement.ts +26 -0
- package/src/ast/util/types.ts +138 -0
- package/src/ast/visitor/node-handler.ts +15 -0
- package/src/ast/visitor/node-visitor.ts +13 -0
- package/src/ast/visitor/traversing-visitor.ts +69 -0
- package/src/completion/completion-rules.ts +447 -0
- package/src/completion/get-potential-syntactic-tokens.ts +54 -0
- package/src/completion/get-potential-token-type-ids.ts +116 -0
- package/src/completion/hierarchical-map.ts +43 -0
- package/src/completion/rules/abstract-types.ts +174 -0
- package/src/completion/rules/aggregate-output-value-rules.ts +48 -0
- package/src/completion/rules/aligned-modifier-rules.ts +45 -0
- package/src/completion/rules/array-definition-rules.ts +87 -0
- package/src/completion/rules/array-element-access-rules.ts +22 -0
- package/src/completion/rules/assignment-expression-rules.ts +19 -0
- package/src/completion/rules/binary-expression-rules.ts +23 -0
- package/src/completion/rules/bit-modifier-rules.ts +25 -0
- package/src/completion/rules/case-clause-rules.ts +39 -0
- package/src/completion/rules/class-declaration-rules.ts +81 -0
- package/src/completion/rules/class-definition-rules.ts +28 -0
- package/src/completion/rules/class-id-range-rules.ts +17 -0
- package/src/completion/rules/class-id-rules.ts +9 -0
- package/src/completion/rules/class-member-access-rules.ts +7 -0
- package/src/completion/rules/compound-statement-rules.ts +25 -0
- package/src/completion/rules/computed-array-definition-rules.ts +25 -0
- package/src/completion/rules/computed-elementary-type-rules.ts +44 -0
- package/src/completion/rules/default-clause-rules.ts +23 -0
- package/src/completion/rules/do-statement-rules.ts +38 -0
- package/src/completion/rules/elementary-type-definition-rules.ts +62 -0
- package/src/completion/rules/elementary-type-output-value-rules.ts +13 -0
- package/src/completion/rules/elementary-type-rules.ts +18 -0
- package/src/completion/rules/expandable-modifier-rules.ts +21 -0
- package/src/completion/rules/explicit-array-dimension-rules.ts +22 -0
- package/src/completion/rules/expression-statement-rules.ts +22 -0
- package/src/completion/rules/extended-class-id-range-rules.ts +17 -0
- package/src/completion/rules/extends-modifier-rules.ts +17 -0
- package/src/completion/rules/for-statement-rules.ts +51 -0
- package/src/completion/rules/if-statement-rules.ts +42 -0
- package/src/completion/rules/implicit-array-dimension-rules.ts +21 -0
- package/src/completion/rules/length-attribute-rules.ts +19 -0
- package/src/completion/rules/lengthof-expression-rules.ts +23 -0
- package/src/completion/rules/map-declaration-rules.ts +45 -0
- package/src/completion/rules/map-definition-rules.ts +46 -0
- package/src/completion/rules/map-entry-rules.ts +17 -0
- package/src/completion/rules/parameter-list-rules.ts +21 -0
- package/src/completion/rules/parameter-rules.ts +17 -0
- package/src/completion/rules/parameter-value-list-rules.ts +27 -0
- package/src/completion/rules/partial-array-dimension-rules.ts +33 -0
- package/src/completion/rules/specification-rules.ts +37 -0
- package/src/completion/rules/string-definition-rules.ts +103 -0
- package/src/completion/rules/switch-statement-rules.ts +50 -0
- package/src/completion/rules/unary-expression-rules.ts +41 -0
- package/src/completion/rules/utf-string-literal-rules.ts +17 -0
- package/src/completion/rules/while-statement-rules.ts +38 -0
- package/src/lezer/context-tracker.ts +45 -0
- package/src/lezer/create-sdl-parser.ts +88 -0
- package/src/lezer/create-syntax-error-from-text-and-cursor.ts +110 -0
- package/src/lezer/create-syntax-error-from-text-and-position.ts +36 -0
- package/src/lezer/parser.terms.ts +129 -0
- package/src/lezer/parser.ts +63 -0
- package/src/lezer/props/fold-node-prop-source.ts +27 -0
- package/src/lezer/props/primitive-node-prop-source.ts +19 -0
- package/src/lezer/props/style-tags-node-prop-source.ts +188 -0
- package/src/lezer/props/syntactic-token-node-prop-source.ts +298 -0
- package/src/lezer/sdl-string-input.ts +46 -0
- package/src/location.ts +13 -0
- package/src/parse-helper.ts +93 -0
- package/src/prettier/prettier-plugin-sdl.ts +89 -0
- package/src/prettier/print-abstract-array-dimension.ts +84 -0
- package/src/prettier/print-abstract-class-id.ts +53 -0
- package/src/prettier/print-abstract-expression.ts +168 -0
- package/src/prettier/print-abstract-node.ts +224 -0
- package/src/prettier/print-abstract-statement.ts +124 -0
- package/src/prettier/print-aggregate-output-value.ts +35 -0
- package/src/prettier/print-aligned-modifier.ts +50 -0
- package/src/prettier/print-array-definition.ts +95 -0
- package/src/prettier/print-array-element-access.ts +14 -0
- package/src/prettier/print-bit-modifier.ts +48 -0
- package/src/prettier/print-case-clause.ts +58 -0
- package/src/prettier/print-class-declaration.ts +99 -0
- package/src/prettier/print-class-definition.ts +44 -0
- package/src/prettier/print-class-member-access.ts +13 -0
- package/src/prettier/print-computed-array-definition.ts +33 -0
- package/src/prettier/print-computed-elementary-type-definition.ts +60 -0
- package/src/prettier/print-default-clause.ts +39 -0
- package/src/prettier/print-do-statement.ts +31 -0
- package/src/prettier/print-elementary-type-definition.ts +108 -0
- package/src/prettier/print-elementary-type-output-value.ts +13 -0
- package/src/prettier/print-elementary-type.ts +28 -0
- package/src/prettier/print-expandable-modifier.ts +41 -0
- package/src/prettier/print-extends-modifier.ts +29 -0
- package/src/prettier/print-for-statement.ts +64 -0
- package/src/prettier/print-identifier.ts +10 -0
- package/src/prettier/print-if-statement.ts +76 -0
- package/src/prettier/print-length-attribute.ts +14 -0
- package/src/prettier/print-map-declaration.ts +75 -0
- package/src/prettier/print-map-definition.ts +67 -0
- package/src/prettier/print-map-entry.ts +22 -0
- package/src/prettier/print-number-literal.ts +84 -0
- package/src/prettier/print-parameter-list.ts +20 -0
- package/src/prettier/print-parameter-value-list.ts +20 -0
- package/src/prettier/print-parameter.ts +34 -0
- package/src/prettier/print-specification.ts +51 -0
- package/src/prettier/print-string-definition.ts +114 -0
- package/src/prettier/print-string-literal.ts +57 -0
- package/src/prettier/print-switch-statement.ts +46 -0
- package/src/prettier/print-token.ts +7 -0
- package/src/prettier/print-unexpected-error.ts +10 -0
- package/src/prettier/print-while-statement.ts +26 -0
- package/src/prettier/util/print-utils.ts +607 -0
- package/src/prettier/util/types.ts +40 -0
- package/src/scanner-error.ts +65 -0
- package/src/util/location-utils.ts +16 -0
- package/src/util/logger.ts +165 -0
- package/tests/analyser/create-sdl-analyser.test.ts +54 -0
- package/tests/analyser/get-sdl-analyser-test-scenarios.ts +80 -0
- package/tests/analyser/sdl-analyser-scenarios.test.ts +67 -0
- package/tests/analyser/semantic-error-scenarios.test.ts +40 -0
- package/tests/analyser/symbol-table.test.ts +188 -0
- package/tests/analyser/test-cases/array_definition.txt +50 -0
- package/tests/analyser/test-cases/class_declaration.txt +112 -0
- package/tests/analyser/test-cases/class_definition.txt +60 -0
- package/tests/analyser/test-cases/compound_statement.txt +63 -0
- package/tests/analyser/test-cases/computed_array_definition.txt +12 -0
- package/tests/analyser/test-cases/computed_elementary_type_definition.txt +39 -0
- package/tests/analyser/test-cases/do_statement.txt +16 -0
- package/tests/analyser/test-cases/elementary_type_definition.txt +58 -0
- package/tests/analyser/test-cases/expression.txt +159 -0
- package/tests/analyser/test-cases/for_statement.txt +55 -0
- package/tests/analyser/test-cases/if_statement.txt +57 -0
- package/tests/analyser/test-cases/map_declaration.txt +89 -0
- package/tests/analyser/test-cases/map_definition.txt +35 -0
- package/tests/analyser/test-cases/number_literal.txt +31 -0
- package/tests/analyser/test-cases/parameter_list.txt +16 -0
- package/tests/analyser/test-cases/scopes.txt +239 -0
- package/tests/analyser/test-cases/specification.txt +28 -0
- package/tests/analyser/test-cases/string_definition.txt +40 -0
- package/tests/analyser/test-cases/switch_statement.txt +96 -0
- package/tests/analyser/test-cases/while_statement.txt +16 -0
- package/tests/analyser/util/symbol-table-utils.test.ts +65 -0
- package/tests/ast/__snapshots__/build-ast.test.ts.snap +38897 -0
- package/tests/ast/build-ast.test.ts +463 -0
- package/tests/ast/visitor/traversing-visitor.test.ts +36 -0
- package/tests/completion/get-potential-syntactic-tokens.test.ts +89 -0
- package/tests/completion/get-potential-token-type-ids.test.ts +76 -0
- package/tests/completion/test-potential-syntactic-tokens-scenario.ts +24 -0
- package/tests/completion/test-potential-token-type-ids-scenario.ts +33 -0
- package/tests/fixtures/history-recording-node-handler.ts +232 -0
- package/tests/lezer/create-parse-error-from-text-and-position.test.ts +129 -0
- package/tests/lezer/create-sdl-parser.test.ts +15 -0
- package/tests/lezer/sdl-parser-scenarios.test.ts +24 -0
- package/tests/lezer/sdl-string-input.test.ts +12 -0
- package/tests/lezer/syntax-error-scenarios.test.ts +114 -0
- package/tests/lezer/test-cases/array_definition.txt +109 -0
- package/tests/lezer/test-cases/class_declaration.txt +141 -0
- package/tests/lezer/test-cases/class_definition.txt +89 -0
- package/tests/lezer/test-cases/comment.txt +335 -0
- package/tests/lezer/test-cases/compound_statement.txt +109 -0
- package/tests/lezer/test-cases/computed_array_definition.txt +33 -0
- package/tests/lezer/test-cases/computed_elementary_type_definition.txt +59 -0
- package/tests/lezer/test-cases/do_statement.txt +48 -0
- package/tests/lezer/test-cases/elementary_type_definition.txt +158 -0
- package/tests/lezer/test-cases/expression.txt +1203 -0
- package/tests/lezer/test-cases/for_statement.txt +183 -0
- package/tests/lezer/test-cases/if_statement.txt +183 -0
- package/tests/lezer/test-cases/invalid.txt +97 -0
- package/tests/lezer/test-cases/map_declaration.txt +152 -0
- package/tests/lezer/test-cases/map_definition.txt +59 -0
- package/tests/lezer/test-cases/number_literal.txt +273 -0
- package/tests/lezer/test-cases/specification.txt +38 -0
- package/tests/lezer/test-cases/string_definition.txt +263 -0
- package/tests/lezer/test-cases/string_literal.txt +303 -0
- package/tests/lezer/test-cases/switch_statement.txt +407 -0
- package/tests/lezer/test-cases/while_statement.txt +45 -0
- package/tests/parse-helper.test.ts +361 -0
- package/tests/prettier/__snapshots__/prettier-plugin-sdl.test.ts.snap +127 -0
- package/tests/prettier/prettier-plugin-sdl.test.ts +58 -0
- package/tests/prettier/print-array.test.ts +29 -0
- package/tests/prettier/print-class.test.ts +15 -0
- package/tests/prettier/print-do.test.ts +25 -0
- package/tests/prettier/print-elementary-type.test.ts +62 -0
- package/tests/prettier/print-error.test.ts +40 -0
- package/tests/prettier/print-expression.test.ts +17 -0
- package/tests/prettier/print-for.test.ts +23 -0
- package/tests/prettier/print-if.test.ts +71 -0
- package/tests/prettier/print-number-literal.test.ts +28 -0
- package/tests/prettier/print-specification.test.ts +54 -0
- package/tests/prettier/print-string.test.ts +36 -0
- package/tests/prettier/print-switch.test.ts +69 -0
- package/tests/prettier/print-while.test.ts +23 -0
- package/tests/prettier/test-prettier-scenario.ts +41 -0
- package/tests/prettier/util/print-utils.test.ts +665 -0
- package/tests/prettier/util/types.test.ts +38 -0
- package/tests/sample-specifications/invalid.sdl +24 -0
- package/tests/sample-specifications/prettified-invalid.sdl +28 -0
- package/tests/sample-specifications/prettified-various-elements-narrow.sdl +97 -0
- package/tests/sample-specifications/prettified-various-elements.sdl +90 -0
- package/tests/sample-specifications/sample.sdl +24 -0
- package/tests/sample-specifications/various-elements.sdl +88 -0
- package/tests/util/logger.test.ts +36 -0
- package/tsconfig.json +29 -0
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
/* Syntactic Description Language grammar in EBNF syntax: https://www.w3.org/TR/xml/#sec-notation */
|
|
2
|
+
/* References are either to sub-clauses or rules appearing in 14496-34 */
|
|
3
|
+
/* Lines indented by 4 spaces have been wrapped from the previous line */
|
|
4
|
+
|
|
5
|
+
/* 5.1 Character set */
|
|
6
|
+
|
|
7
|
+
non_zero_digit_character ::= [1-9]
|
|
8
|
+
digit_character ::= 0 | non_zero_digit_character
|
|
9
|
+
latin_character ::= [a-zA-Z]
|
|
10
|
+
sdl_compatible_ucs_character ::= [#x0020-#x10FFFF] - #xFEFF - #x0085 - #x2028 - #x2029
|
|
11
|
+
universal_character_name ::= ('\u' four_hexadecimal_characters) | ('\U' four_hexadecimal_characters four_hexadecimal_characters)
|
|
12
|
+
multiple_character_literal_character ::= [#x0020-#x007E]
|
|
13
|
+
|
|
14
|
+
/* 5.4 Comments */
|
|
15
|
+
|
|
16
|
+
/* Rule S.1: Comments - until the end of the line */
|
|
17
|
+
/* Comments are treated as whitespace and therefore not included in the grammar as a token */
|
|
18
|
+
/* however a suitable rule for tokenization would be as follows */
|
|
19
|
+
/* comment ::= '//' (sdl_compatible_ucs_character | universal_character_name)* */
|
|
20
|
+
|
|
21
|
+
/* 5.5 Identifiers */
|
|
22
|
+
|
|
23
|
+
identifier_character ::= digit_character | latin_character | '_'
|
|
24
|
+
|
|
25
|
+
/* An identifier must include at least one alphabetic character. */
|
|
26
|
+
identifier ::= identifier_character* latin_character identifier_character*
|
|
27
|
+
|
|
28
|
+
/* 5.6 Punctuators */
|
|
29
|
+
|
|
30
|
+
open_parenthesis ::= '('
|
|
31
|
+
close_parenthesis ::= ')'
|
|
32
|
+
open_brace ::= '{'
|
|
33
|
+
close_brace ::= '}'
|
|
34
|
+
open_bracket ::= '['
|
|
35
|
+
close_bracket ::= ']'
|
|
36
|
+
colon ::= ':'
|
|
37
|
+
semicolon ::= ';'
|
|
38
|
+
comma ::= ','
|
|
39
|
+
double_quote ::= '"'
|
|
40
|
+
single_quote ::= "'"
|
|
41
|
+
|
|
42
|
+
/* 5.7 Keywords */
|
|
43
|
+
|
|
44
|
+
abstract ::= 'abstract'
|
|
45
|
+
aligned ::= 'aligned'
|
|
46
|
+
base64string ::= 'base64string'
|
|
47
|
+
bit ::= 'bit'
|
|
48
|
+
break ::= 'break'
|
|
49
|
+
case ::= 'case'
|
|
50
|
+
class ::= 'class'
|
|
51
|
+
computed ::= 'computed'
|
|
52
|
+
const ::= 'const'
|
|
53
|
+
default ::= 'default'
|
|
54
|
+
do ::= 'do'
|
|
55
|
+
else ::= 'else'
|
|
56
|
+
expandable ::= 'expandable'
|
|
57
|
+
extends ::= 'extends'
|
|
58
|
+
float ::= 'float'
|
|
59
|
+
for ::= 'for'
|
|
60
|
+
if ::= 'if'
|
|
61
|
+
int ::= 'int'
|
|
62
|
+
legacy ::= 'legacy'
|
|
63
|
+
lengthof ::= 'lengthof'
|
|
64
|
+
map ::= 'map'
|
|
65
|
+
reserved ::= 'reserved'
|
|
66
|
+
switch ::= 'switch'
|
|
67
|
+
unsigned ::= 'unsigned'
|
|
68
|
+
utf16string ::= 'utf16string'
|
|
69
|
+
utf8string ::= 'utf8string'
|
|
70
|
+
utf8list ::= 'utf8list'
|
|
71
|
+
utfstring ::= 'utfstring'
|
|
72
|
+
while ::= 'while'
|
|
73
|
+
|
|
74
|
+
/* 5.8 Operators */
|
|
75
|
+
|
|
76
|
+
/* . class member access defined as part of class_member_access */
|
|
77
|
+
/* [] array element access defined as part of array_element_access */
|
|
78
|
+
postfix_increment ::= '++'
|
|
79
|
+
postfix_decrement ::= '--'
|
|
80
|
+
unary_plus ::= '+'
|
|
81
|
+
unary_negation ::= '-'
|
|
82
|
+
multiplication ::= '*'
|
|
83
|
+
division ::= '/'
|
|
84
|
+
modulus ::= '%'
|
|
85
|
+
addition ::= '+'
|
|
86
|
+
subtraction ::= '-'
|
|
87
|
+
bitwise_shift_left ::= '<<'
|
|
88
|
+
bitwise_shift_right ::= '>>'
|
|
89
|
+
relational_less_than ::= '<'
|
|
90
|
+
relational_less_than_or_equal ::= '<='
|
|
91
|
+
relational_greater_than ::= '>'
|
|
92
|
+
relational_greater_than_or_equal ::= '>='
|
|
93
|
+
relational_equal ::= '=='
|
|
94
|
+
relational_not_equal ::= '!='
|
|
95
|
+
bitwise_and ::= '&'
|
|
96
|
+
bitwise_or ::= '|'
|
|
97
|
+
logical_and ::= '&&'
|
|
98
|
+
logical_or ::= '||'
|
|
99
|
+
assignment ::= '='
|
|
100
|
+
|
|
101
|
+
postfix_operator ::= postfix_increment | postfix_decrement
|
|
102
|
+
unary_operator ::= unary_plus | unary_negation
|
|
103
|
+
multiplicative_operator ::= multiplication | division | modulus
|
|
104
|
+
additive_operator ::= addition | subtraction
|
|
105
|
+
shift_operator ::= bitwise_shift_left | bitwise_shift_right
|
|
106
|
+
relational_operator ::= relational_less_than | relational_less_than_or_equal | relational_greater_than |
|
|
107
|
+
relational_greater_than_or_equal
|
|
108
|
+
equality_operator ::= relational_equal | relational_not_equal
|
|
109
|
+
bitwise_operator ::= bitwise_and | bitwise_or
|
|
110
|
+
logical_operator ::= logical_and | logical_or
|
|
111
|
+
|
|
112
|
+
/* 5.9 Expressions and evaluation */
|
|
113
|
+
|
|
114
|
+
class_member_access ::= '.' identifier
|
|
115
|
+
array_element_access ::= open_bracket expression close_bracket
|
|
116
|
+
|
|
117
|
+
primary_expression ::= identifier | number_literal | open_parenthesis expression close_parenthesis
|
|
118
|
+
postfix_expression ::= expression (array_element_access | class_member_access | postfix_operator)? | primary_expression
|
|
119
|
+
unary_expression ::= unary_operator? (postfix_expression | lengthof_expression)
|
|
120
|
+
multiplicative_expression ::= unary_expression (multiplicative_operator multiplicative_expression)?
|
|
121
|
+
additive_expression ::= multiplicative_expression (additive_operator additive_expression)?
|
|
122
|
+
shift_expression ::= additive_expression (shift_operator shift_expression)?
|
|
123
|
+
relational_expression ::= shift_expression (relational_operator relational_expression)?
|
|
124
|
+
equality_expression ::= relational_expression (equality_operator equality_expression)?
|
|
125
|
+
bitwise_expression ::= equality_expression (bitwise_operator bitwise_expression)?
|
|
126
|
+
expression ::= bitwise_expression (logical_operator expression)?
|
|
127
|
+
|
|
128
|
+
/* Left hand operand must evaluate to a parsed variable value target */
|
|
129
|
+
/* Right hand operand must evaluate to a value source */
|
|
130
|
+
assignment_expression ::= expression assignment expression
|
|
131
|
+
|
|
132
|
+
/* 5.10 Statements */
|
|
133
|
+
|
|
134
|
+
expression_statement ::= (expression | assignment_expression) semicolon
|
|
135
|
+
|
|
136
|
+
/* Block scoping */
|
|
137
|
+
compound_statement ::= open_brace statement* close_brace
|
|
138
|
+
|
|
139
|
+
statement ::= expression_statement | compound_statement |
|
|
140
|
+
elementary_type_definition | map_definition |
|
|
141
|
+
string_definition | class_definition | array_definition |
|
|
142
|
+
computed_elementary_type_definition | computed_array_definition |
|
|
143
|
+
if_statement | switch_statement | for_statement | do_statement | while_statement
|
|
144
|
+
|
|
145
|
+
/* 5.11 Built-in operators */
|
|
146
|
+
|
|
147
|
+
/* Rule O.1: lengthof() Operator */
|
|
148
|
+
|
|
149
|
+
lengthof_expression ::= lengthof open_parenthesis expression close_parenthesis
|
|
150
|
+
|
|
151
|
+
/* Rule O.2: Range operator */
|
|
152
|
+
|
|
153
|
+
range_operator ::= '..'
|
|
154
|
+
|
|
155
|
+
/* 5.14 Binary literal values */
|
|
156
|
+
|
|
157
|
+
/* Rule S.2: Binary literal value */
|
|
158
|
+
|
|
159
|
+
binary_character ::= 0 | 1
|
|
160
|
+
binary_character_string ::= binary_character*
|
|
161
|
+
four_binary_characters ::= binary_character binary_character binary_character binary_character
|
|
162
|
+
one_to_four_binary_characters ::= binary_character binary_character? binary_character? binary_character?
|
|
163
|
+
period_separated_binary_character_string ::= four_binary_characters '.'
|
|
164
|
+
(four_binary_characters '.')* one_to_four_binary_characters
|
|
165
|
+
|
|
166
|
+
binary_literal ::= '0b' (period_separated_binary_character_string | binary_character_string)
|
|
167
|
+
|
|
168
|
+
/* 5.15 Hexadecimal literal values */
|
|
169
|
+
|
|
170
|
+
/* Rule S.3: Hexadecimal literal value */
|
|
171
|
+
|
|
172
|
+
hexadecimal_character ::= [0-9A-F]
|
|
173
|
+
hexadecimal_character_string ::= hexadecimal_character*
|
|
174
|
+
four_hexadecimal_characters ::= hexadecimal_character hexadecimal_character
|
|
175
|
+
hexadecimal_character hexadecimal_character
|
|
176
|
+
one_to_four_hexadecimal_characters ::= hexadecimal_character hexadecimal_character?
|
|
177
|
+
hexadecimal_character? hexadecimal_character?
|
|
178
|
+
period_separated_hexadecimal_character_string ::= four_hexadecimal_characters '.'
|
|
179
|
+
(four_hexadecimal_characters '.')* one_to_four_hexadecimal_characters
|
|
180
|
+
|
|
181
|
+
hexadecimal_literal ::= '0x' (period_separated_hexadecimal_character_string | hexadecimal_character_string)
|
|
182
|
+
|
|
183
|
+
/* 5.16 Multiple character literal values */
|
|
184
|
+
|
|
185
|
+
/* Rule S.4: Multiple character literal value */
|
|
186
|
+
|
|
187
|
+
escaped_multiple_character_literal_character ::= (multiple_character_literal_character - single_quote - '\') | ('\' single_quote) | '\\'
|
|
188
|
+
multiple_character_literal ::= (single_quote escaped_multiple_character_literal_character+ single_quote)+
|
|
189
|
+
|
|
190
|
+
/* 5.17 Integer, decimal and floating-point literal values */
|
|
191
|
+
|
|
192
|
+
positive_integer ::= non_zero_digit_character digit_character*
|
|
193
|
+
|
|
194
|
+
integer_literal ::= 0 | positive_integer
|
|
195
|
+
decimal_literal ::= integer_literal '.' digit_character+
|
|
196
|
+
floating_point_literal ::= (integer_literal | decimal_literal) 'e' (0 | (('+' | '-')? positive_integer))
|
|
197
|
+
|
|
198
|
+
/* One or more multiple character literals to support concatenation */
|
|
199
|
+
|
|
200
|
+
number_literal ::= binary_literal | hexadecimal_literal | multiple_character_literal | integer_literal |
|
|
201
|
+
decimal_literal | floating_point_literal
|
|
202
|
+
|
|
203
|
+
/* 5.18 String literal values */
|
|
204
|
+
|
|
205
|
+
escaped_sdl_compatible_ucs_character ::= (sdl_compatible_ucs_character - double_quote - '\') | ('\' double_quote) | '\\'
|
|
206
|
+
utf_string_literal ::= ('u' double_quote (escaped_sdl_compatible_ucs_character | universal_character_name)* double_quote)+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
/* 5.19 Scope */
|
|
210
|
+
|
|
211
|
+
/* computed_elementary_type_definition can only be const */
|
|
212
|
+
|
|
213
|
+
Specification ::= (class_declaration | map_declaration | computed_elementary_type_definition)*
|
|
214
|
+
|
|
215
|
+
/* 6.2 Constant-length direct representation bit fields */
|
|
216
|
+
|
|
217
|
+
/* Rule E.1: Elementary data types */
|
|
218
|
+
|
|
219
|
+
aligned_modifier ::= aligned (open_parenthesis ('8' | '16' | '32' | '64' | '128') close_parenthesis)?
|
|
220
|
+
|
|
221
|
+
elementary_type ::= int | unsigned int | float | bit
|
|
222
|
+
|
|
223
|
+
length_attribute ::= open_parenthesis expression close_parenthesis
|
|
224
|
+
|
|
225
|
+
/* Rule E.2: Look-ahead parsing */
|
|
226
|
+
|
|
227
|
+
/* Rule E.3: Legacy keyword */
|
|
228
|
+
|
|
229
|
+
/* Rule E.4: Reserved keyword */
|
|
230
|
+
|
|
231
|
+
/* 6.3 Variable length direct representation bit fields */
|
|
232
|
+
|
|
233
|
+
elementary_type_definition ::= (reserved | legacy)? const? aligned_modifier? elementary_type length_attribute '*'?
|
|
234
|
+
identifier (assignment expression (range_operator expression)?)? semicolon
|
|
235
|
+
|
|
236
|
+
/* 6.4 Constant-length indirect representation bit fields */
|
|
237
|
+
|
|
238
|
+
/* Rule E.3: Maps */
|
|
239
|
+
|
|
240
|
+
/* Rule E.4: Mapped data types */
|
|
241
|
+
|
|
242
|
+
/* 6.5 Variable length indirect representation bit fields */
|
|
243
|
+
|
|
244
|
+
/* Rule E.5: Maps with escape codes */
|
|
245
|
+
|
|
246
|
+
output_value ::= number_literal | elementary_type_output_value | aggregate_output_value
|
|
247
|
+
elementary_type_output_value ::= elementary_type length_attribute
|
|
248
|
+
aggregate_output_value ::= open_brace (output_value comma)* output_value close_brace
|
|
249
|
+
map_entry ::= binary_literal comma aggregate_output_value
|
|
250
|
+
|
|
251
|
+
map_declaration ::= map identifier open_parenthesis (elementary_type | identifier) close_parenthesis
|
|
252
|
+
open_brace (map_entry comma)+ map_entry close_brace
|
|
253
|
+
|
|
254
|
+
map_definition ::= (reserved | legacy)? (elementary_type | identifier) '<' identifier '>' identifier semicolon
|
|
255
|
+
|
|
256
|
+
/* 6.6 Variable length strings */
|
|
257
|
+
|
|
258
|
+
/* Rule E.6: String data types */
|
|
259
|
+
|
|
260
|
+
base64_character ::= digit_character | latin_character | '+' | '/'
|
|
261
|
+
base64_string_literal ::= (double_quote base64_character* '='? '='? double_quote)+
|
|
262
|
+
|
|
263
|
+
/* 6.7 String value */
|
|
264
|
+
|
|
265
|
+
/* One or more string literals to support concatenation */
|
|
266
|
+
|
|
267
|
+
utf16_string_definition ::= utf16string identifier (assignment utf_string_literal)?
|
|
268
|
+
utf8_string_definition ::= (utf8string | utf8list) identifier (assignment utf_string_literal)?
|
|
269
|
+
utf_string_definition ::= utfstring identifier (assignment utf_string_literal)?
|
|
270
|
+
base64_string_definition ::= base64string identifier (assignment base64_string_literal)?
|
|
271
|
+
|
|
272
|
+
string_definition ::= (reserved | legacy)? const? aligned_modifier? (base64_string_definition | utf16_string_definition |
|
|
273
|
+
utf8_string_definition | utf_string_definition) semicolon
|
|
274
|
+
|
|
275
|
+
/* 7.1 Classes */
|
|
276
|
+
|
|
277
|
+
/* Rule C.1: Classes */
|
|
278
|
+
|
|
279
|
+
/* Rule C.2: Class data types */
|
|
280
|
+
|
|
281
|
+
/* 7.2 Base and derived classes */
|
|
282
|
+
|
|
283
|
+
/* RULE C.3: Derived classes */
|
|
284
|
+
|
|
285
|
+
/* 7.3 Abstract classes */
|
|
286
|
+
|
|
287
|
+
/* Rule C.4: Abstract classes */
|
|
288
|
+
|
|
289
|
+
/* 7.4 Polymorphism in class declaration */
|
|
290
|
+
|
|
291
|
+
/* Rule C.5: Class polymorphism */
|
|
292
|
+
|
|
293
|
+
class_id ::= integer_literal
|
|
294
|
+
class_id_range ::= class_id range_operator class_id
|
|
295
|
+
extended_class_id_range ::= class_id | class_id_range (comma (class_id | class_id_range))*
|
|
296
|
+
|
|
297
|
+
bit_modifier ::= colon bit open_parenthesis positive_integer close_parenthesis
|
|
298
|
+
(identifier assignment)? extended_class_id_range
|
|
299
|
+
|
|
300
|
+
/* 7.5 Expandable classes */
|
|
301
|
+
|
|
302
|
+
/* Rule C.6: Expandable classes */
|
|
303
|
+
|
|
304
|
+
expandable_modifier ::= expandable (open_parenthesis positive_integer close_parenthesis)?
|
|
305
|
+
|
|
306
|
+
/* 7.6 Parameter types */
|
|
307
|
+
|
|
308
|
+
/* Rule C.7: Class parameter types */
|
|
309
|
+
|
|
310
|
+
parameter ::= (identifier | elementary_type) identifier
|
|
311
|
+
parameter_list ::= open_parenthesis (parameter comma)* parameter close_parenthesis
|
|
312
|
+
parameter_value_list ::= open_parenthesis (expression comma)* expression close_parenthesis
|
|
313
|
+
|
|
314
|
+
extends_modifier ::= extends identifier parameter_value_list?
|
|
315
|
+
|
|
316
|
+
class_declaration ::= aligned_modifier? expandable_modifier? abstract? class identifier
|
|
317
|
+
parameter_list? extends_modifier? bit_modifier? open_brace statement* close_brace
|
|
318
|
+
|
|
319
|
+
/* Rule C.8: Parameterized class data types */
|
|
320
|
+
|
|
321
|
+
class_definition ::= legacy? identifier identifier parameter_value_list? semicolon
|
|
322
|
+
|
|
323
|
+
/* 7.7 Arrays */
|
|
324
|
+
|
|
325
|
+
/* Rule A.1: Arrays */
|
|
326
|
+
|
|
327
|
+
/* 7.8 Multi-dimensional arrays */
|
|
328
|
+
|
|
329
|
+
/* Rule A.2: Multi-dimensional arrays */
|
|
330
|
+
|
|
331
|
+
/* 7.9 Partial arrays */
|
|
332
|
+
|
|
333
|
+
/* Rule A.3: Partial arrays */
|
|
334
|
+
|
|
335
|
+
/* Rule A.4: Partial multi-dimensional arrays */
|
|
336
|
+
|
|
337
|
+
explicit_array_dimension ::= open_bracket expression close_bracket
|
|
338
|
+
|
|
339
|
+
partial_array_dimension ::= open_bracket open_bracket expression close_bracket close_bracket
|
|
340
|
+
|
|
341
|
+
/* 7.10 Implicit arrays */
|
|
342
|
+
|
|
343
|
+
/* Rule A.5: Implicit arrays */
|
|
344
|
+
|
|
345
|
+
implicit_array_dimension ::= open_bracket (positive_integer range_operator positive_integer)? close_bracket
|
|
346
|
+
|
|
347
|
+
array_definition ::= (reserved | legacy)? aligned_modifier? ((elementary_type length_attribute) | identifier) identifier
|
|
348
|
+
(implicit_array_dimension | (explicit_array_dimension | partial_array_dimension)+) semicolon
|
|
349
|
+
|
|
350
|
+
/* 8 Computed variables */
|
|
351
|
+
|
|
352
|
+
/* 8.2 Elementary data types */
|
|
353
|
+
|
|
354
|
+
/* Rule NP.1: Elementary data types */
|
|
355
|
+
|
|
356
|
+
computed_elementary_type_definition ::= computed const? elementary_type identifier (assignment expression)? semicolon
|
|
357
|
+
|
|
358
|
+
/* 8.3 Arrays */
|
|
359
|
+
|
|
360
|
+
/* Rule NP.2: Arrays */
|
|
361
|
+
|
|
362
|
+
/* 8.4 Multi-dimensional arrays */
|
|
363
|
+
|
|
364
|
+
/* Rule NP.3: Multi-dimensional arrays */
|
|
365
|
+
|
|
366
|
+
computed_array_definition ::= computed elementary_type identifier (explicit_array_dimension)+ semicolon
|
|
367
|
+
|
|
368
|
+
/* 9 Syntactic flow control */
|
|
369
|
+
|
|
370
|
+
/* 9.1 Conditionals */
|
|
371
|
+
|
|
372
|
+
/* Rule FC.1: Flow control using if-then-else */
|
|
373
|
+
|
|
374
|
+
if_statement ::= if open_parenthesis expression close_parenthesis statement
|
|
375
|
+
(else statement)?
|
|
376
|
+
|
|
377
|
+
/* Rule FC.2: Flow control using switch */
|
|
378
|
+
|
|
379
|
+
case_clause ::= case number_literal colon
|
|
380
|
+
((statement* (break semicolon)?) | (open_brace statement* break semicolon close_brace))?
|
|
381
|
+
default_clause ::= default colon statement*
|
|
382
|
+
|
|
383
|
+
switch_statement ::= switch open_parenthesis expression close_parenthesis open_brace
|
|
384
|
+
case_clause* default_clause? close_brace
|
|
385
|
+
|
|
386
|
+
/* 9.2 Loops */
|
|
387
|
+
|
|
388
|
+
/* Rule FC.3: Flow control using for */
|
|
389
|
+
|
|
390
|
+
for_statement ::= for open_parenthesis ((assignment_expression semicolon) | computed_elementary_type_definition | semicolon)
|
|
391
|
+
expression? semicolon (assignment_expression | expression)? close_parenthesis statement
|
|
392
|
+
|
|
393
|
+
/* Rule FC.4: Flow control using do */
|
|
394
|
+
|
|
395
|
+
do_statement ::= do compound_statement while open_parenthesis expression close_parenthesis semicolon
|
|
396
|
+
|
|
397
|
+
/* Rule FC.5: Flow control using while */
|
|
398
|
+
|
|
399
|
+
while_statement ::= while open_parenthesis expression close_parenthesis statement
|