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,796 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Define the parse rules for transforming Python AST to our custom AST.
|
|
3
|
+
|
|
4
|
+
This module provides translation from a very general Python AST to our more specific,
|
|
5
|
+
domain-related syntax.
|
|
6
|
+
|
|
7
|
+
For comparison, :py:mod:`aas_core_codegen.intermediate` is responsible for
|
|
8
|
+
semantic analysis, simplifications and resolution to environments and actual symbols.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import abc
|
|
12
|
+
import ast
|
|
13
|
+
import os
|
|
14
|
+
import pathlib
|
|
15
|
+
import sys
|
|
16
|
+
from typing import Tuple, Optional, List, Mapping, Type, Sequence, Union, cast
|
|
17
|
+
|
|
18
|
+
from icontract import ensure
|
|
19
|
+
|
|
20
|
+
from aas_core_codegen.common import Identifier, Error, assert_never
|
|
21
|
+
from aas_core_codegen.parse import tree
|
|
22
|
+
|
|
23
|
+
# noinspection PyTypeChecker
|
|
24
|
+
_AST_COMPARATOR_TO_OURS = {
|
|
25
|
+
ast.Lt: tree.Comparator.LT,
|
|
26
|
+
ast.LtE: tree.Comparator.LE,
|
|
27
|
+
ast.Gt: tree.Comparator.GT,
|
|
28
|
+
ast.GtE: tree.Comparator.GE,
|
|
29
|
+
ast.Eq: tree.Comparator.EQ,
|
|
30
|
+
ast.NotEq: tree.Comparator.NE,
|
|
31
|
+
} # type: Mapping[Type[ast.cmpop], tree.Comparator]
|
|
32
|
+
|
|
33
|
+
_AST_COMPARATORS = tuple(_AST_COMPARATOR_TO_OURS.keys())
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class _Parse(abc.ABC):
|
|
37
|
+
"""Define a parse rule from a Python AST node to our custom AST."""
|
|
38
|
+
|
|
39
|
+
@abc.abstractmethod
|
|
40
|
+
def matches(self, node: ast.AST) -> bool:
|
|
41
|
+
"""Return True if the node can be matched by the rule."""
|
|
42
|
+
raise NotImplementedError()
|
|
43
|
+
|
|
44
|
+
@abc.abstractmethod
|
|
45
|
+
@ensure(lambda result: (result[0] is not None) ^ (result[1] is not None))
|
|
46
|
+
def transform(self, node: ast.AST) -> Tuple[Optional[tree.Node], Optional[Error]]:
|
|
47
|
+
"""Transform the Python node to our custom node."""
|
|
48
|
+
raise NotImplementedError()
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class _ParseComparison(_Parse):
|
|
52
|
+
def matches(self, node: ast.AST) -> bool:
|
|
53
|
+
return (
|
|
54
|
+
isinstance(node, ast.Compare)
|
|
55
|
+
and len(node.ops) == 1
|
|
56
|
+
and isinstance(node.ops[0], _AST_COMPARATORS)
|
|
57
|
+
and len(node.comparators) == 1
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
# noinspection PyTypeChecker
|
|
61
|
+
def transform(self, node: ast.AST) -> Tuple[Optional[tree.Node], Optional[Error]]:
|
|
62
|
+
assert isinstance(node, ast.Compare)
|
|
63
|
+
|
|
64
|
+
left, error = ast_node_to_our_node(cast(ast.AST, node.left))
|
|
65
|
+
if error is not None:
|
|
66
|
+
return None, error
|
|
67
|
+
|
|
68
|
+
assert isinstance(left, tree.Expression), f"{left=}"
|
|
69
|
+
|
|
70
|
+
op = _AST_COMPARATOR_TO_OURS[type(node.ops[0])]
|
|
71
|
+
|
|
72
|
+
right, error = ast_node_to_our_node(node.comparators[0])
|
|
73
|
+
if error is not None:
|
|
74
|
+
return None, error
|
|
75
|
+
|
|
76
|
+
assert isinstance(right, tree.Expression), f"{right=}"
|
|
77
|
+
|
|
78
|
+
return tree.Comparison(left=left, op=op, right=right, original_node=node), None
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class _ParseIsIn(_Parse):
|
|
82
|
+
def matches(self, node: ast.AST) -> bool:
|
|
83
|
+
return (
|
|
84
|
+
isinstance(node, ast.Compare)
|
|
85
|
+
and len(node.ops) == 1
|
|
86
|
+
and isinstance(node.ops[0], ast.In)
|
|
87
|
+
and len(node.comparators) == 1
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
# noinspection PyTypeChecker
|
|
91
|
+
def transform(self, node: ast.AST) -> Tuple[Optional[tree.Node], Optional[Error]]:
|
|
92
|
+
assert isinstance(node, ast.Compare)
|
|
93
|
+
|
|
94
|
+
member, error = ast_node_to_our_node(cast(ast.AST, node.left))
|
|
95
|
+
if error is not None:
|
|
96
|
+
return None, error
|
|
97
|
+
|
|
98
|
+
assert isinstance(member, tree.Expression), f"{member=}"
|
|
99
|
+
|
|
100
|
+
container, error = ast_node_to_our_node(node.comparators[0])
|
|
101
|
+
if error is not None:
|
|
102
|
+
return None, error
|
|
103
|
+
|
|
104
|
+
assert isinstance(container, tree.Expression), f"{container=}"
|
|
105
|
+
|
|
106
|
+
return tree.IsIn(member=member, container=container, original_node=node), None
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class _ParseAnyOrAll(_Parse):
|
|
110
|
+
def matches(self, node: ast.AST) -> bool:
|
|
111
|
+
return (
|
|
112
|
+
isinstance(node, ast.Call)
|
|
113
|
+
and isinstance(node.func, ast.Name)
|
|
114
|
+
and node.func.id in ("any", "all")
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
# noinspection PyUnresolvedReferences,PyTypeChecker
|
|
118
|
+
def transform(self, node: ast.AST) -> Tuple[Optional[tree.Node], Optional[Error]]:
|
|
119
|
+
assert (
|
|
120
|
+
isinstance(node, ast.Call)
|
|
121
|
+
and isinstance(node.func, ast.Name)
|
|
122
|
+
and node.func.id in ("any", "all")
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
if len(node.keywords) > 0:
|
|
126
|
+
return None, Error(
|
|
127
|
+
node,
|
|
128
|
+
f"Expected no keyword arguments in ``{node.func.id}``, "
|
|
129
|
+
f"but got {len(node.keywords)}",
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
if len(node.args) != 1:
|
|
133
|
+
return None, Error(
|
|
134
|
+
node,
|
|
135
|
+
f"Expected exactly one argument in ``{node.func.id}``, "
|
|
136
|
+
f"but got {len(node.args)}",
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
if not isinstance(node.args[0], ast.GeneratorExp):
|
|
140
|
+
return None, Error(
|
|
141
|
+
node,
|
|
142
|
+
f"Expected a generator expression in ``{node.func.id}``, "
|
|
143
|
+
f"but got: {ast.dump(node)}",
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
generator_exp = node.args[0]
|
|
147
|
+
|
|
148
|
+
# noinspection PyUnresolvedReferences
|
|
149
|
+
our_condition, error = ast_node_to_our_node(generator_exp.elt)
|
|
150
|
+
if error is not None:
|
|
151
|
+
return None, error
|
|
152
|
+
|
|
153
|
+
assert isinstance(our_condition, tree.Expression), f"{our_condition=}"
|
|
154
|
+
|
|
155
|
+
if len(generator_exp.generators) != 1:
|
|
156
|
+
return None, Error(
|
|
157
|
+
node,
|
|
158
|
+
f"Expected exactly one generator in ``{node.func.id}``, "
|
|
159
|
+
f"but got {len(generator_exp.generators)}",
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
generator = generator_exp.generators[0]
|
|
163
|
+
if not isinstance(generator, ast.comprehension):
|
|
164
|
+
return None, Error(
|
|
165
|
+
generator, f"Expected a comprehension, but got: {ast.dump(generator)}"
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
if not isinstance(generator.target, ast.Name):
|
|
169
|
+
return None, Error(
|
|
170
|
+
generator,
|
|
171
|
+
f"Expected the target of the generator to be a name, "
|
|
172
|
+
f"but got: {ast.dump(generator.target)}",
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
our_variable, error = ast_node_to_our_node(generator.target)
|
|
176
|
+
if error is not None:
|
|
177
|
+
return None, error
|
|
178
|
+
assert isinstance(our_variable, tree.Name), f"{our_variable=}"
|
|
179
|
+
|
|
180
|
+
# region Parse the generator
|
|
181
|
+
|
|
182
|
+
our_generator: tree.ForUnion
|
|
183
|
+
|
|
184
|
+
if (
|
|
185
|
+
isinstance(generator.iter, ast.Call)
|
|
186
|
+
and isinstance(generator.iter.func, ast.Name)
|
|
187
|
+
and generator.iter.func.id == "range"
|
|
188
|
+
):
|
|
189
|
+
if len(generator.iter.args) != 2:
|
|
190
|
+
return None, Error(
|
|
191
|
+
generator.iter,
|
|
192
|
+
f"Expected exactly to arguments to a call of ``range``, "
|
|
193
|
+
f"but got: {len(generator.iter.args)}",
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
if len(generator.iter.keywords) != 0:
|
|
197
|
+
return None, Error(
|
|
198
|
+
generator.iter,
|
|
199
|
+
f"Expected no keyword arguments to a call of ``range``, "
|
|
200
|
+
f"but got: {len(generator.iter.keywords)}",
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
start, error = ast_node_to_our_node(generator.iter.args[0])
|
|
204
|
+
if error is not None:
|
|
205
|
+
return None, error
|
|
206
|
+
|
|
207
|
+
end, error = ast_node_to_our_node(generator.iter.args[1])
|
|
208
|
+
if error is not None:
|
|
209
|
+
return None, error
|
|
210
|
+
|
|
211
|
+
assert isinstance(start, tree.Expression), f"{start=}"
|
|
212
|
+
assert isinstance(end, tree.Expression), f"{end=}"
|
|
213
|
+
|
|
214
|
+
our_generator = tree.ForRange(
|
|
215
|
+
variable=our_variable, start=start, end=end, original_node=generator
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
else:
|
|
219
|
+
our_iteration, error = ast_node_to_our_node(generator.iter)
|
|
220
|
+
if error is not None:
|
|
221
|
+
return None, error
|
|
222
|
+
|
|
223
|
+
assert isinstance(our_iteration, tree.Expression), f"{our_iteration=}"
|
|
224
|
+
|
|
225
|
+
our_generator = tree.ForEach(
|
|
226
|
+
variable=our_variable, iteration=our_iteration, original_node=generator
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
# endregion
|
|
230
|
+
|
|
231
|
+
# noinspection PyUnusedLocal
|
|
232
|
+
factory_to_use: Union[Type[tree.Any], Type[tree.All]]
|
|
233
|
+
if node.func.id == "any":
|
|
234
|
+
factory_to_use = tree.Any
|
|
235
|
+
elif node.func.id == "all":
|
|
236
|
+
factory_to_use = tree.All
|
|
237
|
+
else:
|
|
238
|
+
raise AssertionError(f"Unexpected {node.func.id=}")
|
|
239
|
+
|
|
240
|
+
return (
|
|
241
|
+
factory_to_use(
|
|
242
|
+
generator=our_generator,
|
|
243
|
+
condition=our_condition,
|
|
244
|
+
original_node=node,
|
|
245
|
+
),
|
|
246
|
+
None,
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
class _ParseCall(_Parse):
|
|
251
|
+
def matches(self, node: ast.AST) -> bool:
|
|
252
|
+
return isinstance(node, ast.Call)
|
|
253
|
+
|
|
254
|
+
# noinspection PyTypeChecker
|
|
255
|
+
def transform(self, node: ast.AST) -> Tuple[Optional[tree.Node], Optional[Error]]:
|
|
256
|
+
assert isinstance(node, ast.Call)
|
|
257
|
+
|
|
258
|
+
args = [] # type: List[tree.Expression]
|
|
259
|
+
for arg_node in node.args:
|
|
260
|
+
arg, error = ast_node_to_our_node(arg_node)
|
|
261
|
+
if error is not None:
|
|
262
|
+
return None, error
|
|
263
|
+
|
|
264
|
+
if not isinstance(arg, tree.Expression):
|
|
265
|
+
return None, Error(
|
|
266
|
+
arg_node,
|
|
267
|
+
f"Expected the argument to a call to be an expression, "
|
|
268
|
+
f"but got: {arg}",
|
|
269
|
+
)
|
|
270
|
+
|
|
271
|
+
args.append(arg)
|
|
272
|
+
|
|
273
|
+
if len(node.keywords) > 0:
|
|
274
|
+
return None, Error(
|
|
275
|
+
node,
|
|
276
|
+
"Keyword arguments are not supported since "
|
|
277
|
+
"many implementation languages do not support them",
|
|
278
|
+
)
|
|
279
|
+
|
|
280
|
+
if isinstance(node.func, ast.Name):
|
|
281
|
+
name, error = ast_node_to_our_node(node.func)
|
|
282
|
+
if error is not None:
|
|
283
|
+
return None, error
|
|
284
|
+
|
|
285
|
+
assert name is not None
|
|
286
|
+
assert isinstance(name, tree.Name)
|
|
287
|
+
|
|
288
|
+
return (
|
|
289
|
+
tree.FunctionCall(name=name, args=args, original_node=node),
|
|
290
|
+
None,
|
|
291
|
+
)
|
|
292
|
+
else:
|
|
293
|
+
member, error = ast_node_to_our_node(node.func)
|
|
294
|
+
if error is not None:
|
|
295
|
+
return None, error
|
|
296
|
+
|
|
297
|
+
assert isinstance(
|
|
298
|
+
member, tree.Member
|
|
299
|
+
), f"Expected a member for {ast.dump(node.func)=}, but got: {member=}"
|
|
300
|
+
|
|
301
|
+
return tree.MethodCall(member=member, args=args, original_node=node), None
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
class _ParseConstant(_Parse):
|
|
305
|
+
def matches(self, node: ast.AST) -> bool:
|
|
306
|
+
# fmt: off
|
|
307
|
+
return (
|
|
308
|
+
isinstance(node, ast.Constant)
|
|
309
|
+
and isinstance(node.value, (bool, int, float, str))
|
|
310
|
+
) or (
|
|
311
|
+
isinstance(node, ast.UnaryOp)
|
|
312
|
+
and isinstance(node.op, ast.USub)
|
|
313
|
+
and isinstance(node.operand, ast.Constant)
|
|
314
|
+
and isinstance(node.operand.value, (int, float))
|
|
315
|
+
)
|
|
316
|
+
# fmt: on
|
|
317
|
+
|
|
318
|
+
# noinspection PyTypeChecker
|
|
319
|
+
def transform(self, node: ast.AST) -> Tuple[Optional[tree.Node], Optional[Error]]:
|
|
320
|
+
# fmt: off
|
|
321
|
+
assert (
|
|
322
|
+
isinstance(node, ast.Constant)
|
|
323
|
+
and isinstance(node.value, (bool, int, float, str))
|
|
324
|
+
) or (
|
|
325
|
+
isinstance(node, ast.UnaryOp)
|
|
326
|
+
and isinstance(node.op, ast.USub)
|
|
327
|
+
and isinstance(node.operand, ast.Constant)
|
|
328
|
+
and isinstance(node.operand.value, (int, float))
|
|
329
|
+
)
|
|
330
|
+
# fmt: on
|
|
331
|
+
|
|
332
|
+
if isinstance(node, ast.Constant):
|
|
333
|
+
assert isinstance(node.value, (bool, int, float, str))
|
|
334
|
+
return tree.Constant(value=node.value, original_node=node), None
|
|
335
|
+
|
|
336
|
+
elif isinstance(node, ast.UnaryOp):
|
|
337
|
+
assert (
|
|
338
|
+
isinstance(node.op, ast.USub)
|
|
339
|
+
and isinstance(node.operand, ast.Constant)
|
|
340
|
+
and isinstance(node.operand.value, (int, float))
|
|
341
|
+
)
|
|
342
|
+
|
|
343
|
+
return tree.Constant(value=-node.operand.value, original_node=node), None
|
|
344
|
+
|
|
345
|
+
else:
|
|
346
|
+
raise AssertionError(
|
|
347
|
+
"Unexpected execution path with node: {ast.dump(node)}"
|
|
348
|
+
)
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
class _ParseImplication(_Parse):
|
|
352
|
+
# noinspection PyUnresolvedReferences
|
|
353
|
+
def matches(self, node: ast.AST) -> bool:
|
|
354
|
+
return (
|
|
355
|
+
isinstance(node, ast.BoolOp)
|
|
356
|
+
and isinstance(node.op, ast.Or)
|
|
357
|
+
and len(node.values) == 2
|
|
358
|
+
and isinstance(node.values[0], ast.UnaryOp)
|
|
359
|
+
and isinstance(node.values[0].op, ast.Not)
|
|
360
|
+
)
|
|
361
|
+
|
|
362
|
+
# noinspection PyUnresolvedReferences,PyTypeChecker
|
|
363
|
+
def transform(self, node: ast.AST) -> Tuple[Optional[tree.Node], Optional[Error]]:
|
|
364
|
+
assert (
|
|
365
|
+
isinstance(node, ast.BoolOp)
|
|
366
|
+
and isinstance(node.op, ast.Or)
|
|
367
|
+
and len(node.values) == 2
|
|
368
|
+
and isinstance(node.values[0], ast.UnaryOp)
|
|
369
|
+
and isinstance(node.values[0].op, ast.Not)
|
|
370
|
+
)
|
|
371
|
+
|
|
372
|
+
antecedent, error = ast_node_to_our_node(node.values[0].operand)
|
|
373
|
+
if error is not None:
|
|
374
|
+
return None, error
|
|
375
|
+
|
|
376
|
+
assert isinstance(antecedent, tree.Expression), f"{antecedent=}"
|
|
377
|
+
|
|
378
|
+
consequent, error = ast_node_to_our_node(node.values[1])
|
|
379
|
+
if error is not None:
|
|
380
|
+
return None, error
|
|
381
|
+
|
|
382
|
+
assert isinstance(consequent, tree.Expression), f"{consequent=}"
|
|
383
|
+
|
|
384
|
+
return (
|
|
385
|
+
tree.Implication(
|
|
386
|
+
antecedent=antecedent, consequent=consequent, original_node=node
|
|
387
|
+
),
|
|
388
|
+
None,
|
|
389
|
+
)
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
class _ParseMember(_Parse):
|
|
393
|
+
def matches(self, node: ast.AST) -> bool:
|
|
394
|
+
return isinstance(node, ast.Attribute)
|
|
395
|
+
|
|
396
|
+
# noinspection PyTypeChecker
|
|
397
|
+
def transform(self, node: ast.AST) -> Tuple[Optional[tree.Node], Optional[Error]]:
|
|
398
|
+
assert isinstance(node, ast.Attribute)
|
|
399
|
+
|
|
400
|
+
instance, error = ast_node_to_our_node(node.value)
|
|
401
|
+
if error is not None:
|
|
402
|
+
return None, error
|
|
403
|
+
|
|
404
|
+
assert isinstance(instance, tree.Expression), f"{instance=}"
|
|
405
|
+
|
|
406
|
+
return (
|
|
407
|
+
tree.Member(
|
|
408
|
+
instance=instance, name=Identifier(node.attr), original_node=node
|
|
409
|
+
),
|
|
410
|
+
None,
|
|
411
|
+
)
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
class _ParseIndex(_Parse):
|
|
415
|
+
def matches(self, node: ast.AST) -> bool:
|
|
416
|
+
return isinstance(node, ast.Subscript)
|
|
417
|
+
|
|
418
|
+
# noinspection PyTypeChecker
|
|
419
|
+
def transform(self, node: ast.AST) -> Tuple[Optional[tree.Node], Optional[Error]]:
|
|
420
|
+
assert isinstance(node, ast.Subscript)
|
|
421
|
+
|
|
422
|
+
collection, error = ast_node_to_our_node(node.value)
|
|
423
|
+
if error is not None:
|
|
424
|
+
return None, error
|
|
425
|
+
|
|
426
|
+
# NOTE (mristin, 2022-07-11):
|
|
427
|
+
# There were breaking changes between Python 3.8 and 3.9 in ``ast`` module.
|
|
428
|
+
# Relevant to this particular piece of parsing logic is the deprecation of
|
|
429
|
+
# ``ast.Index``.
|
|
430
|
+
#
|
|
431
|
+
# Hence, we need to switch on Python version and get the underlying slice value
|
|
432
|
+
# explicitly.
|
|
433
|
+
#
|
|
434
|
+
# See deprecation notes just at the end of:
|
|
435
|
+
# https://docs.python.org/3/library/ast.html#ast.AST
|
|
436
|
+
|
|
437
|
+
if sys.version_info < (3, 9):
|
|
438
|
+
if not isinstance(node.slice, ast.Index):
|
|
439
|
+
return None, Error(
|
|
440
|
+
node.slice,
|
|
441
|
+
f"We expect only indices in index access, "
|
|
442
|
+
f"but got: {ast.dump(node.slice)}",
|
|
443
|
+
)
|
|
444
|
+
|
|
445
|
+
index, error = ast_node_to_our_node(node.slice.value)
|
|
446
|
+
if error is not None:
|
|
447
|
+
return None, error
|
|
448
|
+
else:
|
|
449
|
+
index, error = ast_node_to_our_node(node.slice)
|
|
450
|
+
if error is not None:
|
|
451
|
+
return None, error
|
|
452
|
+
|
|
453
|
+
assert isinstance(collection, tree.Expression), f"{collection=}"
|
|
454
|
+
assert isinstance(index, tree.Expression), f"{index=}"
|
|
455
|
+
|
|
456
|
+
return tree.Index(collection=collection, index=index, original_node=node), None
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
class _ParseName(_Parse):
|
|
460
|
+
def matches(self, node: ast.AST) -> bool:
|
|
461
|
+
return isinstance(node, ast.Name)
|
|
462
|
+
|
|
463
|
+
# noinspection PyTypeChecker
|
|
464
|
+
def transform(self, node: ast.AST) -> Tuple[Optional[tree.Node], Optional[Error]]:
|
|
465
|
+
assert isinstance(node, ast.Name)
|
|
466
|
+
|
|
467
|
+
return tree.Name(identifier=Identifier(node.id), original_node=node), None
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
class _ParseIsNoneOrIsNotNone(_Parse):
|
|
471
|
+
# noinspection PyUnresolvedReferences
|
|
472
|
+
def matches(self, node: ast.AST) -> bool:
|
|
473
|
+
return (
|
|
474
|
+
isinstance(node, ast.Compare)
|
|
475
|
+
and len(node.ops) == 1
|
|
476
|
+
and isinstance(node.ops[0], (ast.Is, ast.IsNot))
|
|
477
|
+
and len(node.comparators) == 1
|
|
478
|
+
and isinstance(node.comparators[0], ast.Constant)
|
|
479
|
+
and node.comparators[0].value is None
|
|
480
|
+
)
|
|
481
|
+
|
|
482
|
+
# noinspection PyUnresolvedReferences,PyTypeChecker
|
|
483
|
+
def transform(self, node: ast.AST) -> Tuple[Optional[tree.Node], Optional[Error]]:
|
|
484
|
+
assert (
|
|
485
|
+
isinstance(node, ast.Compare)
|
|
486
|
+
and len(node.ops) == 1
|
|
487
|
+
and isinstance(node.ops[0], (ast.Is, ast.IsNot))
|
|
488
|
+
and len(node.comparators) == 1
|
|
489
|
+
and isinstance(node.comparators[0], ast.Constant)
|
|
490
|
+
and node.comparators[0].value is None
|
|
491
|
+
)
|
|
492
|
+
|
|
493
|
+
value, error = ast_node_to_our_node(node.left)
|
|
494
|
+
if error is not None:
|
|
495
|
+
return None, error
|
|
496
|
+
|
|
497
|
+
assert value is not None
|
|
498
|
+
assert isinstance(value, tree.Expression), f"{value=}"
|
|
499
|
+
|
|
500
|
+
if isinstance(node.ops[0], ast.Is):
|
|
501
|
+
return tree.IsNone(value=value, original_node=node), None
|
|
502
|
+
elif isinstance(node.ops[0], ast.IsNot):
|
|
503
|
+
return tree.IsNotNone(value=value, original_node=node), None
|
|
504
|
+
else:
|
|
505
|
+
raise AssertionError(f"Unexpected: {node.ops[0]=}")
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
class _ParseNot(_Parse):
|
|
509
|
+
# noinspection PyUnresolvedReferences
|
|
510
|
+
def matches(self, node: ast.AST) -> bool:
|
|
511
|
+
return isinstance(node, ast.UnaryOp) and isinstance(node.op, ast.Not)
|
|
512
|
+
|
|
513
|
+
# noinspection PyUnresolvedReferences,PyTypeChecker
|
|
514
|
+
def transform(self, node: ast.AST) -> Tuple[Optional[tree.Node], Optional[Error]]:
|
|
515
|
+
assert isinstance(node, ast.UnaryOp) and isinstance(node.op, ast.Not)
|
|
516
|
+
|
|
517
|
+
operand, error = ast_node_to_our_node(node.operand)
|
|
518
|
+
if error is not None:
|
|
519
|
+
return None, error
|
|
520
|
+
|
|
521
|
+
assert operand is not None
|
|
522
|
+
assert isinstance(operand, tree.Expression), f"{operand=}"
|
|
523
|
+
|
|
524
|
+
return tree.Not(operand=operand, original_node=node), None
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
class _ParseAndOrOr(_Parse):
|
|
528
|
+
def matches(self, node: ast.AST) -> bool:
|
|
529
|
+
return isinstance(node, ast.BoolOp) and isinstance(node.op, (ast.And, ast.Or))
|
|
530
|
+
|
|
531
|
+
# noinspection PyTypeChecker
|
|
532
|
+
def transform(self, node: ast.AST) -> Tuple[Optional[tree.Node], Optional[Error]]:
|
|
533
|
+
assert isinstance(node, ast.BoolOp) and isinstance(node.op, (ast.And, ast.Or))
|
|
534
|
+
|
|
535
|
+
values = [] # type: List[tree.Expression]
|
|
536
|
+
for value_node in node.values:
|
|
537
|
+
value, error = ast_node_to_our_node(value_node)
|
|
538
|
+
if error is not None:
|
|
539
|
+
return None, error
|
|
540
|
+
|
|
541
|
+
assert value is not None
|
|
542
|
+
assert isinstance(value, tree.Expression), f"{value=}"
|
|
543
|
+
|
|
544
|
+
values.append(value)
|
|
545
|
+
|
|
546
|
+
if isinstance(node.op, ast.And):
|
|
547
|
+
return tree.And(values=values, original_node=node), None
|
|
548
|
+
elif isinstance(node.op, ast.Or):
|
|
549
|
+
return tree.Or(values=values, original_node=node), None
|
|
550
|
+
else:
|
|
551
|
+
raise AssertionError(f"Unexpected: {node.op=}")
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
class _ParseAddOrSub(_Parse):
|
|
555
|
+
def matches(self, node: ast.AST) -> bool:
|
|
556
|
+
return isinstance(node, ast.BinOp) and isinstance(node.op, (ast.Add, ast.Sub))
|
|
557
|
+
|
|
558
|
+
# noinspection PyTypeChecker
|
|
559
|
+
def transform(self, node: ast.AST) -> Tuple[Optional[tree.Node], Optional[Error]]:
|
|
560
|
+
assert isinstance(node, ast.BinOp) and isinstance(node.op, (ast.Add, ast.Sub))
|
|
561
|
+
|
|
562
|
+
left, error = ast_node_to_our_node(node.left)
|
|
563
|
+
if error is not None:
|
|
564
|
+
return None, error
|
|
565
|
+
|
|
566
|
+
assert isinstance(left, tree.Expression), f"{left=}"
|
|
567
|
+
|
|
568
|
+
right, error = ast_node_to_our_node(node.right)
|
|
569
|
+
if error is not None:
|
|
570
|
+
return None, error
|
|
571
|
+
|
|
572
|
+
assert isinstance(right, tree.Expression), f"{right=}"
|
|
573
|
+
|
|
574
|
+
if isinstance(node.op, ast.Add):
|
|
575
|
+
return tree.Add(left=left, right=right, original_node=node), None
|
|
576
|
+
elif isinstance(node.op, ast.Sub):
|
|
577
|
+
return tree.Sub(left=left, right=right, original_node=node), None
|
|
578
|
+
else:
|
|
579
|
+
raise AssertionError(f"Unexpected: {node.op=}")
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
class _ParseExpression(_Parse):
|
|
583
|
+
def matches(self, node: ast.AST) -> bool:
|
|
584
|
+
return isinstance(node, ast.Expr)
|
|
585
|
+
|
|
586
|
+
# noinspection PyTypeChecker
|
|
587
|
+
def transform(self, node: ast.AST) -> Tuple[Optional[tree.Node], Optional[Error]]:
|
|
588
|
+
assert isinstance(node, ast.Expr)
|
|
589
|
+
|
|
590
|
+
value, error = ast_node_to_our_node(node.value)
|
|
591
|
+
if error is not None:
|
|
592
|
+
return None, error
|
|
593
|
+
|
|
594
|
+
assert value is not None
|
|
595
|
+
|
|
596
|
+
return value, None
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
class _ParseJoinedStr(_Parse):
|
|
600
|
+
def matches(self, node: ast.AST) -> bool:
|
|
601
|
+
return isinstance(node, ast.JoinedStr)
|
|
602
|
+
|
|
603
|
+
# noinspection PyTypeChecker
|
|
604
|
+
def transform(self, node: ast.AST) -> Tuple[Optional[tree.Node], Optional[Error]]:
|
|
605
|
+
assert isinstance(node, ast.JoinedStr)
|
|
606
|
+
|
|
607
|
+
values = [] # type: List[Union[str, tree.FormattedValue]]
|
|
608
|
+
|
|
609
|
+
assert isinstance(node, ast.JoinedStr)
|
|
610
|
+
for value_node in node.values:
|
|
611
|
+
if isinstance(value_node, ast.Constant):
|
|
612
|
+
if not isinstance(value_node.value, str):
|
|
613
|
+
return None, Error(
|
|
614
|
+
value_node,
|
|
615
|
+
"Unexpected non-string constant in the joined string",
|
|
616
|
+
)
|
|
617
|
+
|
|
618
|
+
values.append(value_node.value)
|
|
619
|
+
|
|
620
|
+
elif isinstance(value_node, ast.FormattedValue):
|
|
621
|
+
if value_node.conversion != -1:
|
|
622
|
+
return None, Error(
|
|
623
|
+
value_node,
|
|
624
|
+
f"We do not support any conversions at the moment. "
|
|
625
|
+
f"Expected -1, but got conversion: {value_node.conversion}",
|
|
626
|
+
)
|
|
627
|
+
|
|
628
|
+
if value_node.format_spec is not None:
|
|
629
|
+
return None, Error(
|
|
630
|
+
value_node,
|
|
631
|
+
f"We do not support any format spec at the moment. "
|
|
632
|
+
f"Expected None, but got format spec: {value_node.format_spec}",
|
|
633
|
+
)
|
|
634
|
+
|
|
635
|
+
# noinspection PyTypeChecker
|
|
636
|
+
value, error = ast_node_to_our_node(node=value_node.value)
|
|
637
|
+
if error is not None:
|
|
638
|
+
return None, error
|
|
639
|
+
|
|
640
|
+
assert value is not None
|
|
641
|
+
|
|
642
|
+
assert isinstance(value, tree.Expression)
|
|
643
|
+
values.append(
|
|
644
|
+
tree.FormattedValue(value=value, original_node=value_node)
|
|
645
|
+
)
|
|
646
|
+
|
|
647
|
+
elif isinstance(value_node, ast.expr):
|
|
648
|
+
return None, Error(
|
|
649
|
+
value_node,
|
|
650
|
+
f"We do not know how to parse the Python ast.expr "
|
|
651
|
+
f"as part of the JoinedStr.values: {ast.dump(value_node)}; "
|
|
652
|
+
f"please notify the developers.",
|
|
653
|
+
)
|
|
654
|
+
else:
|
|
655
|
+
assert_never(value_node)
|
|
656
|
+
|
|
657
|
+
return tree.JoinedStr(values=values, original_node=node), None
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
class _ParseAssignment(_Parse):
|
|
661
|
+
def matches(self, node: ast.AST) -> bool:
|
|
662
|
+
return isinstance(node, ast.Assign) and len(node.targets) == 1
|
|
663
|
+
|
|
664
|
+
# noinspection PyTypeChecker
|
|
665
|
+
def transform(self, node: ast.AST) -> Tuple[Optional[tree.Node], Optional[Error]]:
|
|
666
|
+
assert isinstance(node, ast.Assign) and len(node.targets) == 1
|
|
667
|
+
|
|
668
|
+
target, error = ast_node_to_our_node(node.targets[0])
|
|
669
|
+
if error is not None:
|
|
670
|
+
return None, error
|
|
671
|
+
|
|
672
|
+
assert target is not None
|
|
673
|
+
assert isinstance(target, tree.Expression), f"{target=}"
|
|
674
|
+
|
|
675
|
+
value, error = ast_node_to_our_node(node.value)
|
|
676
|
+
if error is not None:
|
|
677
|
+
return None, error
|
|
678
|
+
|
|
679
|
+
assert value is not None
|
|
680
|
+
assert isinstance(value, tree.Expression), f"{value=}"
|
|
681
|
+
|
|
682
|
+
return (
|
|
683
|
+
tree.Assignment(target=target, value=value, original_node=node),
|
|
684
|
+
None,
|
|
685
|
+
)
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
class _ParseReturn(_Parse):
|
|
689
|
+
def matches(self, node: ast.AST) -> bool:
|
|
690
|
+
return isinstance(node, ast.Return)
|
|
691
|
+
|
|
692
|
+
# noinspection PyTypeChecker
|
|
693
|
+
def transform(self, node: ast.AST) -> Tuple[Optional[tree.Node], Optional[Error]]:
|
|
694
|
+
assert isinstance(node, ast.Return)
|
|
695
|
+
|
|
696
|
+
if node.value is None:
|
|
697
|
+
return tree.Return(value=None, original_node=node), None
|
|
698
|
+
|
|
699
|
+
value, error = ast_node_to_our_node(node.value)
|
|
700
|
+
if error is not None:
|
|
701
|
+
return None, error
|
|
702
|
+
|
|
703
|
+
assert value is not None
|
|
704
|
+
assert isinstance(value, tree.Expression), f"{value=}"
|
|
705
|
+
|
|
706
|
+
return tree.Return(value=value, original_node=node), None
|
|
707
|
+
|
|
708
|
+
|
|
709
|
+
_CHAIN_OF_RULES = [
|
|
710
|
+
_ParseComparison(),
|
|
711
|
+
_ParseIsIn(),
|
|
712
|
+
_ParseAnyOrAll(),
|
|
713
|
+
_ParseCall(),
|
|
714
|
+
_ParseConstant(),
|
|
715
|
+
_ParseImplication(),
|
|
716
|
+
_ParseMember(),
|
|
717
|
+
_ParseIndex(),
|
|
718
|
+
_ParseName(),
|
|
719
|
+
_ParseIsNoneOrIsNotNone(),
|
|
720
|
+
_ParseNot(),
|
|
721
|
+
_ParseAndOrOr(),
|
|
722
|
+
_ParseAddOrSub(),
|
|
723
|
+
_ParseExpression(),
|
|
724
|
+
_ParseJoinedStr(),
|
|
725
|
+
_ParseAssignment(),
|
|
726
|
+
_ParseReturn(),
|
|
727
|
+
] # type: Sequence[_Parse]
|
|
728
|
+
|
|
729
|
+
|
|
730
|
+
def _assert_chains_follow_file_structure() -> None:
|
|
731
|
+
"""
|
|
732
|
+
Make sure that the chains of command follow the structure of the module.
|
|
733
|
+
|
|
734
|
+
This check is necessary so that the rules can be directly followed in the source
|
|
735
|
+
code. Otherwise, it is very hard to follow the chain if it differs from the order
|
|
736
|
+
in which the classes are defined.
|
|
737
|
+
"""
|
|
738
|
+
this_file = pathlib.Path(os.path.realpath(__file__))
|
|
739
|
+
|
|
740
|
+
# If we are in an environment where we can not load the file, skip this assertion.
|
|
741
|
+
# This is the case, for example, in a pyinstaller package.
|
|
742
|
+
if not this_file.exists():
|
|
743
|
+
return
|
|
744
|
+
|
|
745
|
+
root = ast.parse(
|
|
746
|
+
source=this_file.read_text(encoding="utf-8"), filename=str(this_file)
|
|
747
|
+
)
|
|
748
|
+
assert isinstance(root, ast.Module)
|
|
749
|
+
|
|
750
|
+
expected_parse_names = [
|
|
751
|
+
stmt.name
|
|
752
|
+
for stmt in root.body
|
|
753
|
+
if (
|
|
754
|
+
isinstance(stmt, ast.ClassDef)
|
|
755
|
+
and stmt.name.startswith("_Parse")
|
|
756
|
+
and stmt.name != "_Parse"
|
|
757
|
+
)
|
|
758
|
+
] # type: List[str]
|
|
759
|
+
|
|
760
|
+
parse_names_in_chain = [parse.__class__.__name__ for parse in _CHAIN_OF_RULES]
|
|
761
|
+
|
|
762
|
+
assert (
|
|
763
|
+
expected_parse_names == parse_names_in_chain
|
|
764
|
+
), f"{expected_parse_names=} != {parse_names_in_chain=}"
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
_assert_chains_follow_file_structure()
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
@ensure(lambda result: (result[0] is not None) ^ (result[1] is not None))
|
|
771
|
+
def ast_node_to_our_node(node: ast.AST) -> Tuple[Optional[tree.Node], Optional[Error]]:
|
|
772
|
+
"""
|
|
773
|
+
Parse the Python AST node into our custom AST.
|
|
774
|
+
|
|
775
|
+
For example, this function is used to parse contract conditions into
|
|
776
|
+
our representation which is later easier for processing.
|
|
777
|
+
"""
|
|
778
|
+
for parse_rule in _CHAIN_OF_RULES:
|
|
779
|
+
# NOTE(mristin, 2021-10-08):
|
|
780
|
+
# Please leave the variables as they are to facilitate the eventual debugging
|
|
781
|
+
# even though a more succinct code structure lures you.
|
|
782
|
+
|
|
783
|
+
matches = parse_rule.matches(node)
|
|
784
|
+
if matches:
|
|
785
|
+
result, error = parse_rule.transform(node)
|
|
786
|
+
|
|
787
|
+
if error is not None:
|
|
788
|
+
return None, error
|
|
789
|
+
|
|
790
|
+
return result, None
|
|
791
|
+
|
|
792
|
+
return None, Error(
|
|
793
|
+
node,
|
|
794
|
+
f"The code matched no pattern for transpilation "
|
|
795
|
+
f"at the parse stage: {ast.dump(node)}",
|
|
796
|
+
)
|