aas-core-codegen 0.0.16__py3-none-any.whl
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.
- aas_core_codegen/__init__.py +6 -0
- aas_core_codegen/__main__.py +8 -0
- aas_core_codegen/common.py +500 -0
- aas_core_codegen/cpp/__init__.py +1 -0
- aas_core_codegen/cpp/aas_common/__init__.py +6 -0
- aas_core_codegen/cpp/aas_common/_generate.py +713 -0
- aas_core_codegen/cpp/common.py +681 -0
- aas_core_codegen/cpp/constants/__init__.py +6 -0
- aas_core_codegen/cpp/constants/_generate.py +568 -0
- aas_core_codegen/cpp/description.py +654 -0
- aas_core_codegen/cpp/enhancing/__init__.py +4 -0
- aas_core_codegen/cpp/enhancing/_generate.py +993 -0
- aas_core_codegen/cpp/iteration/__init__.py +6 -0
- aas_core_codegen/cpp/iteration/_generate.py +2332 -0
- aas_core_codegen/cpp/jsonization/__init__.py +6 -0
- aas_core_codegen/cpp/jsonization/_generate.py +2619 -0
- aas_core_codegen/cpp/main.py +694 -0
- aas_core_codegen/cpp/naming.py +170 -0
- aas_core_codegen/cpp/optionaling.py +557 -0
- aas_core_codegen/cpp/pattern/__init__.py +6 -0
- aas_core_codegen/cpp/pattern/_generate.py +508 -0
- aas_core_codegen/cpp/revm/__init__.py +6 -0
- aas_core_codegen/cpp/revm/_generate.py +1149 -0
- aas_core_codegen/cpp/stringification/__init__.py +5 -0
- aas_core_codegen/cpp/stringification/_generate.py +955 -0
- aas_core_codegen/cpp/structure/__init__.py +7 -0
- aas_core_codegen/cpp/structure/_generate.py +1503 -0
- aas_core_codegen/cpp/transpilation.py +1383 -0
- aas_core_codegen/cpp/unrolling.py +159 -0
- aas_core_codegen/cpp/verification/__init__.py +6 -0
- aas_core_codegen/cpp/verification/_generate.py +3073 -0
- aas_core_codegen/cpp/visitation/__init__.py +6 -0
- aas_core_codegen/cpp/visitation/_generate.py +521 -0
- aas_core_codegen/cpp/wstringification/__init__.py +5 -0
- aas_core_codegen/cpp/wstringification/_generate.py +586 -0
- aas_core_codegen/cpp/xmlization/__init__.py +6 -0
- aas_core_codegen/cpp/xmlization/_generate.py +5373 -0
- aas_core_codegen/cpp/yielding.py +201 -0
- aas_core_codegen/csharp/__init__.py +1 -0
- aas_core_codegen/csharp/common.py +224 -0
- aas_core_codegen/csharp/constants/__init__.py +5 -0
- aas_core_codegen/csharp/constants/_generate.py +409 -0
- aas_core_codegen/csharp/copying/__init__.py +4 -0
- aas_core_codegen/csharp/copying/_generate.py +498 -0
- aas_core_codegen/csharp/description.py +1103 -0
- aas_core_codegen/csharp/enhancing/__init__.py +4 -0
- aas_core_codegen/csharp/enhancing/_generate.py +667 -0
- aas_core_codegen/csharp/jsonization/__init__.py +4 -0
- aas_core_codegen/csharp/jsonization/_generate.py +1630 -0
- aas_core_codegen/csharp/main.py +421 -0
- aas_core_codegen/csharp/naming.py +157 -0
- aas_core_codegen/csharp/reporting/__init__.py +4 -0
- aas_core_codegen/csharp/reporting/_generate.py +266 -0
- aas_core_codegen/csharp/stringification/__init__.py +4 -0
- aas_core_codegen/csharp/stringification/_generate.py +243 -0
- aas_core_codegen/csharp/structure/__init__.py +6 -0
- aas_core_codegen/csharp/structure/_generate.py +1341 -0
- aas_core_codegen/csharp/transpilation.py +990 -0
- aas_core_codegen/csharp/unrolling.py +211 -0
- aas_core_codegen/csharp/verification/__init__.py +6 -0
- aas_core_codegen/csharp/verification/_generate.py +1457 -0
- aas_core_codegen/csharp/visitation/__init__.py +5 -0
- aas_core_codegen/csharp/visitation/_generate.py +579 -0
- aas_core_codegen/csharp/xmlization/__init__.py +4 -0
- aas_core_codegen/csharp/xmlization/_generate.py +1980 -0
- aas_core_codegen/golang/__init__.py +1 -0
- aas_core_codegen/golang/aas_common/__init__.py +4 -0
- aas_core_codegen/golang/aas_common/_generate.py +152 -0
- aas_core_codegen/golang/common.py +303 -0
- aas_core_codegen/golang/constants/__init__.py +5 -0
- aas_core_codegen/golang/constants/_generate.py +339 -0
- aas_core_codegen/golang/description.py +501 -0
- aas_core_codegen/golang/enhancing/__init__.py +4 -0
- aas_core_codegen/golang/enhancing/_generate.py +527 -0
- aas_core_codegen/golang/jsonization/__init__.py +4 -0
- aas_core_codegen/golang/jsonization/_generate.py +1740 -0
- aas_core_codegen/golang/main.py +368 -0
- aas_core_codegen/golang/naming.py +412 -0
- aas_core_codegen/golang/pointering.py +631 -0
- aas_core_codegen/golang/reporting/__init__.py +4 -0
- aas_core_codegen/golang/reporting/_generate.py +218 -0
- aas_core_codegen/golang/stringification/__init__.py +4 -0
- aas_core_codegen/golang/stringification/_generate.py +394 -0
- aas_core_codegen/golang/structure/__init__.py +6 -0
- aas_core_codegen/golang/structure/_generate.py +1493 -0
- aas_core_codegen/golang/transpilation.py +1191 -0
- aas_core_codegen/golang/unrolling.py +159 -0
- aas_core_codegen/golang/verification/__init__.py +6 -0
- aas_core_codegen/golang/verification/_generate.py +1513 -0
- aas_core_codegen/golang/xmlization/__init__.py +4 -0
- aas_core_codegen/golang/xmlization/_generate.py +2507 -0
- aas_core_codegen/infer_for_schema/__init__.py +21 -0
- aas_core_codegen/infer_for_schema/_inline.py +693 -0
- aas_core_codegen/infer_for_schema/_len.py +527 -0
- aas_core_codegen/infer_for_schema/_pattern.py +311 -0
- aas_core_codegen/infer_for_schema/_set.py +394 -0
- aas_core_codegen/infer_for_schema/_stringify.py +201 -0
- aas_core_codegen/infer_for_schema/_types.py +135 -0
- aas_core_codegen/infer_for_schema/match.py +122 -0
- aas_core_codegen/intermediate/__init__.py +78 -0
- aas_core_codegen/intermediate/_hierarchy.py +397 -0
- aas_core_codegen/intermediate/_stringify.py +989 -0
- aas_core_codegen/intermediate/_translate.py +5128 -0
- aas_core_codegen/intermediate/_types.py +2901 -0
- aas_core_codegen/intermediate/construction.py +750 -0
- aas_core_codegen/intermediate/doc.py +344 -0
- aas_core_codegen/intermediate/pattern_verification.py +428 -0
- aas_core_codegen/intermediate/revm.py +985 -0
- aas_core_codegen/intermediate/type_inference.py +2266 -0
- aas_core_codegen/java/__init__.py +1 -0
- aas_core_codegen/java/common.py +197 -0
- aas_core_codegen/java/constants/__init__.py +5 -0
- aas_core_codegen/java/constants/_generate.py +334 -0
- aas_core_codegen/java/copying/__init__.py +4 -0
- aas_core_codegen/java/copying/_generate.py +502 -0
- aas_core_codegen/java/description.py +774 -0
- aas_core_codegen/java/enhancing/__init__.py +4 -0
- aas_core_codegen/java/enhancing/_generate.py +820 -0
- aas_core_codegen/java/generation/__init__.py +5 -0
- aas_core_codegen/java/generation/_generate.py +285 -0
- aas_core_codegen/java/jsonization/__init__.py +4 -0
- aas_core_codegen/java/jsonization/_generate.py +1472 -0
- aas_core_codegen/java/main.py +438 -0
- aas_core_codegen/java/naming.py +187 -0
- aas_core_codegen/java/optional.py +514 -0
- aas_core_codegen/java/reporting/__init__.py +4 -0
- aas_core_codegen/java/reporting/_generate.py +248 -0
- aas_core_codegen/java/stringification/__init__.py +4 -0
- aas_core_codegen/java/stringification/_generate.py +212 -0
- aas_core_codegen/java/structure/__init__.py +6 -0
- aas_core_codegen/java/structure/_generate.py +1767 -0
- aas_core_codegen/java/transpilation.py +1111 -0
- aas_core_codegen/java/verification/__init__.py +6 -0
- aas_core_codegen/java/verification/_generate.py +1536 -0
- aas_core_codegen/java/visitation/__init__.py +5 -0
- aas_core_codegen/java/visitation/_generate.py +689 -0
- aas_core_codegen/java/xmlization/__init__.py +4 -0
- aas_core_codegen/java/xmlization/_generate.py +2274 -0
- aas_core_codegen/jsonld/__init__.py +1 -0
- aas_core_codegen/jsonld/main.py +455 -0
- aas_core_codegen/jsonschema/__init__.py +1 -0
- aas_core_codegen/jsonschema/main.py +982 -0
- aas_core_codegen/main.py +245 -0
- aas_core_codegen/naming.py +133 -0
- aas_core_codegen/opcua/__init__.py +1 -0
- aas_core_codegen/opcua/main.py +1525 -0
- aas_core_codegen/opcua/naming.py +126 -0
- aas_core_codegen/parse/__init__.py +46 -0
- aas_core_codegen/parse/_rules.py +796 -0
- aas_core_codegen/parse/_stringify.py +532 -0
- aas_core_codegen/parse/_translate.py +3940 -0
- aas_core_codegen/parse/_types.py +973 -0
- aas_core_codegen/parse/retree/__init__.py +46 -0
- aas_core_codegen/parse/retree/_fix.py +434 -0
- aas_core_codegen/parse/retree/_parse.py +1143 -0
- aas_core_codegen/parse/retree/_render.py +298 -0
- aas_core_codegen/parse/retree/_stringify.py +199 -0
- aas_core_codegen/parse/retree/_types.py +362 -0
- aas_core_codegen/parse/retree/_visitor.py +70 -0
- aas_core_codegen/parse/tree.py +1303 -0
- aas_core_codegen/protobuf/__init__.py +1 -0
- aas_core_codegen/protobuf/common.py +225 -0
- aas_core_codegen/protobuf/description.py +1102 -0
- aas_core_codegen/protobuf/main.py +115 -0
- aas_core_codegen/protobuf/naming.py +143 -0
- aas_core_codegen/protobuf/structure/__init__.py +6 -0
- aas_core_codegen/protobuf/structure/_generate.py +502 -0
- aas_core_codegen/py.typed +1 -0
- aas_core_codegen/python/__init__.py +1 -0
- aas_core_codegen/python/aas_common/__init__.py +4 -0
- aas_core_codegen/python/aas_common/_generate.py +63 -0
- aas_core_codegen/python/common.py +406 -0
- aas_core_codegen/python/constants/__init__.py +5 -0
- aas_core_codegen/python/constants/_generate.py +377 -0
- aas_core_codegen/python/description.py +508 -0
- aas_core_codegen/python/jsonization/__init__.py +4 -0
- aas_core_codegen/python/jsonization/_generate.py +1391 -0
- aas_core_codegen/python/main.py +323 -0
- aas_core_codegen/python/naming.py +255 -0
- aas_core_codegen/python/stringification/__init__.py +4 -0
- aas_core_codegen/python/stringification/_generate.py +129 -0
- aas_core_codegen/python/structure/__init__.py +6 -0
- aas_core_codegen/python/structure/_generate.py +1801 -0
- aas_core_codegen/python/transpilation.py +958 -0
- aas_core_codegen/python/unrolling.py +156 -0
- aas_core_codegen/python/verification/__init__.py +6 -0
- aas_core_codegen/python/verification/_generate.py +1471 -0
- aas_core_codegen/python/xmlization/__init__.py +4 -0
- aas_core_codegen/python/xmlization/_generate.py +3003 -0
- aas_core_codegen/python_protobuf/__init__.py +1 -0
- aas_core_codegen/python_protobuf/main.py +1424 -0
- aas_core_codegen/python_protobuf/naming.py +85 -0
- aas_core_codegen/rdf_shacl/__init__.py +1 -0
- aas_core_codegen/rdf_shacl/_description.py +351 -0
- aas_core_codegen/rdf_shacl/common.py +206 -0
- aas_core_codegen/rdf_shacl/main.py +114 -0
- aas_core_codegen/rdf_shacl/naming.py +145 -0
- aas_core_codegen/rdf_shacl/rdf.py +435 -0
- aas_core_codegen/rdf_shacl/shacl.py +453 -0
- aas_core_codegen/run.py +124 -0
- aas_core_codegen/smoke/__init__.py +1 -0
- aas_core_codegen/smoke/main.py +219 -0
- aas_core_codegen/specific_implementations.py +72 -0
- aas_core_codegen/stringify.py +333 -0
- aas_core_codegen/typescript/__init__.py +1 -0
- aas_core_codegen/typescript/aas_common/__init__.py +4 -0
- aas_core_codegen/typescript/aas_common/_generate.py +472 -0
- aas_core_codegen/typescript/common.py +340 -0
- aas_core_codegen/typescript/constants/__init__.py +5 -0
- aas_core_codegen/typescript/constants/_generate.py +347 -0
- aas_core_codegen/typescript/description.py +530 -0
- aas_core_codegen/typescript/jsonization/__init__.py +4 -0
- aas_core_codegen/typescript/jsonization/_generate.py +1510 -0
- aas_core_codegen/typescript/main.py +258 -0
- aas_core_codegen/typescript/naming.py +189 -0
- aas_core_codegen/typescript/stringification/__init__.py +4 -0
- aas_core_codegen/typescript/stringification/_generate.py +367 -0
- aas_core_codegen/typescript/structure/__init__.py +6 -0
- aas_core_codegen/typescript/structure/_generate.py +2500 -0
- aas_core_codegen/typescript/transpilation.py +1051 -0
- aas_core_codegen/typescript/unrolling.py +159 -0
- aas_core_codegen/typescript/verification/__init__.py +6 -0
- aas_core_codegen/typescript/verification/_generate.py +1578 -0
- aas_core_codegen/xsd/__init__.py +1 -0
- aas_core_codegen/xsd/main.py +1187 -0
- aas_core_codegen/xsd/naming.py +83 -0
- aas_core_codegen/yielding/__init__.py +1 -0
- aas_core_codegen/yielding/flow.py +139 -0
- aas_core_codegen/yielding/linear.py +754 -0
- aas_core_codegen-0.0.16.dist-info/METADATA +211 -0
- aas_core_codegen-0.0.16.dist-info/RECORD +604 -0
- aas_core_codegen-0.0.16.dist-info/WHEEL +5 -0
- aas_core_codegen-0.0.16.dist-info/entry_points.txt +3 -0
- aas_core_codegen-0.0.16.dist-info/licenses/AUTHORS +9 -0
- aas_core_codegen-0.0.16.dist-info/licenses/LICENSE +23 -0
- aas_core_codegen-0.0.16.dist-info/top_level.txt +2 -0
- dev/continuous_integration/__init__.py +1 -0
- dev/continuous_integration/check_help_in_readme.py +208 -0
- dev/continuous_integration/check_init_and_pyproject_consistent.py +154 -0
- dev/continuous_integration/precommit.py +400 -0
- dev/dev_scripts/__init__.py +1 -0
- dev/dev_scripts/compare_rendered_regexes_against_source_py.py +42 -0
- dev/dev_scripts/copy_to_aas_core3_cpp.py +100 -0
- dev/dev_scripts/copy_to_aas_core3_java.py +90 -0
- dev/dev_scripts/download_latest_aas_core_meta_v3.py +114 -0
- dev/dev_scripts/draw_bipartite_graph_based_on_lines.py +37 -0
- dev/dev_scripts/run_tests_with_rerecord.py +69 -0
- dev/dev_scripts/update_to_aas_core_meta.py +174 -0
- dev/integration_tests/input/jsonschema/boilerplate/main.py +55 -0
- dev/integration_tests/input/meta_model.py +38 -0
- dev/integration_tests/input/python/boilerplate/main.py +153 -0
- dev/integration_tests/main.py +258 -0
- dev/test_data/csharp/test_structure/concrete_class_with_descendants/meta_model.py +15 -0
- dev/test_data/csharp/test_structure/constructor_without_arguments/all_properties_optional/meta_model.py +9 -0
- dev/test_data/csharp/test_structure/constructor_without_arguments/no_properties/meta_model.py +6 -0
- dev/test_data/csharp/test_verification/builtin_functions/len/on_list/meta_model.py +20 -0
- dev/test_data/csharp/test_verification/builtin_functions/len/on_str/meta_model.py +16 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/as_prefix/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/as_suffix/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/in_group_with_quantifier/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/in_the_middle/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/in_union/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/single_utf32_literal/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/with_quantifier_within_group/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/with_quantifier_without_group/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/at_the_beginning/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/at_the_end/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/in_the_middle/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/multiple/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/single/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/single_with_quantifier/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/mixed_with_non_utf32/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/more_than_two_high_surrogates/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/multiple_utf32_ranges/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/multiple_utf32_ranges_mixed_with_non_utf32/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/same_high_surrogate/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/same_high_surrogate_with_quantifier/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/two_high_surrogates/meta_model.py +8 -0
- dev/test_data/intermediate/expected/class/empty/meta_model.py +6 -0
- dev/test_data/intermediate/expected/class/implementation_specific_method/meta_model.py +8 -0
- dev/test_data/intermediate/expected/class/inheritance/meta_model.py +41 -0
- dev/test_data/intermediate/expected/class/methods_with_contracts/meta_model.py +15 -0
- dev/test_data/intermediate/expected/class/only_method_no_property/meta_model.py +7 -0
- dev/test_data/intermediate/expected/class/only_property_no_method/meta_model.py +9 -0
- dev/test_data/intermediate/expected/constant/constant_set/of_enum/meta_model.py +12 -0
- dev/test_data/intermediate/expected/constant/constant_set/of_str/meta_model.py +4 -0
- dev/test_data/intermediate/expected/constant/constant_set/with_description/meta_model.py +6 -0
- dev/test_data/intermediate/expected/constant/constant_set/with_superset_of/meta_model.py +14 -0
- dev/test_data/intermediate/expected/constant/constant_str/only_value/meta_model.py +7 -0
- dev/test_data/intermediate/expected/constant/constant_str/with_description/meta_model.py +5 -0
- dev/test_data/intermediate/expected/documentation/docstring_with_special_characters_in_literal/meta_model.py +20 -0
- dev/test_data/intermediate/expected/documentation/docstring_with_special_characters_outside_literal/meta_model.py +20 -0
- dev/test_data/intermediate/expected/empty/meta_model.py +2 -0
- dev/test_data/intermediate/expected/enumeration/meta_model.py +9 -0
- dev/test_data/intermediate/expected/interface/basic/meta_model.py +14 -0
- dev/test_data/intermediate/expected/interface/empty/meta_model.py +7 -0
- dev/test_data/intermediate/expected/interface/inheritance/meta_model.py +27 -0
- dev/test_data/intermediate/expected/interface/method_signature/meta_model.py +10 -0
- dev/test_data/intermediate/expected/interface/only_constructor/meta_model.py +11 -0
- dev/test_data/intermediate/expected/method/non_mutating/implementation_specific/meta_model.py +12 -0
- dev/test_data/intermediate/expected/method/non_mutating/understood/meta_model.py +11 -0
- dev/test_data/intermediate/expected/type_annotation/atomic/meta_model.py +9 -0
- dev/test_data/intermediate/expected/type_annotation/subscripted/class/meta_model.py +13 -0
- dev/test_data/intermediate/expected/type_annotation/subscripted/primitive/meta_model.py +9 -0
- dev/test_data/intermediate/unexpected/constant_set/of_enum/enumeration_literals_in_subset_outside_of_superset/meta_model.py +20 -0
- dev/test_data/intermediate/unexpected/constant_set/of_enum/invalid_literal/meta_model.py +11 -0
- dev/test_data/intermediate/unexpected/constant_set/of_enum/mismatch_between_enumeration_and_literal/meta_model.py +30 -0
- dev/test_data/intermediate/unexpected/constant_set/of_enum/mismatch_in_enumerations_between_subset_and_superset/meta_model.py +21 -0
- dev/test_data/intermediate/unexpected/constant_set/of_str/literals_in_subset_outside_of_superset/meta_model.py +18 -0
- dev/test_data/intermediate/unexpected/constant_set/of_str/mismatch_between_type_annotation_and_literals/meta_model.py +10 -0
- dev/test_data/intermediate/unexpected/constant_set/of_str/superset_and_subset_mismatch_in_type/meta_model.py +12 -0
- dev/test_data/intermediate/unexpected/constraints/dangling_constraintref/meta_model.py +18 -0
- dev/test_data/intermediate/unexpected/constraints/duplicate_constraints/meta_model.py +20 -0
- dev/test_data/intermediate/unexpected/documentation/unexpected_documentation_elements/meta_model.py +34 -0
- dev/test_data/intermediate/unexpected/invariant/class_invariant_uses_re/meta_model.py +10 -0
- dev/test_data/intermediate/unexpected/invariant/invariant_of_constrained_primitive_uses_re/meta_model.py +7 -0
- dev/test_data/intermediate/unexpected/invariant/unexpected_argument_count_to_len/meta_model.py +20 -0
- dev/test_data/intermediate/unexpected/invariant/unhandled_built_in_function/meta_model.py +16 -0
- dev/test_data/intermediate/unexpected/method_definitions/non_constant_default/meta_model.py +7 -0
- dev/test_data/intermediate/unexpected/optional_constructor_arguments_wo_default/default_non_none/meta_model.py +16 -0
- dev/test_data/intermediate/unexpected/optional_constructor_arguments_wo_default/no_default/meta_model.py +16 -0
- dev/test_data/intermediate/unexpected/properties_and_constructor_arguments_do_not_match/after_inheritance/meta_model.py +58 -0
- dev/test_data/intermediate/unexpected/properties_and_constructor_arguments_do_not_match/type_missmatch/meta_model.py +9 -0
- dev/test_data/intermediate/unexpected/properties_and_constructor_arguments_do_not_match/within_class/meta_model.py +22 -0
- dev/test_data/jsonschema/test_main/regression_when_len_constraints_on_inherited_property/meta_model.py +28 -0
- dev/test_data/opcua/test_main/abstract_and_concrete_classes/meta_model.py +37 -0
- dev/test_data/opcua/test_main/classes_with_invariants/meta_model.py +21 -0
- dev/test_data/opcua/test_main/concrete_class_with_descendant/meta_model.py +27 -0
- dev/test_data/opcua/test_main/concrete_class_with_enum/meta_model.py +21 -0
- dev/test_data/opcua/test_main/concrete_class_with_list_of_instances/meta_model.py +21 -0
- dev/test_data/opcua/test_main/concrete_class_with_primitive_attributes/meta_model.py +41 -0
- dev/test_data/opcua/test_main/concrete_class_with_string/meta_model.py +13 -0
- dev/test_data/opcua/test_main/constrained_primitive/meta_model.py +20 -0
- dev/test_data/opcua/test_main/multiple_inheritance/meta_model.py +25 -0
- dev/test_data/parse/expected/constant/constant_set/of_enum/meta_model.py +12 -0
- dev/test_data/parse/expected/constant/constant_set/of_str/meta_model.py +4 -0
- dev/test_data/parse/expected/constant/constant_set/with_description/meta_model.py +6 -0
- dev/test_data/parse/expected/constant/constant_set/with_superset_of/meta_model.py +14 -0
- dev/test_data/parse/expected/constant/constant_str/only_value/meta_model.py +7 -0
- dev/test_data/parse/expected/constant/constant_str/with_description/meta_model.py +5 -0
- dev/test_data/parse/expected/enum/ok/meta_model.py +15 -0
- dev/test_data/parse/expected/implementation_specific_class/properties_and_methods_in_implementation_specific_class/meta_model.py +17 -0
- dev/test_data/parse/expected/inheritance/basic/meta_model.py +11 -0
- dev/test_data/parse/expected/inheritance/diamond/meta_model.py +26 -0
- dev/test_data/parse/expected/inheritance/inheritance_from_concrete_class/meta_model.py +10 -0
- dev/test_data/parse/expected/invariants/in_relation/meta_model.py +16 -0
- dev/test_data/parse/expected/method/arguments/meta_model.py +7 -0
- dev/test_data/parse/expected/method/basic/meta_model.py +7 -0
- dev/test_data/parse/expected/method/contracts/condition_as_keyword_argument/meta_model.py +8 -0
- dev/test_data/parse/expected/method/contracts/condition_as_positional_argument/meta_model.py +8 -0
- dev/test_data/parse/expected/method/contracts/description_as_keyword_argument/meta_model.py +8 -0
- dev/test_data/parse/expected/method/contracts/description_as_positional_argument/meta_model.py +8 -0
- dev/test_data/parse/expected/method/contracts/multiple_contracts_in_order/meta_model.py +17 -0
- dev/test_data/parse/expected/method/contracts/postcondition/basic/meta_model.py +10 -0
- dev/test_data/parse/expected/method/contracts/postcondition/snapshot/with_keyword_arguments/meta_model.py +9 -0
- dev/test_data/parse/expected/method/contracts/postcondition/snapshot/with_positional_arguments/meta_model.py +9 -0
- dev/test_data/parse/expected/method/default/meta_model.py +9 -0
- dev/test_data/parse/expected/method/description/meta_model.py +8 -0
- dev/test_data/parse/expected/method/is_implementation_specific/meta_model.py +8 -0
- dev/test_data/parse/expected/method/non_mutating/meta_model.py +11 -0
- dev/test_data/parse/expected/method/returns_none/meta_model.py +7 -0
- dev/test_data/parse/expected/method/returns_something/meta_model.py +7 -0
- dev/test_data/parse/expected/single_class/description/meta_model.py +12 -0
- dev/test_data/parse/expected/single_class/empty/meta_model.py +6 -0
- dev/test_data/parse/expected/single_class/property/description/meta_model.py +14 -0
- dev/test_data/parse/expected/single_class/property/mandatory/meta_model.py +6 -0
- dev/test_data/parse/expected/single_class/property/optional/meta_model.py +6 -0
- dev/test_data/parse/expected/single_class/property/recursion_to_entity/meta_model.py +6 -0
- dev/test_data/parse/unexpected/class_decorators/non_name_decorator/meta_model.py +7 -0
- dev/test_data/parse/unexpected/class_decorators/unknown_decorator/meta_model.py +7 -0
- dev/test_data/parse/unexpected/class_definitions/is_abstract_and_implementation_specific/meta_model.py +8 -0
- dev/test_data/parse/unexpected/class_definitions/unexpected_docstring_before_a_method/meta_model.py +11 -0
- dev/test_data/parse/unexpected/class_definitions/unexpected_docstring_for_a_pass/meta_model.py +9 -0
- dev/test_data/parse/unexpected/class_definitions/unexpected_double_description_for_a_property/meta_model.py +10 -0
- dev/test_data/parse/unexpected/class_inheritances/inheriting_from_implementation_specific_parent/meta_model.py +20 -0
- dev/test_data/parse/unexpected/class_inheritances/non_name_super_class/meta_model.py +6 -0
- dev/test_data/parse/unexpected/enum/expression_as_assignment_value/meta_model.py +6 -0
- dev/test_data/parse/unexpected/enum/non_assignment/meta_model.py +8 -0
- dev/test_data/parse/unexpected/enum/non_string_literal/meta_model.py +6 -0
- dev/test_data/parse/unexpected/enum/unexpected_inheritance/meta_model.py +6 -0
- dev/test_data/parse/unexpected/method_contracts/contract/non_lambda_condition/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/contract/non_string_literal_description/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/contract/without_any_arguments/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/contract/without_condition/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/postcondition/OLD_in_postcondition_without_snapshot/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/postcondition/argument_missing_in_function/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/precondition/argument_missing_in_function/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/snapshot/argument_missing_in_function/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/snapshot/capture_not_a_lambda/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/snapshot/invalid_name/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/snapshot/name_not_a_string_literal/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/snapshot/without_a_capture/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/snapshot/without_a_name/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_decorators/non_mutating/non_mutating_constructor/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_decorators/non_mutating/non_mutating_verification_function/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_decorators/non_name_decorator/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_decorators/unknown_call_decorator/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_decorators/unknown_name_decorator/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_definitions/argument_with_final/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/argument_without_a_type_annotation/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/default_for_self/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/dunder/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/init_with_return_type/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/with_keyword_only_arguments/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/with_positional_arguments/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/with_type_annotation_for_self/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/with_variable_arguments/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/with_variable_keyword_arguments/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/without_arguments/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/without_self/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/without_type_annotation_for_result/meta_model.py +7 -0
- dev/test_data/parse/unexpected/property_definitions/final_without_subscript/meta_model.py +6 -0
- dev/test_data/parse/unexpected/property_definitions/nested_final/meta_model.py +6 -0
- dev/test_data/parse/unexpected/property_definitions/non_simple/meta_model.py +6 -0
- dev/test_data/parse/unexpected/property_definitions/unexpected_assignment/meta_model.py +6 -0
- dev/test_data/parse/unexpected/property_definitions/unexpected_non_name_property/meta_model.py +6 -0
- dev/test_data/parse/unexpected/property_definitions/without_type_annotation/meta_model.py +6 -0
- dev/test_data/parse/unexpected/symbol_table/constant_set_with_a_non_set_subset/meta_model.py +6 -0
- dev/test_data/parse/unexpected/symbol_table/dangling_inheritance/meta_model.py +6 -0
- dev/test_data/parse/unexpected/symbol_table/dangling_reference_in_type_annotation_of_a_property/meta_model.py +6 -0
- dev/test_data/parse/unexpected/symbol_table/dangling_reference_in_type_annotation_of_an_argument/meta_model.py +7 -0
- dev/test_data/parse/unexpected/symbol_table/dangling_reference_in_type_annotation_of_constant_set/meta_model.py +6 -0
- dev/test_data/parse/unexpected/symbol_table/dangling_subset_in_constant_set/meta_model.py +4 -0
- dev/test_data/parse/unexpected/symbol_table/inheritance_from_non_class/meta_model.py +10 -0
- dev/test_data/parse_retree/expected/character_set/common_escaping/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/complementing/double_caret/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/complementing/multiple_ranges/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/complementing/suffix_dash/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/escape_first_caret/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/literals_which_need_no_escaping_in_characters_set_but_need_escaping_outside/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/multiple_ranges/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/single_literal/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/single_range/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/unescaped_dash/only_dash/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/unescaped_dash/prefix_dash/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/unescaped_dash/suffix_dash/source.py +1 -0
- dev/test_data/parse_retree/expected/dot/source.py +1 -0
- dev/test_data/parse_retree/expected/empty/group/source.py +1 -0
- dev/test_data/parse_retree/expected/empty/group_in_a_group/source.py +1 -0
- dev/test_data/parse_retree/expected/empty/group_of_union_of_empty_concatenations/source.py +1 -0
- dev/test_data/parse_retree/expected/empty/regex/source.py +1 -0
- dev/test_data/parse_retree/expected/empty/union_of_empty_concatenations/source.py +1 -0
- dev/test_data/parse_retree/expected/escaped_literals/source.py +1 -0
- dev/test_data/parse_retree/expected/formatted_value/at_the_beginning/source.py +1 -0
- dev/test_data/parse_retree/expected/formatted_value/at_the_end/source.py +1 -0
- dev/test_data/parse_retree/expected/formatted_value/in_the_middle/source.py +1 -0
- dev/test_data/parse_retree/expected/formatted_value/single_formatted_value/source.py +1 -0
- dev/test_data/parse_retree/expected/literal/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/greedy/at_least_3/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/greedy/at_least_one/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/greedy/at_most_3/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/greedy/exactly_3/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/greedy/maybe/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/greedy/zero_or_more/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/non_greedy/at_least_3/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/non_greedy/at_least_one/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/non_greedy/at_most_3/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/non_greedy/exactly_3/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/non_greedy/maybe/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/non_greedy/zero_or_more/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/on_a_character_set/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/on_a_formatted_value/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/on_a_group/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/on_a_literal/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/double_end_symbol/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/double_start_symbol/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/end_symbol_in_the_middle/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/only_start_symbol/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/only_stop_symbol/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/start_symbol_at_the_beginning/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/start_symbol_in_the_middle/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/stop_symbol_at_the_end/source.py +1 -0
- dev/test_data/parse_retree/expected/union/of_character_sets/source.py +1 -0
- dev/test_data/parse_retree/expected/union/of_groups/source.py +1 -0
- dev/test_data/parse_retree/expected/union/of_string_literals/source.py +1 -0
- dev/test_data/parse_retree/expected/union/within_group/source.py +1 -0
- dev/test_data/parse_retree/expected/whitespace/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/Uxxxxxxxx_out_of_range/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/only_backslash/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/short_Uxxxxxxxx/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/short_uxxxx/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/short_x/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unexpected_escaping/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/digit/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/not_digit/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/not_whitespace/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/not_word/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/whitespace/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/word/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/Uxxxxxxxx_out_of_range/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/only_backslash/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/short_Uxxxxxxxx/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/short_uxxxx/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/short_x/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unexpected_escaping/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/digit/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/not_digit/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/not_whitespace/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/not_word/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/whitespace/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/word/source.py +1 -0
- dev/test_data/parse_retree/unexpected/invalid_character_range/source.py +1 -0
- dev/test_data/parse_retree/unexpected/invalid_quantifier/at_least_x/source.py +1 -0
- dev/test_data/parse_retree/unexpected/invalid_quantifier/between_3_and_x/source.py +1 -0
- dev/test_data/parse_retree/unexpected/invalid_quantifier/exactly_x/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unhandled_group_directives/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unterminated/character_set/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unterminated/group/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unterminated/group_of_union_of_empty_concatenations/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unterminated/quantifier/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unterminated/quantifier_with_comma/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unterminated/quantifier_with_number_and_comma/source.py +1 -0
- dev/test_data/proto/test_main/expected/abstract_and_concrete_classes/meta_model.py +37 -0
- dev/test_data/proto/test_main/expected/concrete_class_with_descendants/meta_model.py +30 -0
- dev/test_data/proto/test_main/expected/concrete_class_with_enum/meta_model.py +21 -0
- dev/test_data/proto/test_main/expected/concrete_class_with_list_of_instances/meta_model.py +21 -0
- dev/test_data/proto/test_main/expected/concrete_class_with_primitive_attributes/meta_model.py +41 -0
- dev/test_data/python_protobuf/test_main/abstract_and_concrete_classes/expected_output/pbization.py +532 -0
- dev/test_data/python_protobuf/test_main/abstract_and_concrete_classes/meta_model.py +37 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_descendant/expected_output/pbization.py +527 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_descendant/meta_model.py +27 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_enum/expected_output/pbization.py +290 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_enum/meta_model.py +21 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_list_of_instances/expected_output/pbization.py +328 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_list_of_instances/meta_model.py +23 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_primitive_attributes/expected_output/pbization.py +274 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_primitive_attributes/meta_model.py +41 -0
- dev/test_data/rdf_shacl/test_main/expected/regression_when_lang_string_class_is_missing/meta_model.py +29 -0
- dev/test_data/rdf_shacl/test_main/expected/regression_when_len_constraints_on_inherited_property/meta_model.py +27 -0
- dev/test_data/rdf_shacl/test_main/unexpected/regression_len_constraint_on_class_property/meta_model.py +61 -0
- dev/test_data/real_meta_models/aas_core_meta.v3.py +5721 -0
- dev/test_data/smoke/test_main/unexpected/infer_for_schema_error/meta_model.py +12 -0
- dev/test_data/smoke/test_main/unexpected/intermediate_error/meta_model.py +18 -0
- dev/test_data/smoke/test_main/unexpected/parse_error/meta_model.py +5 -0
- dev/test_data/smoke/test_main/unexpected/pattern_verification_unparsable_regex/direct_match/meta_model.py +8 -0
- dev/test_data/smoke/test_main/unexpected/type_error/meta_model.py +18 -0
- dev/tests/__init__.py +1 -0
- dev/tests/common.py +197 -0
- dev/tests/cpp/__init__.py +0 -0
- dev/tests/cpp/test_common.py +32 -0
- dev/tests/cpp/test_main.py +144 -0
- dev/tests/cpp/test_pattern.py +188 -0
- dev/tests/cpp/test_verification.py +189 -0
- dev/tests/cpp/test_yielding.py +225 -0
- dev/tests/csharp/__init__.py +0 -0
- dev/tests/csharp/live_test_main.py +109 -0
- dev/tests/csharp/test_common.py +28 -0
- dev/tests/csharp/test_description.py +684 -0
- dev/tests/csharp/test_main.py +129 -0
- dev/tests/csharp/test_structure.py +93 -0
- dev/tests/csharp/test_verification.py +82 -0
- dev/tests/description.py +29 -0
- dev/tests/golang/__init__.py +0 -0
- dev/tests/golang/test_common.py +78 -0
- dev/tests/golang/test_main.py +128 -0
- dev/tests/infer_for_schema/__init__.py +0 -0
- dev/tests/infer_for_schema/common.py +47 -0
- dev/tests/infer_for_schema/test_len_on_properties.py +955 -0
- dev/tests/infer_for_schema/test_len_on_self.py +580 -0
- dev/tests/infer_for_schema/test_patterns_on_properties.py +686 -0
- dev/tests/infer_for_schema/test_patterns_on_self.py +258 -0
- dev/tests/infer_for_schema/test_property_in_set_of_enumeration_literals.py +600 -0
- dev/tests/infer_for_schema/test_property_in_set_of_primitives.py +549 -0
- dev/tests/intermediate/__init__.py +0 -0
- dev/tests/intermediate/test_constructor.py +719 -0
- dev/tests/intermediate/test_hierarchy.py +221 -0
- dev/tests/intermediate/test_revm.py +134 -0
- dev/tests/intermediate/test_translate.py +337 -0
- dev/tests/intermediate/test_type_inference.py +333 -0
- dev/tests/intermediate/test_types.py +169 -0
- dev/tests/java/__init__.py +0 -0
- dev/tests/java/test_common.py +20 -0
- dev/tests/java/test_description.py +128 -0
- dev/tests/java/test_main.py +234 -0
- dev/tests/jsonld_context/test_main.py +79 -0
- dev/tests/opcua/__init__.py +3 -0
- dev/tests/opcua/test_main.py +110 -0
- dev/tests/our_jsonschema/__init__.py +3 -0
- dev/tests/our_jsonschema/test_main.py +232 -0
- dev/tests/parse/__init__.py +0 -0
- dev/tests/parse/test_parse.py +503 -0
- dev/tests/parse/test_retree.py +272 -0
- dev/tests/proto/__init__.py +0 -0
- dev/tests/proto/test_main.py +112 -0
- dev/tests/python/__init__.py +0 -0
- dev/tests/python/test_common.py +124 -0
- dev/tests/python/test_main.py +126 -0
- dev/tests/python/test_xml_playground.py +254 -0
- dev/tests/python_protobuf/__init__.py +0 -0
- dev/tests/python_protobuf/test_main.py +111 -0
- dev/tests/rdf_shacl/__init__.py +0 -0
- dev/tests/rdf_shacl/test_common.py +32 -0
- dev/tests/rdf_shacl/test_description.py +223 -0
- dev/tests/rdf_shacl/test_main.py +194 -0
- dev/tests/smoke/__init__.py +0 -0
- dev/tests/smoke/test_main.py +83 -0
- dev/tests/test_common.py +94 -0
- dev/tests/typescript/__init__.py +0 -0
- dev/tests/typescript/test_common.py +108 -0
- dev/tests/typescript/test_main.py +125 -0
- dev/tests/xsd/__init__.py +0 -0
- dev/tests/xsd/test_main.py +227 -0
- dev/tests/yielding/__init__.py +0 -0
- dev/tests/yielding/test_linear.py +558 -0
|
@@ -0,0 +1,973 @@
|
|
|
1
|
+
"""Provide the types into which we parse the original meta-model."""
|
|
2
|
+
import abc
|
|
3
|
+
import ast
|
|
4
|
+
import os
|
|
5
|
+
import pathlib
|
|
6
|
+
from typing import Sequence, Optional, Union, Final, Mapping, cast
|
|
7
|
+
|
|
8
|
+
import docutils.nodes
|
|
9
|
+
from icontract import require, DBC, ensure, invariant
|
|
10
|
+
|
|
11
|
+
from aas_core_codegen.common import (
|
|
12
|
+
Identifier,
|
|
13
|
+
assert_union_of_descendants_exhaustive,
|
|
14
|
+
Stripped,
|
|
15
|
+
)
|
|
16
|
+
from aas_core_codegen.parse import tree
|
|
17
|
+
|
|
18
|
+
_MODULE_NAME = pathlib.Path(os.path.realpath(__file__)).parent.name
|
|
19
|
+
|
|
20
|
+
#: Built-in primitive types
|
|
21
|
+
PRIMITIVE_TYPES = {"bool", "int", "float", "str", "bytearray"}
|
|
22
|
+
|
|
23
|
+
#: Built-in generic types
|
|
24
|
+
GENERIC_TYPES = {Identifier("List"), Identifier("Optional")}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class AtomicTypeAnnotation:
|
|
28
|
+
"""
|
|
29
|
+
Represent an atomic type annotation, such as ``Asset`` or ``int``.
|
|
30
|
+
|
|
31
|
+
Atomic, in this context, means a non-generic type such as ``List``.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
def __init__(self, identifier: Identifier, node: ast.AST) -> None:
|
|
35
|
+
"""Initialize with the given values."""
|
|
36
|
+
self.identifier = identifier
|
|
37
|
+
self.node = node
|
|
38
|
+
|
|
39
|
+
def __repr__(self) -> str:
|
|
40
|
+
"""Represent the instance as a string for debugging."""
|
|
41
|
+
return (
|
|
42
|
+
f"<{_MODULE_NAME}.{self.__class__.__name__} "
|
|
43
|
+
f"{self.identifier} at 0x{id(self):x}>"
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
def __str__(self) -> str:
|
|
47
|
+
return self.identifier
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class SelfTypeAnnotation:
|
|
51
|
+
"""Provide a placeholder for the special argument ``self`` in a method"""
|
|
52
|
+
|
|
53
|
+
def __str__(self) -> str:
|
|
54
|
+
return "SELF"
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class SubscriptedTypeAnnotation:
|
|
58
|
+
"""Represent a subscripted type annotation such as ``Optional[...]``."""
|
|
59
|
+
|
|
60
|
+
def __init__(
|
|
61
|
+
self,
|
|
62
|
+
identifier: Identifier,
|
|
63
|
+
subscripts: Sequence["TypeAnnotation"],
|
|
64
|
+
node: ast.AST,
|
|
65
|
+
) -> None:
|
|
66
|
+
"""Initialize with the given values."""
|
|
67
|
+
self.identifier = identifier
|
|
68
|
+
self.subscripts = subscripts
|
|
69
|
+
self.node = node
|
|
70
|
+
|
|
71
|
+
def __repr__(self) -> str:
|
|
72
|
+
"""Represent the instance as a string for debugging."""
|
|
73
|
+
subscripts_str = ", ".join(repr(subscript) for subscript in self.subscripts)
|
|
74
|
+
return (
|
|
75
|
+
f"<{_MODULE_NAME}.{self.__class__.__name__} "
|
|
76
|
+
f"{self.identifier} at 0x{id(self):x} "
|
|
77
|
+
f"subscripts={subscripts_str}>"
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
def __str__(self) -> str:
|
|
81
|
+
"""Represent by reconstructing the type annotation heuristically."""
|
|
82
|
+
return "".join(
|
|
83
|
+
[self.identifier, "["]
|
|
84
|
+
+ [", ".join([str(subscript) for subscript in self.subscripts])]
|
|
85
|
+
+ ["]"]
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
TypeAnnotation = Union[
|
|
90
|
+
AtomicTypeAnnotation, SubscriptedTypeAnnotation, SelfTypeAnnotation
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class Description:
|
|
95
|
+
"""Represent a docstring describing something in the meta-model."""
|
|
96
|
+
|
|
97
|
+
@require(lambda node: isinstance(node.value, str))
|
|
98
|
+
def __init__(self, document: docutils.nodes.document, node: ast.Constant) -> None:
|
|
99
|
+
"""Initialize with the given values."""
|
|
100
|
+
self.document = document
|
|
101
|
+
self.node = node
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
# region Constants
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class SetLiteral:
|
|
108
|
+
"""Represent a literal as an item of a constant set."""
|
|
109
|
+
|
|
110
|
+
#: Original node of the meta-model's Python AST
|
|
111
|
+
node: Final[Union[ast.Attribute, ast.Constant]]
|
|
112
|
+
|
|
113
|
+
def __init__(self, node: Union[ast.Attribute, ast.Constant]) -> None:
|
|
114
|
+
"""Initialize with the given values."""
|
|
115
|
+
self.node = node
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class Constant(DBC):
|
|
119
|
+
"""Represent a constant in the meta-model."""
|
|
120
|
+
|
|
121
|
+
#: Name of the constant
|
|
122
|
+
name: Final[Identifier]
|
|
123
|
+
|
|
124
|
+
#: Description of the constant, if any given in the meta-model
|
|
125
|
+
description: Final[Optional[Description]]
|
|
126
|
+
|
|
127
|
+
#: Original node of the meta-model's Python AST
|
|
128
|
+
node: Final[ast.AnnAssign]
|
|
129
|
+
|
|
130
|
+
def __init__(
|
|
131
|
+
self,
|
|
132
|
+
name: Identifier,
|
|
133
|
+
description: Optional[Description],
|
|
134
|
+
node: ast.AnnAssign,
|
|
135
|
+
) -> None:
|
|
136
|
+
"""Initialize with the given values."""
|
|
137
|
+
self.name = name
|
|
138
|
+
self.description = description
|
|
139
|
+
self.node = node
|
|
140
|
+
|
|
141
|
+
@abc.abstractmethod
|
|
142
|
+
def __repr__(self) -> str:
|
|
143
|
+
"""Represent the instance as a string for easier debugging."""
|
|
144
|
+
raise NotImplementedError()
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
class ConstantPrimitive(Constant):
|
|
148
|
+
"""Represent a constant value in the meta-model of primitive type."""
|
|
149
|
+
|
|
150
|
+
value: Final[Union[bool, int, float, str, bytearray]]
|
|
151
|
+
|
|
152
|
+
def __init__(
|
|
153
|
+
self,
|
|
154
|
+
name: Identifier,
|
|
155
|
+
value: Union[bool, int, float, str, bytearray],
|
|
156
|
+
description: Optional[Description],
|
|
157
|
+
node: ast.AnnAssign,
|
|
158
|
+
) -> None:
|
|
159
|
+
"""Initialize with the given values."""
|
|
160
|
+
Constant.__init__(
|
|
161
|
+
self,
|
|
162
|
+
name=name,
|
|
163
|
+
description=description,
|
|
164
|
+
node=node,
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
self.value = value
|
|
168
|
+
|
|
169
|
+
def __repr__(self) -> str:
|
|
170
|
+
"""Represent the instance as a string for easier debugging."""
|
|
171
|
+
return (
|
|
172
|
+
f"<{_MODULE_NAME}.{self.__class__.__name__} {self.name} at 0x{id(self):x}>"
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
class ConstantSet(Constant):
|
|
177
|
+
"""Represent a constant set in the meta-model."""
|
|
178
|
+
|
|
179
|
+
# NOTE (mristin, 2022-07-01):
|
|
180
|
+
# At this moment, we only support enumeration subsets and sets of strings. That is
|
|
181
|
+
# why we enforce only the atomic type annotations for the
|
|
182
|
+
# :attr:`~items_type_annotation`. Subscripted type annotations are also possible,
|
|
183
|
+
# but would involve more implementation effort.
|
|
184
|
+
|
|
185
|
+
#: Type annotation corresponding to the set items
|
|
186
|
+
items_type_annotation: Final[AtomicTypeAnnotation]
|
|
187
|
+
|
|
188
|
+
#: Literals contained in the set
|
|
189
|
+
set_literals: Final[Sequence[SetLiteral]]
|
|
190
|
+
|
|
191
|
+
#: All the constant subsets of this set
|
|
192
|
+
subsets: Final[Sequence[Identifier]]
|
|
193
|
+
|
|
194
|
+
def __init__(
|
|
195
|
+
self,
|
|
196
|
+
name: Identifier,
|
|
197
|
+
items_type_annotation: AtomicTypeAnnotation,
|
|
198
|
+
set_literals: Sequence[SetLiteral],
|
|
199
|
+
subsets: Sequence[Identifier],
|
|
200
|
+
description: Optional[Description],
|
|
201
|
+
node: ast.AnnAssign,
|
|
202
|
+
) -> None:
|
|
203
|
+
"""Initialize with the given values."""
|
|
204
|
+
Constant.__init__(
|
|
205
|
+
self,
|
|
206
|
+
name=name,
|
|
207
|
+
description=description,
|
|
208
|
+
node=node,
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
self.items_type_annotation = items_type_annotation
|
|
212
|
+
self.set_literals = set_literals
|
|
213
|
+
self.subsets = subsets
|
|
214
|
+
|
|
215
|
+
def __repr__(self) -> str:
|
|
216
|
+
"""Represent the instance as a string for easier debugging."""
|
|
217
|
+
return (
|
|
218
|
+
f"<{_MODULE_NAME}.{self.__class__.__name__} {self.name} at 0x{id(self):x}>"
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
# endregion
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
class Property:
|
|
226
|
+
"""
|
|
227
|
+
Represent a property of a class.
|
|
228
|
+
|
|
229
|
+
If a property is optional (non-required), the :py:attr:`type_annotation` needs to
|
|
230
|
+
be set with the appropriate ``Optional`` type.
|
|
231
|
+
"""
|
|
232
|
+
|
|
233
|
+
def __init__(
|
|
234
|
+
self,
|
|
235
|
+
name: Identifier,
|
|
236
|
+
type_annotation: TypeAnnotation,
|
|
237
|
+
description: Optional[Description],
|
|
238
|
+
node: ast.AnnAssign,
|
|
239
|
+
) -> None:
|
|
240
|
+
"""Initialize with the given values."""
|
|
241
|
+
self.name = name
|
|
242
|
+
self.type_annotation = type_annotation
|
|
243
|
+
self.description = description
|
|
244
|
+
self.node = node
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
class Default:
|
|
248
|
+
"""Represent a default value for an argument."""
|
|
249
|
+
|
|
250
|
+
def __init__(self, node: ast.AST) -> None:
|
|
251
|
+
"""Initialize with the given values."""
|
|
252
|
+
self.node = node
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
class Argument:
|
|
256
|
+
"""Represent an argument of a method."""
|
|
257
|
+
|
|
258
|
+
def __init__(
|
|
259
|
+
self,
|
|
260
|
+
name: Identifier,
|
|
261
|
+
type_annotation: TypeAnnotation,
|
|
262
|
+
default: Optional[Default],
|
|
263
|
+
node: ast.arg,
|
|
264
|
+
) -> None:
|
|
265
|
+
"""Initialize with the given values."""
|
|
266
|
+
self.name = name
|
|
267
|
+
self.type_annotation = type_annotation
|
|
268
|
+
self.default = default
|
|
269
|
+
self.node = node
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
class Invariant:
|
|
273
|
+
"""Represent an invariant of a class."""
|
|
274
|
+
|
|
275
|
+
def __init__(self, description: str, body: tree.Expression, node: ast.AST) -> None:
|
|
276
|
+
self.description = description
|
|
277
|
+
self.body = body
|
|
278
|
+
self.node = node
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
class Contract:
|
|
282
|
+
"""Represent a contract of a method."""
|
|
283
|
+
|
|
284
|
+
def __init__(
|
|
285
|
+
self,
|
|
286
|
+
args: Sequence[Identifier],
|
|
287
|
+
description: Optional[str],
|
|
288
|
+
body: tree.Expression,
|
|
289
|
+
node: ast.AST,
|
|
290
|
+
) -> None:
|
|
291
|
+
self.args = args
|
|
292
|
+
self.description = description
|
|
293
|
+
self.body = body
|
|
294
|
+
self.node = node
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
class Snapshot:
|
|
298
|
+
"""Represent a snapshot of an OLD value capture before the method execution."""
|
|
299
|
+
|
|
300
|
+
def __init__(
|
|
301
|
+
self,
|
|
302
|
+
args: Sequence[Identifier],
|
|
303
|
+
name: Identifier,
|
|
304
|
+
body: tree.Expression,
|
|
305
|
+
node: ast.AST,
|
|
306
|
+
) -> None:
|
|
307
|
+
"""Initialize with the given values."""
|
|
308
|
+
self.args = args
|
|
309
|
+
self.name = name
|
|
310
|
+
self.body = body
|
|
311
|
+
self.node = node
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
class Contracts:
|
|
315
|
+
"""Represent the set of contracts for a method."""
|
|
316
|
+
|
|
317
|
+
def __init__(
|
|
318
|
+
self,
|
|
319
|
+
preconditions: Sequence[Contract],
|
|
320
|
+
snapshots: Sequence[Snapshot],
|
|
321
|
+
postconditions: Sequence[Contract],
|
|
322
|
+
) -> None:
|
|
323
|
+
"""Initialize with the given values."""
|
|
324
|
+
self.preconditions = preconditions
|
|
325
|
+
self.snapshots = snapshots
|
|
326
|
+
self.postconditions = postconditions
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
# fmt: off
|
|
330
|
+
@ensure(
|
|
331
|
+
lambda expr, result:
|
|
332
|
+
not result
|
|
333
|
+
or (
|
|
334
|
+
isinstance(expr, ast.Expr)
|
|
335
|
+
and isinstance(expr.value, ast.Constant)
|
|
336
|
+
and isinstance(expr.value.value, str)
|
|
337
|
+
)
|
|
338
|
+
)
|
|
339
|
+
# fmt: on
|
|
340
|
+
def is_string_expr(expr: ast.AST) -> bool:
|
|
341
|
+
"""Check that the expression is a string literal."""
|
|
342
|
+
return (
|
|
343
|
+
isinstance(expr, ast.Expr)
|
|
344
|
+
and isinstance(expr.value, ast.Constant)
|
|
345
|
+
and isinstance(expr.value.value, str)
|
|
346
|
+
)
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
class Method(DBC):
|
|
350
|
+
"""
|
|
351
|
+
Represent a function or a class method.
|
|
352
|
+
|
|
353
|
+
Though we have to distinguish in Python between a function and a method, we term
|
|
354
|
+
both of them "methods" in our model.
|
|
355
|
+
"""
|
|
356
|
+
|
|
357
|
+
#: Name of the method
|
|
358
|
+
name: Final[Identifier]
|
|
359
|
+
|
|
360
|
+
#: Set if the method is marked to be used for verification
|
|
361
|
+
verification: Final[bool]
|
|
362
|
+
|
|
363
|
+
#: Specification of method's arguments
|
|
364
|
+
arguments: Final[Sequence[Argument]]
|
|
365
|
+
|
|
366
|
+
#: Specification of the method's return value, or None if it is a procedure
|
|
367
|
+
returns: Final[Optional[TypeAnnotation]]
|
|
368
|
+
|
|
369
|
+
#: Parsed docstring of the method, if any
|
|
370
|
+
description: Final[Optional[Description]]
|
|
371
|
+
|
|
372
|
+
#: Parsed contracts of the method
|
|
373
|
+
contracts: Final[Contracts]
|
|
374
|
+
|
|
375
|
+
#: If set, the method is expected to be an instance method which does not
|
|
376
|
+
#: mutate the instance data.
|
|
377
|
+
non_mutating: Final[bool]
|
|
378
|
+
|
|
379
|
+
#: Node representing the method in the meta-model's Python AST
|
|
380
|
+
node: Final[ast.AST]
|
|
381
|
+
|
|
382
|
+
#: Map arguments by their names
|
|
383
|
+
arguments_by_name: Final[Mapping[str, Argument]]
|
|
384
|
+
|
|
385
|
+
# fmt: off
|
|
386
|
+
@require(
|
|
387
|
+
lambda arguments, contracts:
|
|
388
|
+
(
|
|
389
|
+
arg_set := {arg.name for arg in arguments},
|
|
390
|
+
all(
|
|
391
|
+
arg in arg_set # pylint: disable=used-before-assignment
|
|
392
|
+
for precondition in contracts.preconditions
|
|
393
|
+
for arg in precondition.args
|
|
394
|
+
)
|
|
395
|
+
and all(
|
|
396
|
+
arg in arg_set
|
|
397
|
+
for postcondition in contracts.postconditions
|
|
398
|
+
for arg in postcondition.args if arg not in ('OLD', 'result')
|
|
399
|
+
)
|
|
400
|
+
and all(
|
|
401
|
+
arg in arg_set
|
|
402
|
+
for snapshot in contracts.snapshots
|
|
403
|
+
for arg in snapshot.args
|
|
404
|
+
)
|
|
405
|
+
)[1],
|
|
406
|
+
"All arguments of contracts defined in method arguments"
|
|
407
|
+
)
|
|
408
|
+
@require(
|
|
409
|
+
lambda arguments: (
|
|
410
|
+
arg_names := [arg.name for arg in arguments],
|
|
411
|
+
len(arg_names) == len(set(arg_names))
|
|
412
|
+
)[1],
|
|
413
|
+
"Unique arguments"
|
|
414
|
+
)
|
|
415
|
+
@ensure(
|
|
416
|
+
lambda self:
|
|
417
|
+
len(self.arguments_by_name) == len(self.arguments)
|
|
418
|
+
and all(
|
|
419
|
+
self.arguments_by_name[argument.name] is argument
|
|
420
|
+
for argument in self.arguments
|
|
421
|
+
),
|
|
422
|
+
"Arguments and arguments by name are consistent"
|
|
423
|
+
)
|
|
424
|
+
# fmt: on
|
|
425
|
+
def __init__(
|
|
426
|
+
self,
|
|
427
|
+
name: Identifier,
|
|
428
|
+
verification: bool,
|
|
429
|
+
arguments: Sequence[Argument],
|
|
430
|
+
returns: Optional[TypeAnnotation],
|
|
431
|
+
description: Optional[Description],
|
|
432
|
+
contracts: Contracts,
|
|
433
|
+
non_mutating: bool,
|
|
434
|
+
node: ast.AST,
|
|
435
|
+
) -> None:
|
|
436
|
+
"""Initialize with the given values."""
|
|
437
|
+
self.name = name
|
|
438
|
+
self.verification = verification
|
|
439
|
+
self.arguments = arguments
|
|
440
|
+
self.returns = returns
|
|
441
|
+
self.description = description
|
|
442
|
+
self.contracts = contracts
|
|
443
|
+
self.non_mutating = non_mutating
|
|
444
|
+
self.node = node
|
|
445
|
+
|
|
446
|
+
self.arguments_by_name = {
|
|
447
|
+
argument.name: argument for argument in self.arguments
|
|
448
|
+
} # type: Mapping[Identifier, Argument]
|
|
449
|
+
|
|
450
|
+
@abc.abstractmethod
|
|
451
|
+
def __repr__(self) -> str:
|
|
452
|
+
# Make abstract to signal that this is a pure abstract class
|
|
453
|
+
raise NotImplementedError()
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
class ImplementationSpecificMethod(Method):
|
|
457
|
+
"""
|
|
458
|
+
Represent an implementation-specific function or a class method.
|
|
459
|
+
|
|
460
|
+
Implementation-specific means that we have to provide a snippet for each
|
|
461
|
+
target implementation.
|
|
462
|
+
"""
|
|
463
|
+
|
|
464
|
+
def __repr__(self) -> str:
|
|
465
|
+
"""Represent the instance as a string for easier debugging."""
|
|
466
|
+
return (
|
|
467
|
+
f"<{_MODULE_NAME}.{self.__class__.__name__} {self.name} at 0x{id(self):x}>"
|
|
468
|
+
)
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
class UnderstoodMethod(Method):
|
|
472
|
+
"""
|
|
473
|
+
Represent a function or a class method that we could understand.
|
|
474
|
+
|
|
475
|
+
We use :py:mod:`aas_core_codegen.parse._rules` to understand it.
|
|
476
|
+
"""
|
|
477
|
+
|
|
478
|
+
#: Body as an AST that we could understand with
|
|
479
|
+
#: :py:mod:`aas_core_codegen.parse._rules`
|
|
480
|
+
body: Final[Sequence[tree.Node]]
|
|
481
|
+
|
|
482
|
+
def __init__(
|
|
483
|
+
self,
|
|
484
|
+
name: Identifier,
|
|
485
|
+
verification: bool,
|
|
486
|
+
arguments: Sequence[Argument],
|
|
487
|
+
returns: Optional[TypeAnnotation],
|
|
488
|
+
description: Optional[Description],
|
|
489
|
+
contracts: Contracts,
|
|
490
|
+
non_mutating: bool,
|
|
491
|
+
body: Sequence[tree.Node],
|
|
492
|
+
node: ast.AST,
|
|
493
|
+
) -> None:
|
|
494
|
+
"""Initialize with the given values."""
|
|
495
|
+
Method.__init__(
|
|
496
|
+
self,
|
|
497
|
+
name=name,
|
|
498
|
+
verification=verification,
|
|
499
|
+
arguments=arguments,
|
|
500
|
+
returns=returns,
|
|
501
|
+
description=description,
|
|
502
|
+
contracts=contracts,
|
|
503
|
+
non_mutating=non_mutating,
|
|
504
|
+
node=node,
|
|
505
|
+
)
|
|
506
|
+
|
|
507
|
+
self.body = body
|
|
508
|
+
|
|
509
|
+
def __repr__(self) -> str:
|
|
510
|
+
"""Represent the instance as a string for easier debugging."""
|
|
511
|
+
return (
|
|
512
|
+
f"<{_MODULE_NAME}.{self.__class__.__name__} {self.name} at 0x{id(self):x}>"
|
|
513
|
+
)
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
class ConstructorToBeUnderstood(Method):
|
|
517
|
+
"""
|
|
518
|
+
Represent a constructor of a class.
|
|
519
|
+
|
|
520
|
+
We will use :py:mod:`aas_core_codegen.intermediate.construction` to later
|
|
521
|
+
understand it.
|
|
522
|
+
"""
|
|
523
|
+
|
|
524
|
+
#: Body of the constructor as Python AST. We will understand it in the intermediate
|
|
525
|
+
#: phase using :py:mod:`aas_core_codegen.intermediate.construction`.
|
|
526
|
+
body: Final[Sequence[ast.AST]]
|
|
527
|
+
|
|
528
|
+
# fmt: off
|
|
529
|
+
@require(
|
|
530
|
+
lambda body:
|
|
531
|
+
not (len(body) > 0)
|
|
532
|
+
or not is_string_expr(expr=body[0]),
|
|
533
|
+
"Docstring is excluded from the body"
|
|
534
|
+
)
|
|
535
|
+
# fmt: on
|
|
536
|
+
def __init__(
|
|
537
|
+
self,
|
|
538
|
+
arguments: Sequence[Argument],
|
|
539
|
+
description: Optional[Description],
|
|
540
|
+
contracts: Contracts,
|
|
541
|
+
body: Sequence[ast.AST],
|
|
542
|
+
node: ast.AST,
|
|
543
|
+
) -> None:
|
|
544
|
+
"""Initialize with the given values."""
|
|
545
|
+
Method.__init__(
|
|
546
|
+
self,
|
|
547
|
+
name=Identifier("__init__"),
|
|
548
|
+
verification=False,
|
|
549
|
+
arguments=arguments,
|
|
550
|
+
returns=None,
|
|
551
|
+
description=description,
|
|
552
|
+
contracts=contracts,
|
|
553
|
+
non_mutating=False,
|
|
554
|
+
node=node,
|
|
555
|
+
)
|
|
556
|
+
|
|
557
|
+
self.body = body
|
|
558
|
+
|
|
559
|
+
def __repr__(self) -> str:
|
|
560
|
+
"""Represent the instance as a string for easier debugging."""
|
|
561
|
+
return (
|
|
562
|
+
f"<{_MODULE_NAME}.{self.__class__.__name__} {self.name} at 0x{id(self):x}>"
|
|
563
|
+
)
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
class Serialization:
|
|
567
|
+
"""Define general settings for the de/serialization of a specific class."""
|
|
568
|
+
|
|
569
|
+
def __init__(self, with_model_type: Optional[bool]) -> None:
|
|
570
|
+
"""
|
|
571
|
+
Initialize with the given values.
|
|
572
|
+
|
|
573
|
+
:param with_model_type: The parsed ``with_model_type`` argument
|
|
574
|
+
"""
|
|
575
|
+
self.with_model_type = with_model_type
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
class Class(DBC):
|
|
579
|
+
"""Represent a class of the meta-model."""
|
|
580
|
+
|
|
581
|
+
#: Name of the class
|
|
582
|
+
name: Final[Identifier]
|
|
583
|
+
|
|
584
|
+
#: If set, the class is implementation-specific, and we need to provide a snippet
|
|
585
|
+
#: for it
|
|
586
|
+
is_implementation_specific: Final[bool]
|
|
587
|
+
|
|
588
|
+
#: List of all the ancestor classes
|
|
589
|
+
inheritances: Final[Sequence[Identifier]]
|
|
590
|
+
|
|
591
|
+
#: Properties of the class
|
|
592
|
+
properties: Final[Sequence[Property]]
|
|
593
|
+
|
|
594
|
+
#: Methods of the class
|
|
595
|
+
methods: Final[Sequence["MethodUnion"]]
|
|
596
|
+
|
|
597
|
+
#: Invariants of the class
|
|
598
|
+
invariants: Final[Sequence[Invariant]]
|
|
599
|
+
|
|
600
|
+
#: Serialization settings of the class
|
|
601
|
+
serialization: Final[Optional[Serialization]]
|
|
602
|
+
|
|
603
|
+
#: Description of the class, if any given in the meta-model
|
|
604
|
+
description: Final[Optional[Description]]
|
|
605
|
+
|
|
606
|
+
#: Original node of the meta-model's Python AST
|
|
607
|
+
node: Final[ast.ClassDef]
|
|
608
|
+
|
|
609
|
+
#: Map each property by its name
|
|
610
|
+
properties_by_name: Final[Mapping[Identifier, Property]]
|
|
611
|
+
|
|
612
|
+
#: Map each method by its name
|
|
613
|
+
methods_by_name: Final[Mapping[Identifier, Method]]
|
|
614
|
+
|
|
615
|
+
# fmt: off
|
|
616
|
+
@require(
|
|
617
|
+
lambda properties:
|
|
618
|
+
(
|
|
619
|
+
prop_names := [prop.name for prop in properties],
|
|
620
|
+
len(prop_names) == len(set(prop_names))
|
|
621
|
+
)[1],
|
|
622
|
+
"Unique property names"
|
|
623
|
+
)
|
|
624
|
+
@require(
|
|
625
|
+
lambda methods:
|
|
626
|
+
(
|
|
627
|
+
method_names := [method.name for method in methods],
|
|
628
|
+
len(method_names) == len(set(method_names))
|
|
629
|
+
)[1],
|
|
630
|
+
"Unique methods names"
|
|
631
|
+
)
|
|
632
|
+
@require(
|
|
633
|
+
lambda methods:
|
|
634
|
+
all(
|
|
635
|
+
len(method.arguments) >= 1
|
|
636
|
+
and method.arguments[0].name == 'self'
|
|
637
|
+
and isinstance(method.arguments[0].type_annotation, SelfTypeAnnotation)
|
|
638
|
+
for method in methods
|
|
639
|
+
),
|
|
640
|
+
"``self`` specified in all methods"
|
|
641
|
+
)
|
|
642
|
+
# fmt: on
|
|
643
|
+
def __init__(
|
|
644
|
+
self,
|
|
645
|
+
name: Identifier,
|
|
646
|
+
is_implementation_specific: bool,
|
|
647
|
+
inheritances: Sequence[Identifier],
|
|
648
|
+
properties: Sequence[Property],
|
|
649
|
+
methods: Sequence["MethodUnion"],
|
|
650
|
+
invariants: Sequence[Invariant],
|
|
651
|
+
serialization: Optional[Serialization],
|
|
652
|
+
description: Optional[Description],
|
|
653
|
+
node: ast.ClassDef,
|
|
654
|
+
) -> None:
|
|
655
|
+
self.name = name
|
|
656
|
+
self.is_implementation_specific = is_implementation_specific
|
|
657
|
+
self.inheritances = inheritances
|
|
658
|
+
self.properties = properties
|
|
659
|
+
self.methods = methods
|
|
660
|
+
self.invariants = invariants
|
|
661
|
+
self.serialization = serialization
|
|
662
|
+
self.description = description
|
|
663
|
+
self.node = node
|
|
664
|
+
|
|
665
|
+
self.properties_by_name = {
|
|
666
|
+
prop.name: prop for prop in properties
|
|
667
|
+
} # type: Mapping[Identifier, Property]
|
|
668
|
+
|
|
669
|
+
self.methods_by_name = {
|
|
670
|
+
method.name: method for method in methods
|
|
671
|
+
} # type: Mapping[Identifier, Method]
|
|
672
|
+
|
|
673
|
+
@abc.abstractmethod
|
|
674
|
+
def __repr__(self) -> str:
|
|
675
|
+
raise NotImplementedError()
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
class AbstractClass(Class):
|
|
679
|
+
"""
|
|
680
|
+
Represent an abstract class of the meta-model.
|
|
681
|
+
|
|
682
|
+
For example, ``Referable``.
|
|
683
|
+
"""
|
|
684
|
+
|
|
685
|
+
def __repr__(self) -> str:
|
|
686
|
+
"""Represent the class with a name for easier debugging."""
|
|
687
|
+
return (
|
|
688
|
+
f"<{_MODULE_NAME}.{self.__class__.__name__} "
|
|
689
|
+
f"{self.name} at 0x{id(self):x}>"
|
|
690
|
+
)
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
class ConcreteClass(Class):
|
|
694
|
+
"""
|
|
695
|
+
Represent a concrete class of the meta-model.
|
|
696
|
+
|
|
697
|
+
For example, ``Asset``.
|
|
698
|
+
"""
|
|
699
|
+
|
|
700
|
+
def __repr__(self) -> str:
|
|
701
|
+
"""Represent the class with a name for easier debugging."""
|
|
702
|
+
return (
|
|
703
|
+
f"<{_MODULE_NAME}.{self.__class__.__name__} {self.name} at 0x{id(self):x}>"
|
|
704
|
+
)
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
class EnumerationLiteral:
|
|
708
|
+
"""Represent a single enumeration literal."""
|
|
709
|
+
|
|
710
|
+
def __init__(
|
|
711
|
+
self,
|
|
712
|
+
name: Identifier,
|
|
713
|
+
value: str,
|
|
714
|
+
description: Optional[Description],
|
|
715
|
+
node: ast.Assign,
|
|
716
|
+
) -> None:
|
|
717
|
+
self.name = name
|
|
718
|
+
self.value = value
|
|
719
|
+
self.description = description
|
|
720
|
+
self.node = node
|
|
721
|
+
|
|
722
|
+
|
|
723
|
+
# fmt: off
|
|
724
|
+
@invariant(
|
|
725
|
+
lambda self:
|
|
726
|
+
all(
|
|
727
|
+
literal == self.literals_by_name[literal.name]
|
|
728
|
+
for literal in self.literals
|
|
729
|
+
) and len(self.literals) == len(self.literals_by_name),
|
|
730
|
+
"Literal map consistent on name"
|
|
731
|
+
)
|
|
732
|
+
# fmt: on
|
|
733
|
+
class Enumeration:
|
|
734
|
+
"""Represent an enumeration."""
|
|
735
|
+
|
|
736
|
+
#: Name of the enumeration
|
|
737
|
+
name: Final[Identifier]
|
|
738
|
+
|
|
739
|
+
#: List of the enumeration literals
|
|
740
|
+
literals: Final[Sequence[EnumerationLiteral]]
|
|
741
|
+
|
|
742
|
+
#: Description of the enumeration, if any
|
|
743
|
+
description: Final[Optional[Description]]
|
|
744
|
+
|
|
745
|
+
#: Node of the enumeration in the meta-model's Python AST
|
|
746
|
+
node: Final[ast.ClassDef]
|
|
747
|
+
|
|
748
|
+
#: Map literals by their names
|
|
749
|
+
literals_by_name: Final[Mapping[Identifier, EnumerationLiteral]]
|
|
750
|
+
|
|
751
|
+
def __init__(
|
|
752
|
+
self,
|
|
753
|
+
name: Identifier,
|
|
754
|
+
literals: Sequence[EnumerationLiteral],
|
|
755
|
+
description: Optional[Description],
|
|
756
|
+
node: ast.ClassDef,
|
|
757
|
+
) -> None:
|
|
758
|
+
self.name = name
|
|
759
|
+
self.literals = literals
|
|
760
|
+
self.description = description
|
|
761
|
+
self.node = node
|
|
762
|
+
|
|
763
|
+
self.literals_by_name = {
|
|
764
|
+
literal.name: literal for literal in self.literals
|
|
765
|
+
} # type: Mapping[Identifier, EnumerationLiteral]
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
OurType = Union[AbstractClass, ConcreteClass, Enumeration]
|
|
769
|
+
|
|
770
|
+
|
|
771
|
+
class MetaModel:
|
|
772
|
+
"""Collect information about the underlying meta-model."""
|
|
773
|
+
|
|
774
|
+
#: Description of the meta-model extracted from the docstring
|
|
775
|
+
description: Final[Optional[Description]]
|
|
776
|
+
|
|
777
|
+
#: Specify the version of the meta-model
|
|
778
|
+
version: Final[str]
|
|
779
|
+
|
|
780
|
+
#: Specify the XML namespace that is used both for de/serialization and for schema
|
|
781
|
+
#: definitions
|
|
782
|
+
xml_namespace: Final[Stripped]
|
|
783
|
+
|
|
784
|
+
@require(lambda xml_namespace: not xml_namespace.endswith("/"))
|
|
785
|
+
@require(lambda xml_namespace: '"' not in xml_namespace)
|
|
786
|
+
@require(lambda xml_namespace: "'" not in xml_namespace)
|
|
787
|
+
def __init__(
|
|
788
|
+
self,
|
|
789
|
+
version: str,
|
|
790
|
+
xml_namespace: Stripped,
|
|
791
|
+
description: Optional[Description],
|
|
792
|
+
) -> None:
|
|
793
|
+
self.version = version
|
|
794
|
+
self.xml_namespace = xml_namespace
|
|
795
|
+
self.description = description
|
|
796
|
+
|
|
797
|
+
|
|
798
|
+
class UnverifiedSymbolTable(DBC):
|
|
799
|
+
"""
|
|
800
|
+
Represent the original classes in the meta-model.
|
|
801
|
+
|
|
802
|
+
This symbol table is unverified and may contain inconsistencies.
|
|
803
|
+
"""
|
|
804
|
+
|
|
805
|
+
#: List of parsed our types
|
|
806
|
+
our_types: Final[Sequence[OurType]]
|
|
807
|
+
|
|
808
|
+
#: List of constants in the meta-model
|
|
809
|
+
constants: Final[Sequence["ConstantUnion"]]
|
|
810
|
+
|
|
811
|
+
#: List of implementation-specific verification functions
|
|
812
|
+
verification_functions: Final[Sequence["FunctionUnion"]]
|
|
813
|
+
|
|
814
|
+
#: Additional information about the source meta-model
|
|
815
|
+
meta_model: Final[MetaModel]
|
|
816
|
+
|
|
817
|
+
_name_to_our_type: Final[Mapping[Identifier, OurType]]
|
|
818
|
+
|
|
819
|
+
_name_to_constant: Final[Mapping[Identifier, "ConstantUnion"]]
|
|
820
|
+
|
|
821
|
+
# fmt: off
|
|
822
|
+
@require(
|
|
823
|
+
lambda our_types: (
|
|
824
|
+
names := [our_type.name for our_type in our_types],
|
|
825
|
+
len(names) == len(set(names)),
|
|
826
|
+
)[1],
|
|
827
|
+
"Names of our types unique",
|
|
828
|
+
)
|
|
829
|
+
@require(
|
|
830
|
+
lambda constants: (
|
|
831
|
+
names := [constant.name for constant in constants],
|
|
832
|
+
len(names) == len(set(names)),
|
|
833
|
+
)[1],
|
|
834
|
+
"Names of the constants unique"
|
|
835
|
+
)
|
|
836
|
+
@require(
|
|
837
|
+
lambda verification_functions: (
|
|
838
|
+
names := [func.name for func in verification_functions],
|
|
839
|
+
len(names) == len(set(names)),
|
|
840
|
+
)[1],
|
|
841
|
+
"Names of the verification functions unique"
|
|
842
|
+
)
|
|
843
|
+
@require(
|
|
844
|
+
lambda verification_functions:
|
|
845
|
+
all(
|
|
846
|
+
'self' not in func.arguments_by_name
|
|
847
|
+
for func in verification_functions
|
|
848
|
+
if isinstance(func, UnderstoodMethod)
|
|
849
|
+
),
|
|
850
|
+
"No ``self`` in the verification functions expected as outside of a class"
|
|
851
|
+
)
|
|
852
|
+
# fmt: on
|
|
853
|
+
def __init__(
|
|
854
|
+
self,
|
|
855
|
+
our_types: Sequence[OurType],
|
|
856
|
+
constants: Sequence["ConstantUnion"],
|
|
857
|
+
verification_functions: Sequence["FunctionUnion"],
|
|
858
|
+
meta_model: MetaModel,
|
|
859
|
+
) -> None:
|
|
860
|
+
"""Initialize with the given values and map by name."""
|
|
861
|
+
self.our_types = our_types
|
|
862
|
+
self.constants = constants
|
|
863
|
+
self.verification_functions = verification_functions
|
|
864
|
+
self.meta_model = meta_model
|
|
865
|
+
|
|
866
|
+
self._name_to_our_type = {our_type.name: our_type for our_type in our_types}
|
|
867
|
+
self._name_to_constant = {constant.name: constant for constant in constants}
|
|
868
|
+
|
|
869
|
+
def find_our_type(self, name: Identifier) -> Optional[OurType]:
|
|
870
|
+
"""Find our type with the given name."""
|
|
871
|
+
return self._name_to_our_type.get(name, None)
|
|
872
|
+
|
|
873
|
+
def must_find_our_type(self, name: Identifier) -> OurType:
|
|
874
|
+
"""
|
|
875
|
+
Find our type with the given name.
|
|
876
|
+
|
|
877
|
+
:raise: :py:class:`KeyError` if it does not exist.
|
|
878
|
+
"""
|
|
879
|
+
our_type = self._name_to_our_type.get(name, None)
|
|
880
|
+
if our_type is None:
|
|
881
|
+
raise KeyError(name)
|
|
882
|
+
|
|
883
|
+
return our_type
|
|
884
|
+
|
|
885
|
+
# noinspection GrazieInspection
|
|
886
|
+
def must_find_class(self, name: Identifier) -> Class:
|
|
887
|
+
"""
|
|
888
|
+
Find the class with the given name.
|
|
889
|
+
|
|
890
|
+
:param name: identifier of the class
|
|
891
|
+
:return: the class
|
|
892
|
+
:raise: :py:class:`KeyError` if the name is not in the symbol table.
|
|
893
|
+
:raise: :py:class:`TypeError` if our type is not a class.
|
|
894
|
+
"""
|
|
895
|
+
our_type = self.must_find_our_type(name)
|
|
896
|
+
|
|
897
|
+
if not isinstance(our_type, Class):
|
|
898
|
+
raise TypeError(
|
|
899
|
+
f"Our type {name!r} is expected to be a class, "
|
|
900
|
+
f"but it is not: {our_type}"
|
|
901
|
+
)
|
|
902
|
+
|
|
903
|
+
return our_type
|
|
904
|
+
|
|
905
|
+
def find_constant(self, name: Identifier) -> Optional[Constant]:
|
|
906
|
+
"""Find the constant with the given name."""
|
|
907
|
+
return self._name_to_constant.get(name, None)
|
|
908
|
+
|
|
909
|
+
def must_find_constant(self, name: Identifier) -> Constant:
|
|
910
|
+
"""
|
|
911
|
+
Find the constant with the given name.
|
|
912
|
+
|
|
913
|
+
:raise: :py:class:`KeyError` if it does not exist.
|
|
914
|
+
"""
|
|
915
|
+
constant = self._name_to_constant.get(name, None)
|
|
916
|
+
if constant is None:
|
|
917
|
+
raise KeyError(name)
|
|
918
|
+
|
|
919
|
+
return constant
|
|
920
|
+
|
|
921
|
+
|
|
922
|
+
# noinspection PyInitNewSignature
|
|
923
|
+
class SymbolTable(UnverifiedSymbolTable):
|
|
924
|
+
"""
|
|
925
|
+
Represent a symbol table that has been locally verified.
|
|
926
|
+
|
|
927
|
+
Locality in this context means that there are no dangling or obviously invalid
|
|
928
|
+
inheritances, but higher-order relationships such as inheritance cycles has not
|
|
929
|
+
been verified yet.
|
|
930
|
+
"""
|
|
931
|
+
|
|
932
|
+
# fmt: off
|
|
933
|
+
@require(
|
|
934
|
+
lambda symbol_table:
|
|
935
|
+
all(
|
|
936
|
+
func.verification
|
|
937
|
+
for func in symbol_table.verification_functions
|
|
938
|
+
),
|
|
939
|
+
"All verification functions should have ``verification`` set; "
|
|
940
|
+
"this should have been caught as an Error before"
|
|
941
|
+
)
|
|
942
|
+
@require(
|
|
943
|
+
lambda symbol_table:
|
|
944
|
+
all(
|
|
945
|
+
not method.verification
|
|
946
|
+
for our_type in symbol_table.our_types
|
|
947
|
+
if isinstance(our_type, Class)
|
|
948
|
+
for method in our_type.methods
|
|
949
|
+
),
|
|
950
|
+
"All class methods should not have ``verification`` set; "
|
|
951
|
+
"this should have been caught as an Error before"
|
|
952
|
+
)
|
|
953
|
+
# fmt: on
|
|
954
|
+
def __new__(cls, symbol_table: UnverifiedSymbolTable) -> "SymbolTable":
|
|
955
|
+
return cast(SymbolTable, symbol_table)
|
|
956
|
+
|
|
957
|
+
|
|
958
|
+
# NOTE (mristin, 2022-07-01):
|
|
959
|
+
# At this moment, we only handle one type of constants, namely constant sets. However,
|
|
960
|
+
# we do anticipate more types of constants in the future, so we already prepare
|
|
961
|
+
# the program structure for that case.
|
|
962
|
+
ConstantUnion = Union[ConstantPrimitive, ConstantSet]
|
|
963
|
+
assert_union_of_descendants_exhaustive(union=ConstantUnion, base_class=Constant)
|
|
964
|
+
|
|
965
|
+
ClassUnion = Union[AbstractClass, ConcreteClass]
|
|
966
|
+
assert_union_of_descendants_exhaustive(union=ClassUnion, base_class=Class)
|
|
967
|
+
|
|
968
|
+
FunctionUnion = Union[UnderstoodMethod, ImplementationSpecificMethod]
|
|
969
|
+
|
|
970
|
+
MethodUnion = Union[
|
|
971
|
+
UnderstoodMethod, ImplementationSpecificMethod, ConstructorToBeUnderstood
|
|
972
|
+
]
|
|
973
|
+
assert_union_of_descendants_exhaustive(union=MethodUnion, base_class=Method)
|