@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,629 @@
|
|
|
1
|
+
// Syntactic description language in Lezer syntax: https://lezer.codemirror.net
|
|
2
|
+
// References are either to sub-clauses or rules appearing in 14496-34
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
// Lezer terminal tokens
|
|
6
|
+
|
|
7
|
+
@tokens {
|
|
8
|
+
|
|
9
|
+
Whitespace { @whitespace+ }
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
// 5.1 Character set
|
|
13
|
+
|
|
14
|
+
non_zero_digit_character { $[1-9] }
|
|
15
|
+
digit_character { "0" | non_zero_digit_character }
|
|
16
|
+
latin_character { $[a-zA-Z] }
|
|
17
|
+
|
|
18
|
+
// Lezer only supports up to \uFFFF and not \u10FFFF
|
|
19
|
+
// Not including \ or "
|
|
20
|
+
sdl_compatible_ucs_character { $[\u0020-\u0021\u0023-\u005B\u005D-\u0084\u0086-\u2027\u202A-\uFEFE\uFF00-\uFFFF] }
|
|
21
|
+
escaped_sdl_compatible_ucs_character { sdl_compatible_ucs_character | "\\\"" | "\\\\" }
|
|
22
|
+
universal_character_name { ("\u" four_hexadecimal_characters) | ("\U" four_hexadecimal_characters four_hexadecimal_characters) }
|
|
23
|
+
// Not including \ or '
|
|
24
|
+
multiple_character_literal_character { $[\u0020-\u0026\u0028-\u005B\u005D-\u007E] }
|
|
25
|
+
escaped_multiple_character_literal_character { multiple_character_literal_character | "\\\'" | "\\\\" }
|
|
26
|
+
identifier_character { digit_character | latin_character | "_" }
|
|
27
|
+
base64_character { digit_character | latin_character | "+" | "/" }
|
|
28
|
+
|
|
29
|
+
// 5.4 Comments
|
|
30
|
+
|
|
31
|
+
Comment { "//" ("\\" (![\n] | "\\r"? "\\n") | ![\n])* }
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
// 5.5 Identifiers
|
|
35
|
+
// An identifier must include at least one alphabetic character.
|
|
36
|
+
|
|
37
|
+
Identifier { identifier_character* latin_character identifier_character* }
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
// 5.6 Punctuators
|
|
41
|
+
|
|
42
|
+
OpenParenthesis { "(" }
|
|
43
|
+
CloseParenthesis { ")" }
|
|
44
|
+
OpenBrace { "{" }
|
|
45
|
+
CloseBrace { "}" }
|
|
46
|
+
OpenBracket { "[" }
|
|
47
|
+
CloseBracket { "]" }
|
|
48
|
+
Colon { ":" }
|
|
49
|
+
Semicolon { ";" }
|
|
50
|
+
Comma { "," }
|
|
51
|
+
DoubleQuote { "\"" }
|
|
52
|
+
SingleQuote { "'" }
|
|
53
|
+
Period { "." }
|
|
54
|
+
|
|
55
|
+
// 5.8 Operators
|
|
56
|
+
|
|
57
|
+
PostfixIncrement { "++" }
|
|
58
|
+
PostfixDecrement { "--" }
|
|
59
|
+
UnaryPlus { "+" }
|
|
60
|
+
UnaryNegation { "-" }
|
|
61
|
+
Multiplication { "*" }
|
|
62
|
+
Division { "/" }
|
|
63
|
+
Modulus { "%" }
|
|
64
|
+
Addition { "+" }
|
|
65
|
+
Subtraction { "-" }
|
|
66
|
+
BitwiseShiftLeft { "<<" }
|
|
67
|
+
BitwiseShiftRight { ">>" }
|
|
68
|
+
RelationalLessThan { "<" }
|
|
69
|
+
RelationalLessThanOrEqual { "<=" }
|
|
70
|
+
RelationalGreaterThan { ">" }
|
|
71
|
+
RelationalGreaterThanOrEqual { ">=" }
|
|
72
|
+
RelationalEqual { "==" }
|
|
73
|
+
RelationalNotEqual { "!=" }
|
|
74
|
+
BitwiseAnd { "&" }
|
|
75
|
+
BitwiseOr { "|" }
|
|
76
|
+
LogicalAnd { "&&" }
|
|
77
|
+
LogicalOr { "||" }
|
|
78
|
+
Assignment { "=" }
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
// Rule O.2: Range operator
|
|
82
|
+
|
|
83
|
+
RangeOperator { ".." }
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
// Rule S.2: Binary literal value
|
|
87
|
+
|
|
88
|
+
binary_character { "0" | "1" }
|
|
89
|
+
binary_character_string { binary_character* }
|
|
90
|
+
four_binary_characters { binary_character binary_character binary_character binary_character }
|
|
91
|
+
one_to_four_binary_characters { binary_character binary_character? binary_character? binary_character? }
|
|
92
|
+
period_separated_binary_character_string { four_binary_characters "." (four_binary_characters ".")* one_to_four_binary_characters }
|
|
93
|
+
|
|
94
|
+
BinaryLiteral { "0b" (period_separated_binary_character_string | binary_character_string) }
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
// Rule S.3: Hexadecimal literal value
|
|
98
|
+
|
|
99
|
+
hexadecimal_character { $[0-9A-F] }
|
|
100
|
+
hexadecimal_character_string {hexadecimal_character* }
|
|
101
|
+
four_hexadecimal_characters { hexadecimal_character hexadecimal_character hexadecimal_character hexadecimal_character }
|
|
102
|
+
one_to_four_hexadecimal_characters { hexadecimal_character hexadecimal_character? hexadecimal_character? hexadecimal_character? }
|
|
103
|
+
period_separated_hexadecimal_character_string { four_hexadecimal_characters "." (four_hexadecimal_characters ".")* one_to_four_hexadecimal_characters }
|
|
104
|
+
|
|
105
|
+
HexadecimalLiteral { "0x" (period_separated_hexadecimal_character_string | hexadecimal_character_string) }
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
// 5.17 Integer, decimal and floating-point literal values
|
|
109
|
+
|
|
110
|
+
positive_integer { non_zero_digit_character digit_character* }
|
|
111
|
+
|
|
112
|
+
integer_literal { "0" | positive_integer }
|
|
113
|
+
|
|
114
|
+
IntegerLiteral { integer_literal }
|
|
115
|
+
|
|
116
|
+
decimal_literal { integer_literal "." digit_character+ }
|
|
117
|
+
|
|
118
|
+
DecimalLiteral { decimal_literal }
|
|
119
|
+
|
|
120
|
+
FloatingPointLiteral { (integer_literal | decimal_literal) "e" ("0" | (("+" | "-")? positive_integer)) }
|
|
121
|
+
|
|
122
|
+
// 5.18 String literal values
|
|
123
|
+
|
|
124
|
+
UtfPrefix { "u" }
|
|
125
|
+
|
|
126
|
+
// Rule E.2: Look-ahead parsing
|
|
127
|
+
|
|
128
|
+
LookAhead {
|
|
129
|
+
"*"
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
AlignmentBitCount8 {
|
|
133
|
+
"8"
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
AlignmentBitCount16 {
|
|
137
|
+
"16"
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
AlignmentBitCount32 {
|
|
141
|
+
"32"
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
AlignmentBitCount64 {
|
|
145
|
+
"64"
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
AlignmentBitCount128 {
|
|
149
|
+
"128"
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Lezer token precedence rules
|
|
153
|
+
|
|
154
|
+
@precedence {
|
|
155
|
+
escaped_sdl_compatible_ucs_character,
|
|
156
|
+
escaped_multiple_character_literal_character,
|
|
157
|
+
base64_character,
|
|
158
|
+
Comment,
|
|
159
|
+
Division
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
@precedence {
|
|
163
|
+
escaped_sdl_compatible_ucs_character,
|
|
164
|
+
escaped_multiple_character_literal_character,
|
|
165
|
+
Whitespace
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
@precedence {
|
|
169
|
+
BinaryLiteral,
|
|
170
|
+
HexadecimalLiteral,
|
|
171
|
+
FloatingPointLiteral,
|
|
172
|
+
DecimalLiteral,
|
|
173
|
+
IntegerLiteral,
|
|
174
|
+
Identifier
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
// 5.8 Operators
|
|
180
|
+
|
|
181
|
+
postfix_operator {
|
|
182
|
+
PostfixIncrement |
|
|
183
|
+
PostfixDecrement
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
unary_operator {
|
|
187
|
+
UnaryPlus |
|
|
188
|
+
UnaryNegation
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
multiplicative_operator {
|
|
192
|
+
Multiplication |
|
|
193
|
+
Division |
|
|
194
|
+
Modulus
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
additive_operator {
|
|
198
|
+
Addition |
|
|
199
|
+
Subtraction
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
shift_operator {
|
|
203
|
+
BitwiseShiftLeft |
|
|
204
|
+
BitwiseShiftRight
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
relational_operator {
|
|
208
|
+
RelationalLessThan |
|
|
209
|
+
RelationalLessThanOrEqual |
|
|
210
|
+
RelationalGreaterThan |
|
|
211
|
+
RelationalGreaterThanOrEqual
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
equality_operator {
|
|
215
|
+
RelationalEqual |
|
|
216
|
+
RelationalNotEqual
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
bitwise_operator {
|
|
220
|
+
BitwiseAnd |
|
|
221
|
+
BitwiseOr
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
logical_operator {
|
|
225
|
+
LogicalAnd |
|
|
226
|
+
LogicalOr
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
// 5.9 Expressions and evaluation
|
|
231
|
+
|
|
232
|
+
ArrayElementAccess {
|
|
233
|
+
OpenBracket expression CloseBracket
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
ClassMemberAccess {
|
|
237
|
+
Period Identifier
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
// Rule O.1: lengthof() Operator
|
|
242
|
+
|
|
243
|
+
LengthofExpression { keyword<"lengthof"> OpenParenthesis expression CloseParenthesis }
|
|
244
|
+
|
|
245
|
+
// includes Lezer precedence markers
|
|
246
|
+
|
|
247
|
+
UnaryExpression {
|
|
248
|
+
expression !array_element_access_precedence ArrayElementAccess |
|
|
249
|
+
expression !class_member_access_precedence ClassMemberAccess |
|
|
250
|
+
expression !postfix_operator_precedence postfix_operator |
|
|
251
|
+
unary_operator !unary_operator_precedence expression |
|
|
252
|
+
LengthofExpression !lengthof_precedence |
|
|
253
|
+
Identifier !identifier_precedence |
|
|
254
|
+
number_literal !number_literal_precedence |
|
|
255
|
+
OpenParenthesis expression CloseParenthesis
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// includes Lezer precedence markers
|
|
259
|
+
|
|
260
|
+
BinaryExpression {
|
|
261
|
+
expression !multiplicative_precedence multiplicative_operator expression |
|
|
262
|
+
expression !additive_precedence additive_operator expression |
|
|
263
|
+
expression !shift_precedence shift_operator expression |
|
|
264
|
+
expression !relational_precedence relational_operator expression |
|
|
265
|
+
expression !equality_precedence equality_operator expression |
|
|
266
|
+
expression !bitwise_precedence bitwise_operator expression |
|
|
267
|
+
expression !logical_precedence logical_operator expression
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
expression {
|
|
271
|
+
BinaryExpression |
|
|
272
|
+
UnaryExpression
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// Left hand operand must evaluate to a parsed variable value target, right hand operand must evaluate to a value source
|
|
276
|
+
|
|
277
|
+
AssignmentExpression {
|
|
278
|
+
expression Assignment expression
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
// 5.10 Statements
|
|
283
|
+
|
|
284
|
+
ExpressionStatement {
|
|
285
|
+
(expression | AssignmentExpression) Semicolon
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// Block scoping
|
|
289
|
+
|
|
290
|
+
CompoundStatement {
|
|
291
|
+
OpenBrace statement* CloseBrace
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
statement {
|
|
295
|
+
CompoundStatement |
|
|
296
|
+
IfStatement |
|
|
297
|
+
SwitchStatement |
|
|
298
|
+
ForStatement |
|
|
299
|
+
DoStatement |
|
|
300
|
+
WhileStatement |
|
|
301
|
+
ExpressionStatement |
|
|
302
|
+
ElementaryTypeDefinition |
|
|
303
|
+
MapDefinition |
|
|
304
|
+
ClassDefinition |
|
|
305
|
+
StringDefinition |
|
|
306
|
+
ArrayDefinition |
|
|
307
|
+
ComputedElementaryTypeDefinition |
|
|
308
|
+
ComputedArrayDefinition
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
// Rule S.4: Multiple character literal value
|
|
313
|
+
|
|
314
|
+
// 5.17 Integer, decimal and floating-point literal values
|
|
315
|
+
|
|
316
|
+
MultipleCharacterLiteralCharacters { escaped_multiple_character_literal_character* }
|
|
317
|
+
|
|
318
|
+
// One or more multiple character literals to support concatenation
|
|
319
|
+
|
|
320
|
+
MultipleCharacterLiteral { (SingleQuote MultipleCharacterLiteralCharacters SingleQuote)+ }
|
|
321
|
+
|
|
322
|
+
number_literal { BinaryLiteral | HexadecimalLiteral | MultipleCharacterLiteral | IntegerLiteral | DecimalLiteral | FloatingPointLiteral }
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
// 5.18 String literal values
|
|
326
|
+
|
|
327
|
+
UtfStringLiteralCharacters { (escaped_sdl_compatible_ucs_character | universal_character_name)* }
|
|
328
|
+
|
|
329
|
+
// One or more string literals to support concatenation
|
|
330
|
+
|
|
331
|
+
UtfStringLiteral { (UtfPrefix DoubleQuote UtfStringLiteralCharacters DoubleQuote)+ }
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
// 5.19 Scope
|
|
335
|
+
|
|
336
|
+
@top Specification {
|
|
337
|
+
(ClassDeclaration | MapDeclaration | ComputedElementaryTypeDefinition)*
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
// Rule E.1: Elementary data types
|
|
342
|
+
// Rule E.3: Legacy keyword
|
|
343
|
+
// Rule E.4: Reserved keyword
|
|
344
|
+
|
|
345
|
+
alignment_bit_count {
|
|
346
|
+
AlignmentBitCount8 | AlignmentBitCount16 | AlignmentBitCount32 | AlignmentBitCount64 | AlignmentBitCount128
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
AlignedModifier {
|
|
350
|
+
keyword<"aligned"> (OpenParenthesis alignment_bit_count CloseParenthesis)?
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
ElementaryType {
|
|
354
|
+
keyword<"int"> | keyword<"unsigned"> keyword<"int"> | keyword<"float"> | keyword<"bit">
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
LengthAttribute {
|
|
358
|
+
OpenParenthesis expression CloseParenthesis
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
ElementaryTypeDefinition {
|
|
362
|
+
(keyword<"reserved"> | keyword<"legacy">)? keyword<"const">? AlignedModifier? ElementaryType LengthAttribute LookAhead?
|
|
363
|
+
Identifier (Assignment expression (RangeOperator expression)?)? Semicolon
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
// Rule E.3: Maps
|
|
368
|
+
// Rule E.4: Mapped data types
|
|
369
|
+
// Rule E.5: Maps with escape codes
|
|
370
|
+
|
|
371
|
+
ElementaryTypeOutputValue {
|
|
372
|
+
ElementaryType LengthAttribute
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
output_value {
|
|
376
|
+
number_literal | ElementaryTypeOutputValue | AggregateOutputValue
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
AggregateOutputValue {
|
|
380
|
+
OpenBrace comma_separated<output_value> CloseBrace
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
MapEntry {
|
|
384
|
+
BinaryLiteral Comma AggregateOutputValue
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
MapDeclaration {
|
|
388
|
+
keyword<"map"> Identifier OpenParenthesis (ElementaryType | Identifier) CloseParenthesis
|
|
389
|
+
OpenBrace comma_separated<MapEntry> CloseBrace
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
MapDefinition {
|
|
393
|
+
(keyword<"reserved"> | keyword<"legacy">)? (ElementaryType | Identifier) RelationalLessThan Identifier RelationalGreaterThan Identifier Semicolon
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
// Rule E.6: String data types
|
|
398
|
+
|
|
399
|
+
// One or more string literals to support concatenation
|
|
400
|
+
|
|
401
|
+
Base64StringLiteralCharacters { base64_character* "="? "="? }
|
|
402
|
+
|
|
403
|
+
Base64StringLiteral {
|
|
404
|
+
(DoubleQuote Base64StringLiteralCharacters DoubleQuote)+
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// 6.7 String value
|
|
408
|
+
// One or more string literals to support concatenation
|
|
409
|
+
|
|
410
|
+
utf16_string_definition {
|
|
411
|
+
keyword<"utf16string"> Identifier (Assignment UtfStringLiteral)?
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
utf8_string_definition {
|
|
415
|
+
(keyword<"utf8string"> | keyword<"utf8list">) Identifier (Assignment UtfStringLiteral)?
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
utf_string_definition {
|
|
419
|
+
keyword<"utfstring"> Identifier (Assignment UtfStringLiteral)?
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
base64_string_definition {
|
|
423
|
+
keyword<"base64string"> Identifier (Assignment Base64StringLiteral)?
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
string_definition {
|
|
427
|
+
base64_string_definition |
|
|
428
|
+
utf16_string_definition |
|
|
429
|
+
utf8_string_definition |
|
|
430
|
+
utf_string_definition
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
StringDefinition {
|
|
434
|
+
(keyword<"reserved"> | keyword<"legacy">)? keyword<"const">? AlignedModifier? string_definition Semicolon
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
// Rule C.1: Classes
|
|
439
|
+
// Rule C.2: Class data types
|
|
440
|
+
// RULE C.3: Derived classes
|
|
441
|
+
// Rule C.4: Abstract classes
|
|
442
|
+
// Rule C.5: Class polymorphism
|
|
443
|
+
// Rule C.6: Expandable classes
|
|
444
|
+
// Rule C.7: Class parameter types
|
|
445
|
+
// Rule C.8: Parameterized class data types
|
|
446
|
+
|
|
447
|
+
ClassId {
|
|
448
|
+
IntegerLiteral
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
ClassIdRange {
|
|
452
|
+
ClassId RangeOperator ClassId
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
ExtendedClassIdRange {
|
|
456
|
+
comma_separated<(ClassId | ClassIdRange)>
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
BitModifier {
|
|
460
|
+
Colon keyword<"bit"> OpenParenthesis IntegerLiteral CloseParenthesis (Identifier Assignment)? ExtendedClassIdRange
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
ExpandableModifier {
|
|
464
|
+
keyword<"expandable"> (OpenParenthesis IntegerLiteral CloseParenthesis)?
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
Parameter {
|
|
468
|
+
(Identifier | ElementaryType) Identifier
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
ParameterList {
|
|
472
|
+
OpenParenthesis comma_separated<Parameter> CloseParenthesis
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
ParameterValueList {
|
|
476
|
+
OpenParenthesis comma_separated<expression> CloseParenthesis
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
ExtendsModifier {
|
|
480
|
+
keyword<"extends"> Identifier ParameterValueList?
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
ClassDeclaration {
|
|
484
|
+
AlignedModifier? ExpandableModifier? keyword<"abstract">? keyword<"class"> Identifier ParameterList? ExtendsModifier? BitModifier? OpenBrace
|
|
485
|
+
statement*
|
|
486
|
+
CloseBrace
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
ClassDefinition {
|
|
490
|
+
keyword<"legacy">? Identifier Identifier ParameterValueList? Semicolon
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
// Rule A.1: Arrays
|
|
495
|
+
// Rule A.2: Multi-dimensional arrays
|
|
496
|
+
// Rule A.3: Partial arrays
|
|
497
|
+
// Rule A.4: Partial multi-dimensional arrays
|
|
498
|
+
// Rule A.5: Implicit arrays
|
|
499
|
+
|
|
500
|
+
ExplicitArrayDimension {
|
|
501
|
+
OpenBracket expression CloseBracket
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
PartialArrayDimension {
|
|
505
|
+
OpenBracket OpenBracket expression CloseBracket CloseBracket
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
ImplicitArrayDimension {
|
|
509
|
+
OpenBracket (IntegerLiteral RangeOperator IntegerLiteral)? CloseBracket
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
ArrayDefinition {
|
|
513
|
+
(keyword<"reserved"> | keyword<"legacy">)? AlignedModifier? ((ElementaryType LengthAttribute) | Identifier) Identifier (ImplicitArrayDimension | (ExplicitArrayDimension | PartialArrayDimension)+) Semicolon
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
// Rule NP.1: Elementary data types
|
|
518
|
+
|
|
519
|
+
ComputedElementaryTypeDefinition {
|
|
520
|
+
keyword<"computed"> keyword<"const">? ElementaryType Identifier (Assignment expression)? Semicolon
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
// Rule NP.2: Arrays
|
|
525
|
+
// Rule NP.3: Multi-dimensional arrays
|
|
526
|
+
|
|
527
|
+
ComputedArrayDefinition {
|
|
528
|
+
keyword<"computed"> ElementaryType Identifier (ExplicitArrayDimension)+ Semicolon
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
// Rule FC.1: Flow control using if-then-else
|
|
533
|
+
|
|
534
|
+
IfStatement {
|
|
535
|
+
keyword<"if"> OpenParenthesis expression CloseParenthesis
|
|
536
|
+
statement
|
|
537
|
+
(!else_precedence keyword<"else"> statement)?
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
// Rule FC.2: Flow control using switch
|
|
542
|
+
|
|
543
|
+
CaseClause {
|
|
544
|
+
keyword<"case"> number_literal Colon
|
|
545
|
+
((statement* (keyword<"break"> Semicolon)?) | (OpenBrace statement* keyword<"break"> Semicolon CloseBrace))?
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
DefaultClause {
|
|
549
|
+
keyword<"default"> Colon
|
|
550
|
+
statement*
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
SwitchStatement {
|
|
554
|
+
keyword<"switch"> OpenParenthesis expression CloseParenthesis OpenBrace
|
|
555
|
+
CaseClause*
|
|
556
|
+
DefaultClause?
|
|
557
|
+
CloseBrace
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
// Rule FC.3: Flow control using for
|
|
562
|
+
|
|
563
|
+
ForStatement {
|
|
564
|
+
keyword<"for"> OpenParenthesis ((AssignmentExpression Semicolon) | ComputedElementaryTypeDefinition | Semicolon)
|
|
565
|
+
expression? Semicolon
|
|
566
|
+
(AssignmentExpression | expression)? CloseParenthesis
|
|
567
|
+
statement
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
// Rule FC.4: Flow control using do
|
|
572
|
+
|
|
573
|
+
DoStatement {
|
|
574
|
+
keyword<"do">
|
|
575
|
+
CompoundStatement
|
|
576
|
+
keyword<"while"> OpenParenthesis expression CloseParenthesis Semicolon
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
// Rule FC.5: Flow control using while
|
|
581
|
+
|
|
582
|
+
WhileStatement {
|
|
583
|
+
keyword<"while"> OpenParenthesis expression CloseParenthesis
|
|
584
|
+
statement
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
// Lezer precedence rule
|
|
589
|
+
|
|
590
|
+
@precedence {
|
|
591
|
+
array_element_access_precedence @left,
|
|
592
|
+
class_member_access_precedence @left,
|
|
593
|
+
postfix_operator_precedence @right,
|
|
594
|
+
unary_operator_precedence @right,
|
|
595
|
+
lengthof_precedence @right,
|
|
596
|
+
multiplicative_precedence @left,
|
|
597
|
+
additive_precedence @left,
|
|
598
|
+
shift_precedence @left,
|
|
599
|
+
relational_precedence @left,
|
|
600
|
+
equality_precedence @left,
|
|
601
|
+
bitwise_precedence @left,
|
|
602
|
+
logical_precedence @left,
|
|
603
|
+
identifier_precedence,
|
|
604
|
+
number_literal_precedence,
|
|
605
|
+
else_precedence @right
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
// Lezer template rules
|
|
610
|
+
|
|
611
|
+
keyword<term> {
|
|
612
|
+
@specialize[@name={term}]<Identifier, term>
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
comma_separated<content> {
|
|
616
|
+
content (Comma content)*
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
// Lezer skip expressions
|
|
620
|
+
|
|
621
|
+
@skip { Whitespace | Comment }
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
// Lezer directive to add openedBy and closedBy props to delimiters
|
|
625
|
+
|
|
626
|
+
@detectDelim
|
|
627
|
+
|
|
628
|
+
// Lezer context tracker insertion will be performed when buildParser is invoked
|
|
629
|
+
@context defaultContextTracker from "./context-tracker.ts"
|
package/index.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export * from "./src/ast/node/enum/array-dimension-kind.ts";
|
|
2
|
+
export * from "./src/ast/node/enum/binary-operator-kind.ts";
|
|
3
|
+
export * from "./src/ast/node/enum/class-id-kind.ts";
|
|
4
|
+
export * from "./src/ast/node/enum/elementary-type-kind.ts";
|
|
5
|
+
export * from "./src/ast/node/enum/expression-kind.ts";
|
|
6
|
+
export * from "./src/ast/node/enum/node-kind.ts";
|
|
7
|
+
export * from "./src/ast/node/enum/number-literal-kind.ts";
|
|
8
|
+
export * from "./src/ast/node/enum/statement-kind.ts";
|
|
9
|
+
export * from "./src/ast/node/enum/string-literal-kind.ts";
|
|
10
|
+
export * from "./src/ast/node/enum/string-variable-kind.ts";
|
|
11
|
+
export * from "./src/ast/node/abstract-array-definition.ts";
|
|
12
|
+
export * from "./src/ast/node/abstract-array-dimension.ts";
|
|
13
|
+
export * from "./src/ast/node/abstract-class-id.ts";
|
|
14
|
+
export * from "./src/ast/node/abstract-composite-node.ts";
|
|
15
|
+
export * from "./src/ast/node/abstract-elementary-type-definition.ts";
|
|
16
|
+
export * from "./src/ast/node/abstract-expression.ts";
|
|
17
|
+
export * from "./src/ast/node/abstract-leaf-node.ts";
|
|
18
|
+
export * from "./src/ast/node/abstract-node.ts";
|
|
19
|
+
export * from "./src/ast/node/abstract-statement.ts";
|
|
20
|
+
export * from "./src/ast/node/aggregate-output-value.ts";
|
|
21
|
+
export * from "./src/ast/node/aligned-modifier.ts";
|
|
22
|
+
export * from "./src/ast/node/array-definition.ts";
|
|
23
|
+
export * from "./src/ast/node/array-element-access.ts";
|
|
24
|
+
export * from "./src/ast/node/binary-expression.ts";
|
|
25
|
+
export * from "./src/ast/node/bit-modifier.ts";
|
|
26
|
+
export * from "./src/ast/node/case-clause.ts";
|
|
27
|
+
export * from "./src/ast/node/class-declaration.ts";
|
|
28
|
+
export * from "./src/ast/node/class-definition.ts";
|
|
29
|
+
export * from "./src/ast/node/class-id.ts";
|
|
30
|
+
export * from "./src/ast/node/class-id-range.ts";
|
|
31
|
+
export * from "./src/ast/node/class-member-access.ts";
|
|
32
|
+
export * from "./src/ast/node/compound-statement.ts";
|
|
33
|
+
export * from "./src/ast/node/computed-array-definition.ts";
|
|
34
|
+
export * from "./src/ast/node/computed-elementary-type-definition.ts";
|
|
35
|
+
export * from "./src/ast/node/default-clause.ts";
|
|
36
|
+
export * from "./src/ast/node/do-statement.ts";
|
|
37
|
+
export * from "./src/ast/node/elementary-type.ts";
|
|
38
|
+
export * from "./src/ast/node/elementary-type-definition.ts";
|
|
39
|
+
export * from "./src/ast/node/elementary-type-output-value.ts";
|
|
40
|
+
export * from "./src/ast/node/expandable-modifier.ts";
|
|
41
|
+
export * from "./src/ast/node/explicit-array-dimension.ts";
|
|
42
|
+
export * from "./src/ast/node/expression-statement.ts";
|
|
43
|
+
export * from "./src/ast/node/extended-class-id-range.ts";
|
|
44
|
+
export * from "./src/ast/node/extends-modifier.ts";
|
|
45
|
+
export * from "./src/ast/node/for-statement.ts";
|
|
46
|
+
export * from "./src/ast/node/identifier.ts";
|
|
47
|
+
export * from "./src/ast/node/if-statement.ts";
|
|
48
|
+
export * from "./src/ast/node/implicit-array-dimension.ts";
|
|
49
|
+
export * from "./src/ast/node/length-attribute.ts";
|
|
50
|
+
export * from "./src/ast/node/length-of-expression.ts";
|
|
51
|
+
export * from "./src/ast/node/map-declaration.ts";
|
|
52
|
+
export * from "./src/ast/node/map-definition.ts";
|
|
53
|
+
export * from "./src/ast/node/map-entry.ts";
|
|
54
|
+
export * from "./src/ast/node/number-literal.ts";
|
|
55
|
+
export * from "./src/ast/node/parameter.ts";
|
|
56
|
+
export * from "./src/ast/node/parameter-list.ts";
|
|
57
|
+
export * from "./src/ast/node/parameter-value-list.ts";
|
|
58
|
+
export * from "./src/ast/node/partial-array-dimension.ts";
|
|
59
|
+
export * from "./src/ast/node/specification.ts";
|
|
60
|
+
export * from "./src/ast/node/string-definition.ts";
|
|
61
|
+
export * from "./src/ast/node/string-literal.ts";
|
|
62
|
+
export * from "./src/ast/node/switch-statement.ts";
|
|
63
|
+
export * from "./src/ast/node/token.ts";
|
|
64
|
+
export * from "./src/ast/node/unary-expression.ts";
|
|
65
|
+
export * from "./src/ast/node/while-statement.ts";
|
|
66
|
+
export * from "./src/ast/node/trivia.ts";
|
|
67
|
+
export * from "./src/ast/visitor/node-handler.ts";
|
|
68
|
+
export * from "./src/ast/visitor/node-visitor.ts";
|
|
69
|
+
export * from "./src/ast/visitor/traversing-visitor.ts";
|
|
70
|
+
export * from "./src/lezer/create-sdl-parser.ts";
|
|
71
|
+
export * from "./src/lezer/sdl-string-input.ts";
|
|
72
|
+
export * from "./src/prettier/prettier-plugin-sdl.ts";
|
|
73
|
+
export * from "./src/location.ts";
|
|
74
|
+
export * from "./src/scanner-error.ts";
|
|
75
|
+
export * from "./src/parse-helper.ts";
|
|
76
|
+
export * from "./src/ast/build-ast.ts";
|
|
77
|
+
export { createSyntaxErrorFromTextAndCursor } from "./src/lezer/create-syntax-error-from-text-and-cursor.ts";
|
|
78
|
+
export { getPotentialTokenTypeIds } from "./src/completion/get-potential-token-type-ids.ts";
|
|
79
|
+
export { getPotentialSyntacticTokens } from "./src/completion/get-potential-syntactic-tokens.ts";
|
|
80
|
+
export * from "./src/analyser/create-sdl-analyser.ts";
|
|
81
|
+
|
|
82
|
+
// Generated by Lezer from the SDL grammar
|
|
83
|
+
export * as TokenTypeId from "./src/lezer/parser.terms.ts";
|