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,754 @@
|
|
|
1
|
+
"""Translate control flows to linear flows with goto-statements and co-routines."""
|
|
2
|
+
import abc
|
|
3
|
+
import typing
|
|
4
|
+
from typing import (
|
|
5
|
+
Optional,
|
|
6
|
+
Union,
|
|
7
|
+
Sequence,
|
|
8
|
+
List,
|
|
9
|
+
Tuple,
|
|
10
|
+
Set,
|
|
11
|
+
Dict,
|
|
12
|
+
cast,
|
|
13
|
+
overload,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
from icontract import require, ensure
|
|
17
|
+
|
|
18
|
+
from aas_core_codegen import common
|
|
19
|
+
from aas_core_codegen.common import (
|
|
20
|
+
Stripped,
|
|
21
|
+
indent_but_first_line,
|
|
22
|
+
pairwise,
|
|
23
|
+
iterate_except_first,
|
|
24
|
+
)
|
|
25
|
+
from aas_core_codegen.yielding import flow as yielding_flow
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class Statement(abc.ABC):
|
|
29
|
+
"""Represent an abstract statement in a co-routine."""
|
|
30
|
+
|
|
31
|
+
@require(lambda label: not (label is not None) or label >= 0)
|
|
32
|
+
def __init__(self, label: Optional[int] = None) -> None:
|
|
33
|
+
"""Initialize with the given values."""
|
|
34
|
+
self.label = label
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class Command(Statement):
|
|
38
|
+
"""Represent a command which contains no jumps."""
|
|
39
|
+
|
|
40
|
+
def __init__(self, code: Stripped, label: Optional[int] = None) -> None:
|
|
41
|
+
"""Initialize with the given values."""
|
|
42
|
+
Statement.__init__(self, label=label)
|
|
43
|
+
|
|
44
|
+
self.code = code
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class If(Statement):
|
|
48
|
+
"""Represent a conditional jump, where we jump based on the condition."""
|
|
49
|
+
|
|
50
|
+
def __init__(
|
|
51
|
+
self,
|
|
52
|
+
condition: Stripped,
|
|
53
|
+
on_true: Optional[int] = None,
|
|
54
|
+
on_false: Optional[int] = None,
|
|
55
|
+
label: Optional[int] = None,
|
|
56
|
+
) -> None:
|
|
57
|
+
"""Initialize with the given values."""
|
|
58
|
+
Statement.__init__(self, label=label)
|
|
59
|
+
|
|
60
|
+
self.condition = condition
|
|
61
|
+
self.on_true = on_true
|
|
62
|
+
self.on_false = on_false
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class Jump(Statement):
|
|
66
|
+
"""Represent an unconditional jump in the execution."""
|
|
67
|
+
|
|
68
|
+
def __init__(self, target: int, label: Optional[int] = None) -> None:
|
|
69
|
+
"""Initialize with the given values."""
|
|
70
|
+
Statement.__init__(self, label=label)
|
|
71
|
+
|
|
72
|
+
self.target = target
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class Yield(Statement):
|
|
76
|
+
"""Represent a yield statement, where the next co-routine should take over."""
|
|
77
|
+
|
|
78
|
+
def __init__(self, label: Optional[int] = None) -> None:
|
|
79
|
+
"""Initialize with the given values."""
|
|
80
|
+
Statement.__init__(self, label=label)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class Noop(Statement):
|
|
84
|
+
"""Represent a no-operation statement, which does nothing."""
|
|
85
|
+
|
|
86
|
+
def __init__(
|
|
87
|
+
self, label: Optional[int] = None, comment: Optional[Stripped] = None
|
|
88
|
+
) -> None:
|
|
89
|
+
"""Initialize with the given values."""
|
|
90
|
+
Statement.__init__(self, label=label)
|
|
91
|
+
self.comment = comment
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
StatementUnion = Union[Command, If, Jump, Yield, Noop]
|
|
95
|
+
common.assert_union_of_descendants_exhaustive(
|
|
96
|
+
union=StatementUnion, base_class=Statement
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def _dump_command_without_label(command: Command) -> str:
|
|
101
|
+
return command.code
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def _dump_if_without_label(if_statement: If) -> str:
|
|
105
|
+
indent = " "
|
|
106
|
+
blocks = [] # type: List[str]
|
|
107
|
+
if "\n" in if_statement.condition:
|
|
108
|
+
blocks.append(
|
|
109
|
+
f"""\
|
|
110
|
+
if
|
|
111
|
+
{indent}{indent_but_first_line(if_statement.condition, indent)}"""
|
|
112
|
+
)
|
|
113
|
+
else:
|
|
114
|
+
blocks.append(f"if {if_statement.condition}")
|
|
115
|
+
|
|
116
|
+
if if_statement.on_true is not None:
|
|
117
|
+
blocks.append(f"is true, jump to {if_statement.on_true}")
|
|
118
|
+
|
|
119
|
+
if if_statement.on_false is not None:
|
|
120
|
+
blocks.append(f"is false, jump to {if_statement.on_false}")
|
|
121
|
+
|
|
122
|
+
return "\n".join(blocks)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def _dump_jump_without_label(jump: Jump) -> str:
|
|
126
|
+
return f"jump {jump.target}"
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def _dump_yield_without_label(yield_statement: Yield) -> str:
|
|
130
|
+
return "yield"
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def _dump_noop_without_label(noop_statement: Noop) -> str:
|
|
134
|
+
if noop_statement.comment is not None:
|
|
135
|
+
return f"noop - {noop_statement.comment}"
|
|
136
|
+
|
|
137
|
+
return "noop"
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
_DUMP_WITHOUT_LABEL_DISPATCH = {
|
|
141
|
+
Command: _dump_command_without_label,
|
|
142
|
+
If: _dump_if_without_label,
|
|
143
|
+
Jump: _dump_jump_without_label,
|
|
144
|
+
Yield: _dump_yield_without_label,
|
|
145
|
+
Noop: _dump_noop_without_label,
|
|
146
|
+
}
|
|
147
|
+
assert all(
|
|
148
|
+
cls in _DUMP_WITHOUT_LABEL_DISPATCH for cls in typing.get_args(StatementUnion)
|
|
149
|
+
), "All statements covered in _DUMP_WITHOUT_LABEL_DISPATCH"
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def _dump_without_label(statement: StatementUnion) -> str:
|
|
153
|
+
_dump_without_label_func = _DUMP_WITHOUT_LABEL_DISPATCH[statement.__class__]
|
|
154
|
+
result = _dump_without_label_func(statement) # type: ignore
|
|
155
|
+
assert isinstance(result, str) # necessary for mypy
|
|
156
|
+
return result
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def dump(statements: Sequence[StatementUnion]) -> str:
|
|
160
|
+
"""Render the statements to a textual sequence of labeled code."""
|
|
161
|
+
if len(statements) == 0:
|
|
162
|
+
return ""
|
|
163
|
+
|
|
164
|
+
max_label = None
|
|
165
|
+
for statement in statements:
|
|
166
|
+
if statement.label is not None:
|
|
167
|
+
if max_label is None:
|
|
168
|
+
max_label = statement.label
|
|
169
|
+
else:
|
|
170
|
+
max_label = statement.label
|
|
171
|
+
|
|
172
|
+
if max_label is None:
|
|
173
|
+
label_characters = 0
|
|
174
|
+
else:
|
|
175
|
+
label_characters = len(str(max_label))
|
|
176
|
+
|
|
177
|
+
label_format = f"{{:{label_characters}d}}: "
|
|
178
|
+
empty_label = " " * label_characters + ": "
|
|
179
|
+
indent = " " * (label_characters + 2)
|
|
180
|
+
|
|
181
|
+
blocks = [] # type: List[str]
|
|
182
|
+
for statement in statements:
|
|
183
|
+
if statement.label is not None:
|
|
184
|
+
label_str = label_format.format(statement.label)
|
|
185
|
+
else:
|
|
186
|
+
label_str = empty_label
|
|
187
|
+
|
|
188
|
+
code = _dump_without_label(statement)
|
|
189
|
+
|
|
190
|
+
blocks.append(
|
|
191
|
+
f"""\
|
|
192
|
+
{label_str}{indent_but_first_line(code, indent)}"""
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
return "\n".join(blocks)
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def _linearize_command(
|
|
199
|
+
command: yielding_flow.Command, label: int
|
|
200
|
+
) -> Tuple[List[StatementUnion], int]:
|
|
201
|
+
"""
|
|
202
|
+
Linearize the command with the given label.
|
|
203
|
+
|
|
204
|
+
Return the linearization and the next available label.
|
|
205
|
+
"""
|
|
206
|
+
return [Command(code=command.code, label=label)], label + 1
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def _linearize_if_true(
|
|
210
|
+
if_true_node: yielding_flow.IfTrue, label: int
|
|
211
|
+
) -> Tuple[List[StatementUnion], int]:
|
|
212
|
+
"""
|
|
213
|
+
Linearize recursively the if-node in the control flow with the given label.
|
|
214
|
+
|
|
215
|
+
Return the linearization and the next available label.
|
|
216
|
+
"""
|
|
217
|
+
# NOTE (mristin, 2023-10-20):
|
|
218
|
+
# We will fix this if-statement at the end, once we know the labels for ``on_true``
|
|
219
|
+
# and ``on_false``.
|
|
220
|
+
if_statement = If(condition=if_true_node.condition, label=label)
|
|
221
|
+
|
|
222
|
+
result = [if_statement] # type: List[StatementUnion]
|
|
223
|
+
label += 1
|
|
224
|
+
|
|
225
|
+
if if_true_node.or_else is not None:
|
|
226
|
+
body, label = _linearize_sequence(if_true_node.body, label)
|
|
227
|
+
result.extend(body)
|
|
228
|
+
|
|
229
|
+
# NOTE (mristin, 2023-10-20):
|
|
230
|
+
# This jump will be fixed after we know the exact target.
|
|
231
|
+
jump_to_done_after_body = Jump(target=-1, label=label)
|
|
232
|
+
result.append(jump_to_done_after_body)
|
|
233
|
+
label += 1
|
|
234
|
+
|
|
235
|
+
on_false = label
|
|
236
|
+
or_else, label = _linearize_sequence(if_true_node.or_else, label)
|
|
237
|
+
result.extend(or_else)
|
|
238
|
+
|
|
239
|
+
done_label = label
|
|
240
|
+
result.append(Noop(label=label))
|
|
241
|
+
label += 1
|
|
242
|
+
|
|
243
|
+
jump_to_done_after_body.target = done_label
|
|
244
|
+
|
|
245
|
+
if_statement.on_false = on_false
|
|
246
|
+
|
|
247
|
+
else:
|
|
248
|
+
body, label = _linearize_sequence(if_true_node.body, label)
|
|
249
|
+
if len(body) == 0:
|
|
250
|
+
result.append(Noop(label=label))
|
|
251
|
+
result.extend(body)
|
|
252
|
+
|
|
253
|
+
done_label = label
|
|
254
|
+
result.append(Noop(label=label))
|
|
255
|
+
label += 1
|
|
256
|
+
|
|
257
|
+
if_statement.on_false = done_label
|
|
258
|
+
|
|
259
|
+
return result, label
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
def _linearize_if_false(
|
|
263
|
+
if_false_node: yielding_flow.IfFalse, label: int
|
|
264
|
+
) -> Tuple[List[StatementUnion], int]:
|
|
265
|
+
"""
|
|
266
|
+
Linearize recursively the if-node in the control flow with the given label.
|
|
267
|
+
|
|
268
|
+
Return the linearization and the next available label.
|
|
269
|
+
"""
|
|
270
|
+
# NOTE (mristin, 2023-10-20):
|
|
271
|
+
# We will fix this if-statement at the end, once we know the labels for ``on_true``
|
|
272
|
+
# and ``on_false``.
|
|
273
|
+
if_statement = If(condition=if_false_node.condition, label=label)
|
|
274
|
+
|
|
275
|
+
result = [if_statement] # type: List[StatementUnion]
|
|
276
|
+
label += 1
|
|
277
|
+
|
|
278
|
+
if if_false_node.or_else is not None:
|
|
279
|
+
body, label = _linearize_sequence(if_false_node.body, label)
|
|
280
|
+
result.extend(body)
|
|
281
|
+
|
|
282
|
+
# NOTE (mristin, 2023-10-22):
|
|
283
|
+
# This jump will be fixed after we know the exact target.
|
|
284
|
+
jump_to_done_after_body = Jump(target=-1, label=label)
|
|
285
|
+
result.append(jump_to_done_after_body)
|
|
286
|
+
label += 1
|
|
287
|
+
|
|
288
|
+
on_true = label
|
|
289
|
+
or_else, label = _linearize_sequence(if_false_node.or_else, label)
|
|
290
|
+
result.extend(or_else)
|
|
291
|
+
|
|
292
|
+
done_label = label
|
|
293
|
+
result.append(Noop(label=label))
|
|
294
|
+
label += 1
|
|
295
|
+
|
|
296
|
+
jump_to_done_after_body.target = done_label
|
|
297
|
+
|
|
298
|
+
if_statement.on_true = on_true
|
|
299
|
+
|
|
300
|
+
else:
|
|
301
|
+
body, label = _linearize_sequence(if_false_node.body, label)
|
|
302
|
+
if len(body) == 0:
|
|
303
|
+
result.append(Noop(label=label))
|
|
304
|
+
result.extend(body)
|
|
305
|
+
|
|
306
|
+
done_label = label
|
|
307
|
+
result.append(Noop(label=label))
|
|
308
|
+
label += 1
|
|
309
|
+
|
|
310
|
+
if_statement.on_true = done_label
|
|
311
|
+
|
|
312
|
+
return result, label
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
def _linearize_for(
|
|
316
|
+
for_node: yielding_flow.For, label: int
|
|
317
|
+
) -> Tuple[List[StatementUnion], int]:
|
|
318
|
+
"""
|
|
319
|
+
Linearize recursively the for-node in the control flow with the given label.
|
|
320
|
+
|
|
321
|
+
Return the linearization and the next available label.
|
|
322
|
+
"""
|
|
323
|
+
result = [] # type: List[StatementUnion]
|
|
324
|
+
|
|
325
|
+
if for_node.init is not None:
|
|
326
|
+
result.append(Command(for_node.init, label=label))
|
|
327
|
+
label += 1
|
|
328
|
+
|
|
329
|
+
# NOTE (mristin, 2023-10-20):
|
|
330
|
+
# We will fix this if-statement at the end, once we know the label for ``on_true``.
|
|
331
|
+
if_statement = If(condition=for_node.condition, label=label)
|
|
332
|
+
|
|
333
|
+
result.append(if_statement)
|
|
334
|
+
label += 1
|
|
335
|
+
|
|
336
|
+
body, label = _linearize_sequence(for_node.body, label=label)
|
|
337
|
+
result.extend(body)
|
|
338
|
+
|
|
339
|
+
result.append(Command(for_node.iteration, label=label))
|
|
340
|
+
label += 1
|
|
341
|
+
|
|
342
|
+
assert if_statement.label is not None, (
|
|
343
|
+
"The label of the condition If-statement must have been set; otherwise "
|
|
344
|
+
"we do not know where to jump at the end of a loop iteration."
|
|
345
|
+
)
|
|
346
|
+
result.append(Jump(target=if_statement.label, label=label))
|
|
347
|
+
label += 1
|
|
348
|
+
|
|
349
|
+
done_label = label
|
|
350
|
+
result.append(Noop(label=done_label))
|
|
351
|
+
label += 1
|
|
352
|
+
|
|
353
|
+
if_statement.on_false = done_label
|
|
354
|
+
|
|
355
|
+
return result, label
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
def _linearize_while(
|
|
359
|
+
while_node: yielding_flow.While, label: int
|
|
360
|
+
) -> Tuple[List[StatementUnion], int]:
|
|
361
|
+
"""
|
|
362
|
+
Linearize the while-node in the control flow with the given label.
|
|
363
|
+
|
|
364
|
+
Return the linearization and the next available label.
|
|
365
|
+
"""
|
|
366
|
+
result = [] # type: List[StatementUnion]
|
|
367
|
+
|
|
368
|
+
# NOTE (mristin, 2023-10-28):
|
|
369
|
+
# We will fix this if-statement at the end, once we know the label for ``on_true``.
|
|
370
|
+
if_statement = If(condition=while_node.condition, label=label)
|
|
371
|
+
label += 1
|
|
372
|
+
result.append(if_statement)
|
|
373
|
+
|
|
374
|
+
body, label = _linearize_sequence(while_node.body, label=label)
|
|
375
|
+
result.extend(body)
|
|
376
|
+
|
|
377
|
+
assert if_statement.label is not None, (
|
|
378
|
+
"The label of the condition If-statement must have been set; otherwise "
|
|
379
|
+
"we do not know where to jump at the end of a loop iteration."
|
|
380
|
+
)
|
|
381
|
+
|
|
382
|
+
result.append(Jump(target=if_statement.label, label=label))
|
|
383
|
+
label += 1
|
|
384
|
+
|
|
385
|
+
done_label = label
|
|
386
|
+
result.append(Noop(label=done_label))
|
|
387
|
+
label += 1
|
|
388
|
+
|
|
389
|
+
if_statement.on_false = done_label
|
|
390
|
+
|
|
391
|
+
return result, label
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
def _linearize_yield(
|
|
395
|
+
yield_node: yielding_flow.Yield, label: int
|
|
396
|
+
) -> Tuple[List[StatementUnion], int]:
|
|
397
|
+
"""
|
|
398
|
+
Linearize the yield node in the control flow with the given label.
|
|
399
|
+
|
|
400
|
+
Return the linearization and the next available label.
|
|
401
|
+
"""
|
|
402
|
+
return [Yield(label=label)], label + 1
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
_LINEARIZE_DISPATCH = {
|
|
406
|
+
yielding_flow.Command: _linearize_command,
|
|
407
|
+
yielding_flow.IfTrue: _linearize_if_true,
|
|
408
|
+
yielding_flow.IfFalse: _linearize_if_false,
|
|
409
|
+
yielding_flow.For: _linearize_for,
|
|
410
|
+
yielding_flow.While: _linearize_while,
|
|
411
|
+
yielding_flow.Yield: _linearize_yield,
|
|
412
|
+
}
|
|
413
|
+
assert all(
|
|
414
|
+
cls in _LINEARIZE_DISPATCH for cls in typing.get_args(yielding_flow.Node)
|
|
415
|
+
), "All classes covered in _LINEARIZE_DISPATCH"
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
def _linearize_node(
|
|
419
|
+
node: yielding_flow.Node, label: int
|
|
420
|
+
) -> Tuple[List[StatementUnion], int]:
|
|
421
|
+
"""
|
|
422
|
+
Linearize the yield node in the control flow with the given label.
|
|
423
|
+
|
|
424
|
+
Return the linearization and the next available label.
|
|
425
|
+
"""
|
|
426
|
+
linearize_func = _LINEARIZE_DISPATCH[node.__class__]
|
|
427
|
+
result = linearize_func(node, label) # type: ignore
|
|
428
|
+
|
|
429
|
+
assert isinstance(result, tuple)
|
|
430
|
+
assert isinstance(result[0], list)
|
|
431
|
+
assert isinstance(result[1], int)
|
|
432
|
+
|
|
433
|
+
return linearize_func(node, label) # type: ignore
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
@ensure(
|
|
437
|
+
lambda sequence, label, result: not (len(sequence) == 0)
|
|
438
|
+
or (len(result[0]) == 0 and label == result[1]),
|
|
439
|
+
"Empty sequence implies no statements and no change in labels",
|
|
440
|
+
)
|
|
441
|
+
def _linearize_sequence(
|
|
442
|
+
sequence: Sequence[yielding_flow.Node], label: int
|
|
443
|
+
) -> Tuple[List[StatementUnion], int]:
|
|
444
|
+
"""
|
|
445
|
+
Linearize recursively the control flow sequence, starting with the given label.
|
|
446
|
+
:param sequence:
|
|
447
|
+
:return:
|
|
448
|
+
"""
|
|
449
|
+
result = [] # type: List[StatementUnion]
|
|
450
|
+
for node in sequence:
|
|
451
|
+
statements, label = _linearize_node(node, label)
|
|
452
|
+
result.extend(statements)
|
|
453
|
+
|
|
454
|
+
return result, label
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
def _linearize_control_flow(flow: Sequence[yielding_flow.Node]) -> List[StatementUnion]:
|
|
458
|
+
"""Compile the control flow into a linearized sequence of statements."""
|
|
459
|
+
statements, _ = _linearize_sequence(flow, label=0)
|
|
460
|
+
return statements
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
def _collect_targets(statements: Sequence[StatementUnion]) -> Set[int]:
|
|
464
|
+
"""Collect all the targets over all the sequences."""
|
|
465
|
+
result = set() # type: Set[int]
|
|
466
|
+
for statement in statements:
|
|
467
|
+
if isinstance(statement, Jump):
|
|
468
|
+
result.add(statement.target)
|
|
469
|
+
|
|
470
|
+
elif isinstance(statement, If):
|
|
471
|
+
if statement.on_true is not None:
|
|
472
|
+
result.add(statement.on_true)
|
|
473
|
+
|
|
474
|
+
if statement.on_false is not None:
|
|
475
|
+
result.add(statement.on_false)
|
|
476
|
+
else:
|
|
477
|
+
pass
|
|
478
|
+
|
|
479
|
+
return result
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
def _remove_redundant_labels_in_place(statements: Sequence[StatementUnion]) -> None:
|
|
483
|
+
"""Remove labels from statements which are never a target."""
|
|
484
|
+
target_set = _collect_targets(statements)
|
|
485
|
+
for statement in statements:
|
|
486
|
+
if statement.label not in target_set:
|
|
487
|
+
statement.label = None
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
def _remove_noops_in_place(statements: List[StatementUnion]) -> List[StatementUnion]:
|
|
491
|
+
"""
|
|
492
|
+
Remove no-ops and re-wire the targets in-place.
|
|
493
|
+
|
|
494
|
+
The input statements list is invalidated, and should not be used after the call
|
|
495
|
+
to this function.
|
|
496
|
+
"""
|
|
497
|
+
# NOTE (mristin, 2023-10-20):
|
|
498
|
+
# We can safely remove all no-ops which do not have a label, since they are
|
|
499
|
+
# not targeted at all.
|
|
500
|
+
statements = [
|
|
501
|
+
statement
|
|
502
|
+
for statement in statements
|
|
503
|
+
if not isinstance(statement, Noop) or statement.label is not None
|
|
504
|
+
]
|
|
505
|
+
|
|
506
|
+
# NOTE (mristin, 2023-10-20):
|
|
507
|
+
# We will iterate through the statements now, map all the targets to the new
|
|
508
|
+
# labels, and mark the no-ops for removal by unsetting their labels.
|
|
509
|
+
|
|
510
|
+
old_to_new_target = dict() # type: Dict[int, int]
|
|
511
|
+
noop_block = [] # type: List[Noop]
|
|
512
|
+
|
|
513
|
+
for statement in statements:
|
|
514
|
+
if isinstance(statement, Noop):
|
|
515
|
+
noop_block.append(statement)
|
|
516
|
+
else:
|
|
517
|
+
if len(noop_block) == 0:
|
|
518
|
+
continue
|
|
519
|
+
|
|
520
|
+
# NOTE (mristin, 2023-10-20):
|
|
521
|
+
# If the statement does not have a label, we arbitrarily assign the label
|
|
522
|
+
# of the first no-op in the block.
|
|
523
|
+
if statement.label is None:
|
|
524
|
+
assert noop_block[0].label is not None, (
|
|
525
|
+
"The label of the first no-op statement is always expected "
|
|
526
|
+
"as it starts a block."
|
|
527
|
+
)
|
|
528
|
+
|
|
529
|
+
statement.label = noop_block[0].label
|
|
530
|
+
|
|
531
|
+
for noop in noop_block:
|
|
532
|
+
assert noop.label is not None, (
|
|
533
|
+
"We have removed non-labeled no-ops before, "
|
|
534
|
+
"so all remaining no-ops must have a label."
|
|
535
|
+
)
|
|
536
|
+
|
|
537
|
+
assert (
|
|
538
|
+
statement.label is not None
|
|
539
|
+
), "The statement must have been set before so that we can map it."
|
|
540
|
+
|
|
541
|
+
old_to_new_target[noop.label] = statement.label
|
|
542
|
+
noop.label = None
|
|
543
|
+
|
|
544
|
+
noop_block = []
|
|
545
|
+
|
|
546
|
+
if len(noop_block) > 1:
|
|
547
|
+
# NOTE (mristin, 2023-10-20):
|
|
548
|
+
# This is a trailing no-op block. We simply reduce it to one no-op.
|
|
549
|
+
iter_noop_block = iter(noop_block)
|
|
550
|
+
next(iter_noop_block)
|
|
551
|
+
|
|
552
|
+
for noop in iter_noop_block:
|
|
553
|
+
assert noop.label is not None, (
|
|
554
|
+
"We have removed non-labeled no-ops before, "
|
|
555
|
+
"so all remaining no-ops must have a label."
|
|
556
|
+
)
|
|
557
|
+
|
|
558
|
+
assert noop_block[0].label is not None, (
|
|
559
|
+
"Since all no-op statements must have a label, "
|
|
560
|
+
"the first no-op in the block must have a label as well."
|
|
561
|
+
)
|
|
562
|
+
|
|
563
|
+
old_to_new_target[noop.label] = noop_block[0].label
|
|
564
|
+
noop.label = None
|
|
565
|
+
|
|
566
|
+
# NOTE (mristin, 2023-10-20):
|
|
567
|
+
# We marked all no-ops for removal by unsetting their label.
|
|
568
|
+
statements = [
|
|
569
|
+
statement
|
|
570
|
+
for statement in statements
|
|
571
|
+
if not isinstance(statement, Noop) or statement.label is not None
|
|
572
|
+
]
|
|
573
|
+
|
|
574
|
+
# NOTE (mristin, 2023-10-20):
|
|
575
|
+
# Now we have to re-wire the targets.
|
|
576
|
+
for statement in statements:
|
|
577
|
+
if isinstance(statement, If):
|
|
578
|
+
if statement.on_true is not None and statement.on_true in old_to_new_target:
|
|
579
|
+
statement.on_true = old_to_new_target[statement.on_true]
|
|
580
|
+
|
|
581
|
+
if (
|
|
582
|
+
statement.on_false is not None
|
|
583
|
+
and statement.on_false in old_to_new_target
|
|
584
|
+
):
|
|
585
|
+
statement.on_false = old_to_new_target[statement.on_false]
|
|
586
|
+
|
|
587
|
+
elif isinstance(statement, Jump):
|
|
588
|
+
if statement.target in old_to_new_target:
|
|
589
|
+
statement.target = old_to_new_target[statement.target]
|
|
590
|
+
|
|
591
|
+
else:
|
|
592
|
+
pass
|
|
593
|
+
|
|
594
|
+
return statements
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
def _compress_in_place(statements: List[StatementUnion]) -> List[StatementUnion]:
|
|
598
|
+
"""
|
|
599
|
+
Remove redundant statements and labels.
|
|
600
|
+
|
|
601
|
+
The input statements list is invalidated, and should not be used after the call
|
|
602
|
+
to this function.
|
|
603
|
+
"""
|
|
604
|
+
_remove_redundant_labels_in_place(statements)
|
|
605
|
+
statements = _remove_noops_in_place(statements)
|
|
606
|
+
return statements
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
def _fix_labels_in_place(statements: List[StatementUnion]) -> None:
|
|
610
|
+
"""
|
|
611
|
+
Go through statements and re-wire the labels so that they are consecutive.
|
|
612
|
+
|
|
613
|
+
Moreover, we make sure that there is a label after each yield and at the first
|
|
614
|
+
statement, so that we can split statements in blocks by labels.
|
|
615
|
+
"""
|
|
616
|
+
if len(statements) == 0:
|
|
617
|
+
return
|
|
618
|
+
|
|
619
|
+
label = (
|
|
620
|
+
max(
|
|
621
|
+
statement.label if statement.label is not None else 0
|
|
622
|
+
for statement in statements
|
|
623
|
+
)
|
|
624
|
+
+ 1
|
|
625
|
+
)
|
|
626
|
+
|
|
627
|
+
# NOTE (mristin, 2023-10-20):
|
|
628
|
+
# We simply set the first label to some arbitrary number and fix it later.
|
|
629
|
+
if statements[0].label is None:
|
|
630
|
+
statements[0].label = label
|
|
631
|
+
label += 1
|
|
632
|
+
|
|
633
|
+
# NOTE (mristin, 2023-10-21):
|
|
634
|
+
# We add a label after each yield so that we can split the statements in block,
|
|
635
|
+
# where each block starts with a statement label.
|
|
636
|
+
for previous, current in pairwise(statements):
|
|
637
|
+
if isinstance(previous, Yield) and current.label is None:
|
|
638
|
+
current.label = label
|
|
639
|
+
label += 1
|
|
640
|
+
|
|
641
|
+
# NOTE (mristin, 2023-10-21):
|
|
642
|
+
# Now reset all labels so that they are consecutive.
|
|
643
|
+
|
|
644
|
+
label = 0
|
|
645
|
+
|
|
646
|
+
old_to_new_label = dict() # type: Dict[int, int]
|
|
647
|
+
for statement in statements:
|
|
648
|
+
if statement.label is not None:
|
|
649
|
+
old_to_new_label[statement.label] = label
|
|
650
|
+
label += 1
|
|
651
|
+
|
|
652
|
+
for statement in statements:
|
|
653
|
+
if statement.label is not None:
|
|
654
|
+
statement.label = old_to_new_label[statement.label]
|
|
655
|
+
|
|
656
|
+
if isinstance(statement, If):
|
|
657
|
+
if statement.on_true is not None and statement.on_true in old_to_new_label:
|
|
658
|
+
statement.on_true = old_to_new_label[statement.on_true]
|
|
659
|
+
|
|
660
|
+
if (
|
|
661
|
+
statement.on_false is not None
|
|
662
|
+
and statement.on_false in old_to_new_label
|
|
663
|
+
):
|
|
664
|
+
statement.on_false = old_to_new_label[statement.on_false]
|
|
665
|
+
|
|
666
|
+
elif isinstance(statement, Jump):
|
|
667
|
+
if statement.target in old_to_new_label:
|
|
668
|
+
statement.target = old_to_new_label[statement.target]
|
|
669
|
+
|
|
670
|
+
else:
|
|
671
|
+
pass
|
|
672
|
+
|
|
673
|
+
|
|
674
|
+
class Subroutine(Sequence[StatementUnion]):
|
|
675
|
+
"""Capture a subroutine which can execute between the yields."""
|
|
676
|
+
|
|
677
|
+
# fmt: off
|
|
678
|
+
@require(
|
|
679
|
+
lambda statements:
|
|
680
|
+
statements[0].label is not None
|
|
681
|
+
and all(
|
|
682
|
+
statement.label is None
|
|
683
|
+
for statement in iterate_except_first(statements)
|
|
684
|
+
),
|
|
685
|
+
"Only the first statement should have the label defined, "
|
|
686
|
+
"and the remainder of the statements should not."
|
|
687
|
+
)
|
|
688
|
+
@require(
|
|
689
|
+
lambda statements: len(statements) > 0,
|
|
690
|
+
"Empty subroutines are ill-defined"
|
|
691
|
+
)
|
|
692
|
+
# fmt: on
|
|
693
|
+
def __new__(cls, statements: Sequence[StatementUnion]) -> "Subroutine":
|
|
694
|
+
return cast(Subroutine, statements)
|
|
695
|
+
|
|
696
|
+
@overload
|
|
697
|
+
def __getitem__(self, index: int) -> StatementUnion:
|
|
698
|
+
raise NotImplementedError("Only for type annotations")
|
|
699
|
+
|
|
700
|
+
@overload
|
|
701
|
+
def __getitem__(self, index: slice) -> "Subroutine":
|
|
702
|
+
raise NotImplementedError("Only for type annotations")
|
|
703
|
+
|
|
704
|
+
def __getitem__(
|
|
705
|
+
self, index: Union[int, slice]
|
|
706
|
+
) -> Union[StatementUnion, "Subroutine"]:
|
|
707
|
+
raise NotImplementedError("Only for type annotations")
|
|
708
|
+
|
|
709
|
+
def __len__(self) -> int:
|
|
710
|
+
raise NotImplementedError("Only for type annotations")
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
def _split_in_subroutines(statements: Sequence[StatementUnion]) -> List[Subroutine]:
|
|
714
|
+
"""Split the statements in blocks on each label."""
|
|
715
|
+
result = [] # type: List[Subroutine]
|
|
716
|
+
|
|
717
|
+
block = [] # type: List[StatementUnion]
|
|
718
|
+
for statement in statements:
|
|
719
|
+
if statement.label is not None:
|
|
720
|
+
if len(block) > 0:
|
|
721
|
+
result.append(Subroutine(block))
|
|
722
|
+
|
|
723
|
+
block = [statement]
|
|
724
|
+
|
|
725
|
+
else:
|
|
726
|
+
block.append(statement)
|
|
727
|
+
|
|
728
|
+
if len(block) > 0:
|
|
729
|
+
result.append(Subroutine(block))
|
|
730
|
+
|
|
731
|
+
return result
|
|
732
|
+
|
|
733
|
+
|
|
734
|
+
# fmt: off
|
|
735
|
+
@ensure(
|
|
736
|
+
lambda result:
|
|
737
|
+
all(
|
|
738
|
+
subroutine[0].label + 1 == next_subroutine[0].label
|
|
739
|
+
for subroutine, next_subroutine in pairwise(result)
|
|
740
|
+
),
|
|
741
|
+
"Subroutine labels are consecutively increasing"
|
|
742
|
+
)
|
|
743
|
+
# fmt: on
|
|
744
|
+
def linearize_to_subroutines(flow: Sequence[yielding_flow.Node]) -> List[Subroutine]:
|
|
745
|
+
"""Linearize the control flow and split it in subroutines on each yield."""
|
|
746
|
+
if len(flow) == 0:
|
|
747
|
+
return []
|
|
748
|
+
|
|
749
|
+
statements = _linearize_control_flow(flow)
|
|
750
|
+
statements = _compress_in_place(statements)
|
|
751
|
+
_fix_labels_in_place(statements)
|
|
752
|
+
subroutines = _split_in_subroutines(statements)
|
|
753
|
+
|
|
754
|
+
return subroutines
|