@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,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enum representing different kinds of nodes.
|
|
3
|
+
*/
|
|
4
|
+
export enum NodeKind {
|
|
5
|
+
/** Error placeholder for unexpected node */
|
|
6
|
+
UNEXPECTED_ERROR = -1,
|
|
7
|
+
/** Output value node */
|
|
8
|
+
AGGREGATE_OUTPUT_VALUE,
|
|
9
|
+
/** Aligned modifier node */
|
|
10
|
+
ALIGNED_MODIFIER,
|
|
11
|
+
/** Array dimension node */
|
|
12
|
+
ARRAY_DIMENSION,
|
|
13
|
+
/** Array element access node */
|
|
14
|
+
ARRAY_ELEMENT_ACCESS,
|
|
15
|
+
/** Bit modifier node */
|
|
16
|
+
BIT_MODIFIER,
|
|
17
|
+
/** Switch case clause node */
|
|
18
|
+
CASE_CLAUSE,
|
|
19
|
+
/** Class ID node */
|
|
20
|
+
CLASS_ID,
|
|
21
|
+
/** Class member access node */
|
|
22
|
+
CLASS_MEMBER_ACCESS,
|
|
23
|
+
/** Switch default clause node */
|
|
24
|
+
DEFAULT_CLAUSE,
|
|
25
|
+
/** Elementary type node */
|
|
26
|
+
ELEMENTARY_TYPE,
|
|
27
|
+
/** Elementary type output value node */
|
|
28
|
+
ELEMENTARY_TYPE_OUTPUT_VALUE,
|
|
29
|
+
/** Expandable modifier node */
|
|
30
|
+
EXPANDABLE_MODIFIER,
|
|
31
|
+
/** Expression node */
|
|
32
|
+
EXPRESSION,
|
|
33
|
+
/** Extends modifier node */
|
|
34
|
+
EXTENDS_MODIFIER,
|
|
35
|
+
/** Identifier node */
|
|
36
|
+
IDENTIFIER,
|
|
37
|
+
/** Length attribute node */
|
|
38
|
+
LENGTH_ATTRIBUTE,
|
|
39
|
+
/** Map entry node */
|
|
40
|
+
MAP_ENTRY,
|
|
41
|
+
/** Number literal node */
|
|
42
|
+
NUMBER_LITERAL,
|
|
43
|
+
/** Parameter node */
|
|
44
|
+
PARAMETER,
|
|
45
|
+
/** Parameter list node */
|
|
46
|
+
PARAMETER_LIST,
|
|
47
|
+
/** Parameter value list node */
|
|
48
|
+
PARAMETER_VALUE_LIST,
|
|
49
|
+
/** Specification node */
|
|
50
|
+
SPECIFICATION,
|
|
51
|
+
/** Statement node */
|
|
52
|
+
STATEMENT,
|
|
53
|
+
/** String literal node */
|
|
54
|
+
STRING_LITERAL,
|
|
55
|
+
/** Syntax token node */
|
|
56
|
+
TOKEN,
|
|
57
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enum representing different kinds of number literals.
|
|
3
|
+
*/
|
|
4
|
+
export enum NumberLiteralKind {
|
|
5
|
+
/** Binary number literal */
|
|
6
|
+
BINARY,
|
|
7
|
+
/** Hexadecimal number literal */
|
|
8
|
+
HEXADECIMAL,
|
|
9
|
+
/** Integer number literal */
|
|
10
|
+
INTEGER,
|
|
11
|
+
/** Decimal number literal */
|
|
12
|
+
DECIMAL,
|
|
13
|
+
/** Multiple character number literal */
|
|
14
|
+
MULTIPLE_CHARACTER,
|
|
15
|
+
/** Floating point number literal */
|
|
16
|
+
FLOATING_POINT,
|
|
17
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enum representing different kinds of statements.
|
|
3
|
+
*/
|
|
4
|
+
export enum StatementKind {
|
|
5
|
+
/** Array definition statement */
|
|
6
|
+
ARRAY_DEFINITION,
|
|
7
|
+
/** Computed array definition statement */
|
|
8
|
+
COMPUTED_ARRAY_DEFINITION,
|
|
9
|
+
/** Computed elementary type definition statement */
|
|
10
|
+
COMPUTED_ELEMENTARY_TYPE_DEFINITION,
|
|
11
|
+
/** Class declaration statement */
|
|
12
|
+
CLASS_DECLARATION,
|
|
13
|
+
/** Class definition statement */
|
|
14
|
+
CLASS_DEFINITION,
|
|
15
|
+
/** Compound statement */
|
|
16
|
+
COMPOUND,
|
|
17
|
+
/** Do statement */
|
|
18
|
+
DO,
|
|
19
|
+
/** Elementary type definition statement */
|
|
20
|
+
ELEMENTARY_TYPE_DEFINITION,
|
|
21
|
+
/** Expression statement */
|
|
22
|
+
EXPRESSION,
|
|
23
|
+
/** For statement */
|
|
24
|
+
FOR,
|
|
25
|
+
/** If statement */
|
|
26
|
+
IF,
|
|
27
|
+
/** Map declaration statement */
|
|
28
|
+
MAP_DECLARATION,
|
|
29
|
+
/** Map definition statement */
|
|
30
|
+
MAP_DEFINITION,
|
|
31
|
+
/** String definition statement */
|
|
32
|
+
STRING_DEFINITION,
|
|
33
|
+
/** Switch statement */
|
|
34
|
+
SWITCH,
|
|
35
|
+
/** While statement */
|
|
36
|
+
WHILE,
|
|
37
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enum representing the kinds of string variables.
|
|
3
|
+
*/
|
|
4
|
+
export enum StringVariableKind {
|
|
5
|
+
/**
|
|
6
|
+
* Represents a UTF-8 string variable.
|
|
7
|
+
*/
|
|
8
|
+
UTF8,
|
|
9
|
+
/**
|
|
10
|
+
* Represents a UTF-16 string variable.
|
|
11
|
+
*/
|
|
12
|
+
UTF16,
|
|
13
|
+
/**
|
|
14
|
+
* Represents a UTF string variable.
|
|
15
|
+
*/
|
|
16
|
+
UTF,
|
|
17
|
+
/**
|
|
18
|
+
* Represents a list of UTF-8 string variables.
|
|
19
|
+
*/
|
|
20
|
+
UTF8_LIST,
|
|
21
|
+
/**
|
|
22
|
+
* Represents a Base64 encoded string variable.
|
|
23
|
+
*/
|
|
24
|
+
BASE64,
|
|
25
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This enum is used to categorize different types of tokens.
|
|
3
|
+
*/
|
|
4
|
+
export enum TokenKind {
|
|
5
|
+
ERROR_UNKNOWN_TOKEN = -2,
|
|
6
|
+
ERROR_MISSING_TOKEN = -1,
|
|
7
|
+
ABSTRACT,
|
|
8
|
+
ADDITION,
|
|
9
|
+
ALIGNED,
|
|
10
|
+
ALIGNMENT_BIT_COUNT_8,
|
|
11
|
+
ALIGNMENT_BIT_COUNT_16,
|
|
12
|
+
ALIGNMENT_BIT_COUNT_32,
|
|
13
|
+
ALIGNMENT_BIT_COUNT_64,
|
|
14
|
+
ALIGNMENT_BIT_COUNT_128,
|
|
15
|
+
ASSIGNMENT,
|
|
16
|
+
BASE64_STRING,
|
|
17
|
+
BASE64_STRING_LITERAL_CHARACTERS,
|
|
18
|
+
BINARY_LITERAL,
|
|
19
|
+
BIT,
|
|
20
|
+
BITWISE_AND,
|
|
21
|
+
BITWISE_OR,
|
|
22
|
+
BITWISE_SHIFT_LEFT,
|
|
23
|
+
BITWISE_SHIFT_RIGHT,
|
|
24
|
+
BREAK,
|
|
25
|
+
CASE,
|
|
26
|
+
CLASS,
|
|
27
|
+
CLOSE_BRACE,
|
|
28
|
+
CLOSE_BRACKET,
|
|
29
|
+
CLOSE_PARENTHESIS,
|
|
30
|
+
COLON,
|
|
31
|
+
COMMA,
|
|
32
|
+
COMPUTED,
|
|
33
|
+
CONST,
|
|
34
|
+
DECIMAL_LITERAL,
|
|
35
|
+
DEFAULT,
|
|
36
|
+
DIVISION,
|
|
37
|
+
DO,
|
|
38
|
+
DOUBLE_QUOTE,
|
|
39
|
+
ELSE,
|
|
40
|
+
EXPANDABLE,
|
|
41
|
+
EXTENDS,
|
|
42
|
+
FLOAT,
|
|
43
|
+
FLOATING_POINT_LITERAL,
|
|
44
|
+
FOR,
|
|
45
|
+
HEXADECIMAL_LITERAL,
|
|
46
|
+
IDENTIFIER,
|
|
47
|
+
IF,
|
|
48
|
+
INT,
|
|
49
|
+
INTEGER_LITERAL,
|
|
50
|
+
LEGACY,
|
|
51
|
+
LENGTHOF,
|
|
52
|
+
LOGICAL_AND,
|
|
53
|
+
LOGICAL_OR,
|
|
54
|
+
LOOK_AHEAD,
|
|
55
|
+
MAP,
|
|
56
|
+
MODULUS,
|
|
57
|
+
MULTIPLE_CHARACTER_LITERAL_CHARACTERS,
|
|
58
|
+
MULTIPLICATION,
|
|
59
|
+
OPEN_BRACE,
|
|
60
|
+
OPEN_BRACKET,
|
|
61
|
+
OPEN_PARENTHESIS,
|
|
62
|
+
PERIOD,
|
|
63
|
+
POSTFIX_DECREMENT,
|
|
64
|
+
POSTFIX_INCREMENT,
|
|
65
|
+
RANGE_OPERATOR,
|
|
66
|
+
RELATIONAL_EQUAL,
|
|
67
|
+
RELATIONAL_GREATER_THAN,
|
|
68
|
+
RELATIONAL_GREATER_THAN_OR_EQUAL,
|
|
69
|
+
RELATIONAL_LESS_THAN,
|
|
70
|
+
RELATIONAL_LESS_THAN_OR_EQUAL,
|
|
71
|
+
RELATIONAL_NOT_EQUAL,
|
|
72
|
+
RESERVED,
|
|
73
|
+
SEMICOLON,
|
|
74
|
+
SINGLE_QUOTE,
|
|
75
|
+
SUBTRACTION,
|
|
76
|
+
SWITCH,
|
|
77
|
+
UNARY_NEGATION,
|
|
78
|
+
UNARY_PLUS,
|
|
79
|
+
UNSIGNED,
|
|
80
|
+
UTF_PREFIX,
|
|
81
|
+
UTF_STRING,
|
|
82
|
+
UTF_STRING_LITERAL_CHARACTERS,
|
|
83
|
+
UTF8_LIST,
|
|
84
|
+
UTF8_STRING,
|
|
85
|
+
UTF16_STRING,
|
|
86
|
+
WHILE,
|
|
87
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { OptionalNode, RequiredNode } from "../util/types.ts";
|
|
2
|
+
import { AbstractCompositeNode } from "./abstract-composite-node.ts";
|
|
3
|
+
import type { AbstractNode } from "./abstract-node.ts";
|
|
4
|
+
import { NodeKind } from "./enum/node-kind.ts";
|
|
5
|
+
import type { NumberLiteral } from "./number-literal.ts";
|
|
6
|
+
import type { Token } from "./token.ts";
|
|
7
|
+
|
|
8
|
+
export class ExpandableModifier extends AbstractCompositeNode {
|
|
9
|
+
constructor(
|
|
10
|
+
public readonly expandableKeyword: RequiredNode<Token>,
|
|
11
|
+
public readonly openParenthesisPunctuator: OptionalNode<Token>,
|
|
12
|
+
public readonly maxClassSize: OptionalNode<NumberLiteral>,
|
|
13
|
+
public readonly closeParenthesisPunctuator: OptionalNode<Token>,
|
|
14
|
+
children: Array<AbstractNode>,
|
|
15
|
+
) {
|
|
16
|
+
super(
|
|
17
|
+
NodeKind.EXPANDABLE_MODIFIER,
|
|
18
|
+
children,
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { RequiredNode } from "../util/types.ts";
|
|
2
|
+
import { AbstractArrayDimension } from "./abstract-array-dimension.ts";
|
|
3
|
+
import type { AbstractExpression } from "./abstract-expression.ts";
|
|
4
|
+
import type { AbstractNode } from "./abstract-node.ts";
|
|
5
|
+
import { ArrayDimensionKind } from "./enum/array-dimension-kind.ts";
|
|
6
|
+
import type { Identifier } from "./identifier.ts";
|
|
7
|
+
import type { NumberLiteral } from "./number-literal.ts";
|
|
8
|
+
import type { Token } from "./token.ts";
|
|
9
|
+
|
|
10
|
+
export class ExplicitArrayDimension extends AbstractArrayDimension {
|
|
11
|
+
constructor(
|
|
12
|
+
openBracketPunctuator: RequiredNode<Token>,
|
|
13
|
+
public readonly size: RequiredNode<
|
|
14
|
+
AbstractExpression | Identifier | NumberLiteral
|
|
15
|
+
>,
|
|
16
|
+
closeBracketPunctuator: RequiredNode<Token>,
|
|
17
|
+
children: Array<AbstractNode>,
|
|
18
|
+
) {
|
|
19
|
+
super(
|
|
20
|
+
ArrayDimensionKind.EXPLICIT,
|
|
21
|
+
openBracketPunctuator,
|
|
22
|
+
closeBracketPunctuator,
|
|
23
|
+
children,
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AbstractStatement } from "./abstract-statement.ts";
|
|
2
|
+
import { StatementKind } from "./enum/statement-kind.ts";
|
|
3
|
+
import type { NumberLiteral } from "./number-literal.ts";
|
|
4
|
+
import type { AbstractExpression } from "./abstract-expression.ts";
|
|
5
|
+
import type { Identifier } from "./identifier.ts";
|
|
6
|
+
import type { AbstractNode } from "./abstract-node.ts";
|
|
7
|
+
import type { Token } from "./token.ts";
|
|
8
|
+
import type { RequiredNode } from "../util/types.ts";
|
|
9
|
+
|
|
10
|
+
export class ExpressionStatement extends AbstractStatement {
|
|
11
|
+
constructor(
|
|
12
|
+
public readonly expression: RequiredNode<
|
|
13
|
+
AbstractExpression | Identifier | NumberLiteral
|
|
14
|
+
>,
|
|
15
|
+
public readonly semicolonPunctuator: RequiredNode<Token>,
|
|
16
|
+
children: Array<AbstractNode>,
|
|
17
|
+
) {
|
|
18
|
+
super(
|
|
19
|
+
StatementKind.EXPRESSION,
|
|
20
|
+
children,
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AbstractClassId } from "./abstract-class-id.ts";
|
|
2
|
+
import type { ClassId } from "./class-id.ts";
|
|
3
|
+
import type { ClassIdRange } from "./class-id-range.ts";
|
|
4
|
+
import { ClassIdKind } from "./enum/class-id-kind.ts";
|
|
5
|
+
import type { AbstractNode } from "./abstract-node.ts";
|
|
6
|
+
import type { Token } from "./token.ts";
|
|
7
|
+
import type { OneToManyList, ZeroToManyList } from "../util/types.ts";
|
|
8
|
+
|
|
9
|
+
export class ExtendedClassIdRange extends AbstractClassId {
|
|
10
|
+
constructor(
|
|
11
|
+
public readonly classIds: OneToManyList<ClassId | ClassIdRange>,
|
|
12
|
+
public readonly commaPunctuators: ZeroToManyList<Token>,
|
|
13
|
+
children: Array<AbstractNode>,
|
|
14
|
+
) {
|
|
15
|
+
super(
|
|
16
|
+
ClassIdKind.EXTENDED_RANGE,
|
|
17
|
+
children,
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { OptionalNode, RequiredNode } from "../util/types.ts";
|
|
2
|
+
import { AbstractCompositeNode } from "./abstract-composite-node.ts";
|
|
3
|
+
import type { AbstractNode } from "./abstract-node.ts";
|
|
4
|
+
import { NodeKind } from "./enum/node-kind.ts";
|
|
5
|
+
import type { Identifier } from "./identifier.ts";
|
|
6
|
+
import type { ParameterValueList } from "./parameter-value-list.ts";
|
|
7
|
+
import type { Token } from "./token.ts";
|
|
8
|
+
|
|
9
|
+
export class ExtendsModifier extends AbstractCompositeNode {
|
|
10
|
+
constructor(
|
|
11
|
+
public readonly extendsKeyword: RequiredNode<Token>,
|
|
12
|
+
public readonly identifier: RequiredNode<Identifier>,
|
|
13
|
+
public readonly parameterValueList: OptionalNode<ParameterValueList>,
|
|
14
|
+
children: Array<AbstractNode>,
|
|
15
|
+
) {
|
|
16
|
+
super(
|
|
17
|
+
NodeKind.EXTENDS_MODIFIER,
|
|
18
|
+
children,
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { OptionalNode, RequiredNode } from "../util/types.ts";
|
|
2
|
+
import type { AbstractExpression } from "./abstract-expression.ts";
|
|
3
|
+
import type { AbstractNode } from "./abstract-node.ts";
|
|
4
|
+
import { AbstractStatement } from "./abstract-statement.ts";
|
|
5
|
+
import type { ComputedElementaryTypeDefinition } from "./computed-elementary-type-definition.ts";
|
|
6
|
+
import { StatementKind } from "./enum/statement-kind.ts";
|
|
7
|
+
import type { Token } from "./token.ts";
|
|
8
|
+
|
|
9
|
+
export class ForStatement extends AbstractStatement {
|
|
10
|
+
constructor(
|
|
11
|
+
public readonly forKeyword: RequiredNode<Token>,
|
|
12
|
+
public readonly openParenthesisPunctuator: RequiredNode<Token>,
|
|
13
|
+
// either ((assignment_expression semicolon) | computed_elementary_type_definition | semicolon)
|
|
14
|
+
public readonly expression1: OptionalNode<AbstractExpression>,
|
|
15
|
+
public readonly computedElementaryDefinition: OptionalNode<
|
|
16
|
+
ComputedElementaryTypeDefinition
|
|
17
|
+
>,
|
|
18
|
+
// optional as the first semicolon can be considered part of the optional computedElementaryDefinition
|
|
19
|
+
public readonly semicolon1Punctuator: OptionalNode<Token>,
|
|
20
|
+
public readonly expression2: OptionalNode<AbstractExpression>,
|
|
21
|
+
public readonly semicolon2Punctuator: RequiredNode<Token>,
|
|
22
|
+
public readonly expression3: OptionalNode<AbstractExpression>,
|
|
23
|
+
public readonly closeParenthesisPunctuator: RequiredNode<Token>,
|
|
24
|
+
public readonly statement: RequiredNode<AbstractStatement>,
|
|
25
|
+
children: Array<AbstractNode>,
|
|
26
|
+
) {
|
|
27
|
+
super(StatementKind.FOR, children);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AbstractCompositeNode } from "./abstract-composite-node.ts";
|
|
2
|
+
import { NodeKind } from "./enum/node-kind.ts";
|
|
3
|
+
import type { Token } from "./token.ts";
|
|
4
|
+
|
|
5
|
+
export class Identifier extends AbstractCompositeNode {
|
|
6
|
+
constructor(
|
|
7
|
+
public readonly name: string,
|
|
8
|
+
token: Token,
|
|
9
|
+
) {
|
|
10
|
+
super(NodeKind.IDENTIFIER, [token]);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { OptionalNode, RequiredNode } from "../util/types.ts";
|
|
2
|
+
import type { AbstractExpression } from "./abstract-expression.ts";
|
|
3
|
+
import type { AbstractNode } from "./abstract-node.ts";
|
|
4
|
+
import { AbstractStatement } from "./abstract-statement.ts";
|
|
5
|
+
import { StatementKind } from "./enum/statement-kind.ts";
|
|
6
|
+
import type { Identifier } from "./identifier.ts";
|
|
7
|
+
import type { NumberLiteral } from "./number-literal.ts";
|
|
8
|
+
import type { Token } from "./token.ts";
|
|
9
|
+
|
|
10
|
+
export class IfStatement extends AbstractStatement {
|
|
11
|
+
constructor(
|
|
12
|
+
public readonly ifKeyword: RequiredNode<Token>,
|
|
13
|
+
public readonly openParenthesisPunctuator: RequiredNode<Token>,
|
|
14
|
+
public readonly condition: RequiredNode<
|
|
15
|
+
AbstractExpression | Identifier | NumberLiteral
|
|
16
|
+
>,
|
|
17
|
+
public readonly closeParenthesisPunctuator: RequiredNode<Token>,
|
|
18
|
+
public readonly ifStatement: RequiredNode<AbstractStatement>,
|
|
19
|
+
public readonly elseKeyword: OptionalNode<Token>,
|
|
20
|
+
public readonly elseStatement: OptionalNode<AbstractStatement>,
|
|
21
|
+
children: Array<AbstractNode>,
|
|
22
|
+
) {
|
|
23
|
+
super(
|
|
24
|
+
StatementKind.IF,
|
|
25
|
+
children,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { OptionalNode, RequiredNode } from "../util/types.ts";
|
|
2
|
+
import { AbstractArrayDimension } from "./abstract-array-dimension.ts";
|
|
3
|
+
import type { AbstractExpression } from "./abstract-expression.ts";
|
|
4
|
+
import type { AbstractNode } from "./abstract-node.ts";
|
|
5
|
+
import { ArrayDimensionKind } from "./enum/array-dimension-kind.ts";
|
|
6
|
+
import type { Identifier } from "./identifier.ts";
|
|
7
|
+
import type { NumberLiteral } from "./number-literal.ts";
|
|
8
|
+
import type { Token } from "./token.ts";
|
|
9
|
+
|
|
10
|
+
export class ImplicitArrayDimension extends AbstractArrayDimension {
|
|
11
|
+
constructor(
|
|
12
|
+
openBracketPunctuator: RequiredNode<Token>,
|
|
13
|
+
public readonly rangeStart: OptionalNode<
|
|
14
|
+
| AbstractExpression
|
|
15
|
+
| Identifier
|
|
16
|
+
| NumberLiteral
|
|
17
|
+
>,
|
|
18
|
+
public readonly rangeOperator: OptionalNode<Token>,
|
|
19
|
+
public readonly rangeEnd: OptionalNode<
|
|
20
|
+
| AbstractExpression
|
|
21
|
+
| Identifier
|
|
22
|
+
| NumberLiteral
|
|
23
|
+
>,
|
|
24
|
+
closeBracketPunctuator: RequiredNode<Token>,
|
|
25
|
+
children: Array<AbstractNode>,
|
|
26
|
+
) {
|
|
27
|
+
super(
|
|
28
|
+
ArrayDimensionKind.IMPLICIT,
|
|
29
|
+
openBracketPunctuator,
|
|
30
|
+
closeBracketPunctuator,
|
|
31
|
+
children,
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { RequiredNode } from "../util/types.ts";
|
|
2
|
+
import { AbstractCompositeNode } from "./abstract-composite-node.ts";
|
|
3
|
+
import type { AbstractExpression } from "./abstract-expression.ts";
|
|
4
|
+
import type { AbstractNode } from "./abstract-node.ts";
|
|
5
|
+
import { NodeKind } from "./enum/node-kind.ts";
|
|
6
|
+
import type { Identifier } from "./identifier.ts";
|
|
7
|
+
import type { NumberLiteral } from "./number-literal.ts";
|
|
8
|
+
import type { Token } from "./token.ts";
|
|
9
|
+
|
|
10
|
+
export class LengthAttribute extends AbstractCompositeNode {
|
|
11
|
+
constructor(
|
|
12
|
+
public readonly openParenthesisPunctuator: RequiredNode<Token>,
|
|
13
|
+
public readonly length: RequiredNode<
|
|
14
|
+
NumberLiteral | Identifier | AbstractExpression
|
|
15
|
+
>,
|
|
16
|
+
public readonly closeParenthesisPunctuator: RequiredNode<Token>,
|
|
17
|
+
children: Array<AbstractNode>,
|
|
18
|
+
) {
|
|
19
|
+
super(
|
|
20
|
+
NodeKind.LENGTH_ATTRIBUTE,
|
|
21
|
+
children,
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { RequiredNode } from "../util/types.ts";
|
|
2
|
+
import { AbstractExpression } from "./abstract-expression.ts";
|
|
3
|
+
import type { AbstractNode } from "./abstract-node.ts";
|
|
4
|
+
import { ExpressionKind } from "./enum/expression-kind.ts";
|
|
5
|
+
import type { Identifier } from "./identifier.ts";
|
|
6
|
+
import type { Token } from "./token.ts";
|
|
7
|
+
|
|
8
|
+
export class LengthofExpression extends AbstractExpression {
|
|
9
|
+
constructor(
|
|
10
|
+
public readonly lengthOfKeyword: RequiredNode<Token>,
|
|
11
|
+
public readonly openParenthesisPunctuator: RequiredNode<Token>,
|
|
12
|
+
public readonly operand: RequiredNode<AbstractExpression | Identifier>,
|
|
13
|
+
public readonly closeParenthesisPunctuator: RequiredNode<Token>,
|
|
14
|
+
children: Array<AbstractNode>,
|
|
15
|
+
) {
|
|
16
|
+
super(
|
|
17
|
+
ExpressionKind.LENGTHOF,
|
|
18
|
+
children,
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
OneToManyList,
|
|
3
|
+
OptionalNode,
|
|
4
|
+
RequiredNode,
|
|
5
|
+
ZeroToManyList,
|
|
6
|
+
} from "../util/types.ts";
|
|
7
|
+
import type { AbstractNode } from "./abstract-node.ts";
|
|
8
|
+
import { AbstractStatement } from "./abstract-statement.ts";
|
|
9
|
+
import type { ElementaryType } from "./elementary-type.ts";
|
|
10
|
+
import { StatementKind } from "./enum/statement-kind.ts";
|
|
11
|
+
import type { Identifier } from "./identifier.ts";
|
|
12
|
+
import type { MapEntry } from "./map-entry.ts";
|
|
13
|
+
import type { Token } from "./token.ts";
|
|
14
|
+
|
|
15
|
+
export class MapDeclaration extends AbstractStatement {
|
|
16
|
+
constructor(
|
|
17
|
+
public readonly mapKeyword: RequiredNode<Token>,
|
|
18
|
+
public readonly identifier: RequiredNode<Identifier>,
|
|
19
|
+
public readonly openParenthesisPunctuator: RequiredNode<Token>,
|
|
20
|
+
public readonly outputElementaryType: OptionalNode<ElementaryType>,
|
|
21
|
+
public readonly outputClassIdentifier: OptionalNode<Identifier>,
|
|
22
|
+
public readonly closeParenthesisPunctuator: RequiredNode<Token>,
|
|
23
|
+
public readonly openBracePunctuator: RequiredNode<Token>,
|
|
24
|
+
public readonly mapEntries: OneToManyList<MapEntry>,
|
|
25
|
+
public readonly commaPunctuators: ZeroToManyList<Token>,
|
|
26
|
+
public readonly closeBracePunctuator: RequiredNode<Token>,
|
|
27
|
+
children: Array<AbstractNode>,
|
|
28
|
+
) {
|
|
29
|
+
super(
|
|
30
|
+
StatementKind.MAP_DECLARATION,
|
|
31
|
+
children,
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { OptionalNode, RequiredNode } from "../util/types.ts";
|
|
2
|
+
import type { AbstractNode } from "./abstract-node.ts";
|
|
3
|
+
import { AbstractStatement } from "./abstract-statement.ts";
|
|
4
|
+
import type { ElementaryType } from "./elementary-type.ts";
|
|
5
|
+
import { StatementKind } from "./enum/statement-kind.ts";
|
|
6
|
+
import type { Identifier } from "./identifier.ts";
|
|
7
|
+
import type { Token } from "./token.ts";
|
|
8
|
+
|
|
9
|
+
export class MapDefinition extends AbstractStatement {
|
|
10
|
+
constructor(
|
|
11
|
+
public readonly reservedKeyword: OptionalNode<Token>,
|
|
12
|
+
public readonly legacyKeyword: OptionalNode<Token>,
|
|
13
|
+
public readonly elementaryType: OptionalNode<ElementaryType>,
|
|
14
|
+
public readonly classIdentifier: OptionalNode<Identifier>,
|
|
15
|
+
public readonly relationalLessThanPunctuator: RequiredNode<Token>,
|
|
16
|
+
public readonly mapIdentifier: RequiredNode<Identifier>,
|
|
17
|
+
public readonly relationalGreaterThanPunctuator: RequiredNode<Token>,
|
|
18
|
+
public readonly identifier: RequiredNode<Identifier>,
|
|
19
|
+
public readonly semicolonPunctuator: RequiredNode<Token>,
|
|
20
|
+
children: Array<AbstractNode>,
|
|
21
|
+
) {
|
|
22
|
+
super(
|
|
23
|
+
StatementKind.MAP_DEFINITION,
|
|
24
|
+
children,
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { RequiredNode } from "../util/types.ts";
|
|
2
|
+
import { AbstractCompositeNode } from "./abstract-composite-node.ts";
|
|
3
|
+
import type { AbstractNode } from "./abstract-node.ts";
|
|
4
|
+
import type { AggregateOutputValue } from "./aggregate-output-value.ts";
|
|
5
|
+
import { NodeKind } from "./enum/node-kind.ts";
|
|
6
|
+
import type { NumberLiteral } from "./number-literal.ts";
|
|
7
|
+
import type { Token } from "./token.ts";
|
|
8
|
+
|
|
9
|
+
export class MapEntry extends AbstractCompositeNode {
|
|
10
|
+
constructor(
|
|
11
|
+
public readonly inputValue: RequiredNode<NumberLiteral>,
|
|
12
|
+
public readonly commaPunctuator: RequiredNode<Token>,
|
|
13
|
+
public readonly outputValue: RequiredNode<AggregateOutputValue>,
|
|
14
|
+
children: Array<AbstractNode>,
|
|
15
|
+
) {
|
|
16
|
+
super(NodeKind.MAP_ENTRY, children);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TokenKind } from "./enum/token-kind.ts";
|
|
2
|
+
import { Token } from "./token.ts";
|
|
3
|
+
import type { Location } from "../../location.ts";
|
|
4
|
+
|
|
5
|
+
export class MissingError extends Token {
|
|
6
|
+
constructor(location: Location) {
|
|
7
|
+
super(TokenKind.ERROR_MISSING_TOKEN, "", location);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { OneToManyList } from "../util/types.ts";
|
|
2
|
+
import { AbstractCompositeNode } from "./abstract-composite-node.ts";
|
|
3
|
+
import { NodeKind } from "./enum/node-kind.ts";
|
|
4
|
+
import type { NumberLiteralKind } from "./enum/number-literal-kind.ts";
|
|
5
|
+
import type { Token } from "./token.ts";
|
|
6
|
+
|
|
7
|
+
export class NumberLiteral extends AbstractCompositeNode {
|
|
8
|
+
constructor(
|
|
9
|
+
public readonly numberLiteralKind: NumberLiteralKind,
|
|
10
|
+
public readonly value: number,
|
|
11
|
+
// defined as an array to support multiple concatenated multiple character literal tokens
|
|
12
|
+
public readonly literals: OneToManyList<Token>,
|
|
13
|
+
) {
|
|
14
|
+
super(NodeKind.NUMBER_LITERAL, literals);
|
|
15
|
+
this.numberLiteralKind = numberLiteralKind;
|
|
16
|
+
this.value = value;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
OneToManyList,
|
|
3
|
+
RequiredNode,
|
|
4
|
+
ZeroToManyList,
|
|
5
|
+
} from "../util/types.ts";
|
|
6
|
+
import { AbstractCompositeNode } from "./abstract-composite-node.ts";
|
|
7
|
+
import type { AbstractNode } from "./abstract-node.ts";
|
|
8
|
+
import { NodeKind } from "./enum/node-kind.ts";
|
|
9
|
+
import type { Parameter } from "./parameter.ts";
|
|
10
|
+
import type { Token } from "./token.ts";
|
|
11
|
+
|
|
12
|
+
export class ParameterList extends AbstractCompositeNode {
|
|
13
|
+
constructor(
|
|
14
|
+
public readonly openParenthesisPunctuator: RequiredNode<Token>,
|
|
15
|
+
public readonly parameters: OneToManyList<Parameter>,
|
|
16
|
+
public readonly commaPunctuators: ZeroToManyList<Token>,
|
|
17
|
+
public readonly closeParenthesisPunctuator: RequiredNode<Token>,
|
|
18
|
+
children: Array<AbstractNode>,
|
|
19
|
+
) {
|
|
20
|
+
super(
|
|
21
|
+
NodeKind.PARAMETER_LIST,
|
|
22
|
+
children,
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
}
|