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.
Files changed (604) hide show
  1. aas_core_codegen/__init__.py +6 -0
  2. aas_core_codegen/__main__.py +8 -0
  3. aas_core_codegen/common.py +500 -0
  4. aas_core_codegen/cpp/__init__.py +1 -0
  5. aas_core_codegen/cpp/aas_common/__init__.py +6 -0
  6. aas_core_codegen/cpp/aas_common/_generate.py +713 -0
  7. aas_core_codegen/cpp/common.py +681 -0
  8. aas_core_codegen/cpp/constants/__init__.py +6 -0
  9. aas_core_codegen/cpp/constants/_generate.py +568 -0
  10. aas_core_codegen/cpp/description.py +654 -0
  11. aas_core_codegen/cpp/enhancing/__init__.py +4 -0
  12. aas_core_codegen/cpp/enhancing/_generate.py +993 -0
  13. aas_core_codegen/cpp/iteration/__init__.py +6 -0
  14. aas_core_codegen/cpp/iteration/_generate.py +2332 -0
  15. aas_core_codegen/cpp/jsonization/__init__.py +6 -0
  16. aas_core_codegen/cpp/jsonization/_generate.py +2619 -0
  17. aas_core_codegen/cpp/main.py +694 -0
  18. aas_core_codegen/cpp/naming.py +170 -0
  19. aas_core_codegen/cpp/optionaling.py +557 -0
  20. aas_core_codegen/cpp/pattern/__init__.py +6 -0
  21. aas_core_codegen/cpp/pattern/_generate.py +508 -0
  22. aas_core_codegen/cpp/revm/__init__.py +6 -0
  23. aas_core_codegen/cpp/revm/_generate.py +1149 -0
  24. aas_core_codegen/cpp/stringification/__init__.py +5 -0
  25. aas_core_codegen/cpp/stringification/_generate.py +955 -0
  26. aas_core_codegen/cpp/structure/__init__.py +7 -0
  27. aas_core_codegen/cpp/structure/_generate.py +1503 -0
  28. aas_core_codegen/cpp/transpilation.py +1383 -0
  29. aas_core_codegen/cpp/unrolling.py +159 -0
  30. aas_core_codegen/cpp/verification/__init__.py +6 -0
  31. aas_core_codegen/cpp/verification/_generate.py +3073 -0
  32. aas_core_codegen/cpp/visitation/__init__.py +6 -0
  33. aas_core_codegen/cpp/visitation/_generate.py +521 -0
  34. aas_core_codegen/cpp/wstringification/__init__.py +5 -0
  35. aas_core_codegen/cpp/wstringification/_generate.py +586 -0
  36. aas_core_codegen/cpp/xmlization/__init__.py +6 -0
  37. aas_core_codegen/cpp/xmlization/_generate.py +5373 -0
  38. aas_core_codegen/cpp/yielding.py +201 -0
  39. aas_core_codegen/csharp/__init__.py +1 -0
  40. aas_core_codegen/csharp/common.py +224 -0
  41. aas_core_codegen/csharp/constants/__init__.py +5 -0
  42. aas_core_codegen/csharp/constants/_generate.py +409 -0
  43. aas_core_codegen/csharp/copying/__init__.py +4 -0
  44. aas_core_codegen/csharp/copying/_generate.py +498 -0
  45. aas_core_codegen/csharp/description.py +1103 -0
  46. aas_core_codegen/csharp/enhancing/__init__.py +4 -0
  47. aas_core_codegen/csharp/enhancing/_generate.py +667 -0
  48. aas_core_codegen/csharp/jsonization/__init__.py +4 -0
  49. aas_core_codegen/csharp/jsonization/_generate.py +1630 -0
  50. aas_core_codegen/csharp/main.py +421 -0
  51. aas_core_codegen/csharp/naming.py +157 -0
  52. aas_core_codegen/csharp/reporting/__init__.py +4 -0
  53. aas_core_codegen/csharp/reporting/_generate.py +266 -0
  54. aas_core_codegen/csharp/stringification/__init__.py +4 -0
  55. aas_core_codegen/csharp/stringification/_generate.py +243 -0
  56. aas_core_codegen/csharp/structure/__init__.py +6 -0
  57. aas_core_codegen/csharp/structure/_generate.py +1341 -0
  58. aas_core_codegen/csharp/transpilation.py +990 -0
  59. aas_core_codegen/csharp/unrolling.py +211 -0
  60. aas_core_codegen/csharp/verification/__init__.py +6 -0
  61. aas_core_codegen/csharp/verification/_generate.py +1457 -0
  62. aas_core_codegen/csharp/visitation/__init__.py +5 -0
  63. aas_core_codegen/csharp/visitation/_generate.py +579 -0
  64. aas_core_codegen/csharp/xmlization/__init__.py +4 -0
  65. aas_core_codegen/csharp/xmlization/_generate.py +1980 -0
  66. aas_core_codegen/golang/__init__.py +1 -0
  67. aas_core_codegen/golang/aas_common/__init__.py +4 -0
  68. aas_core_codegen/golang/aas_common/_generate.py +152 -0
  69. aas_core_codegen/golang/common.py +303 -0
  70. aas_core_codegen/golang/constants/__init__.py +5 -0
  71. aas_core_codegen/golang/constants/_generate.py +339 -0
  72. aas_core_codegen/golang/description.py +501 -0
  73. aas_core_codegen/golang/enhancing/__init__.py +4 -0
  74. aas_core_codegen/golang/enhancing/_generate.py +527 -0
  75. aas_core_codegen/golang/jsonization/__init__.py +4 -0
  76. aas_core_codegen/golang/jsonization/_generate.py +1740 -0
  77. aas_core_codegen/golang/main.py +368 -0
  78. aas_core_codegen/golang/naming.py +412 -0
  79. aas_core_codegen/golang/pointering.py +631 -0
  80. aas_core_codegen/golang/reporting/__init__.py +4 -0
  81. aas_core_codegen/golang/reporting/_generate.py +218 -0
  82. aas_core_codegen/golang/stringification/__init__.py +4 -0
  83. aas_core_codegen/golang/stringification/_generate.py +394 -0
  84. aas_core_codegen/golang/structure/__init__.py +6 -0
  85. aas_core_codegen/golang/structure/_generate.py +1493 -0
  86. aas_core_codegen/golang/transpilation.py +1191 -0
  87. aas_core_codegen/golang/unrolling.py +159 -0
  88. aas_core_codegen/golang/verification/__init__.py +6 -0
  89. aas_core_codegen/golang/verification/_generate.py +1513 -0
  90. aas_core_codegen/golang/xmlization/__init__.py +4 -0
  91. aas_core_codegen/golang/xmlization/_generate.py +2507 -0
  92. aas_core_codegen/infer_for_schema/__init__.py +21 -0
  93. aas_core_codegen/infer_for_schema/_inline.py +693 -0
  94. aas_core_codegen/infer_for_schema/_len.py +527 -0
  95. aas_core_codegen/infer_for_schema/_pattern.py +311 -0
  96. aas_core_codegen/infer_for_schema/_set.py +394 -0
  97. aas_core_codegen/infer_for_schema/_stringify.py +201 -0
  98. aas_core_codegen/infer_for_schema/_types.py +135 -0
  99. aas_core_codegen/infer_for_schema/match.py +122 -0
  100. aas_core_codegen/intermediate/__init__.py +78 -0
  101. aas_core_codegen/intermediate/_hierarchy.py +397 -0
  102. aas_core_codegen/intermediate/_stringify.py +989 -0
  103. aas_core_codegen/intermediate/_translate.py +5128 -0
  104. aas_core_codegen/intermediate/_types.py +2901 -0
  105. aas_core_codegen/intermediate/construction.py +750 -0
  106. aas_core_codegen/intermediate/doc.py +344 -0
  107. aas_core_codegen/intermediate/pattern_verification.py +428 -0
  108. aas_core_codegen/intermediate/revm.py +985 -0
  109. aas_core_codegen/intermediate/type_inference.py +2266 -0
  110. aas_core_codegen/java/__init__.py +1 -0
  111. aas_core_codegen/java/common.py +197 -0
  112. aas_core_codegen/java/constants/__init__.py +5 -0
  113. aas_core_codegen/java/constants/_generate.py +334 -0
  114. aas_core_codegen/java/copying/__init__.py +4 -0
  115. aas_core_codegen/java/copying/_generate.py +502 -0
  116. aas_core_codegen/java/description.py +774 -0
  117. aas_core_codegen/java/enhancing/__init__.py +4 -0
  118. aas_core_codegen/java/enhancing/_generate.py +820 -0
  119. aas_core_codegen/java/generation/__init__.py +5 -0
  120. aas_core_codegen/java/generation/_generate.py +285 -0
  121. aas_core_codegen/java/jsonization/__init__.py +4 -0
  122. aas_core_codegen/java/jsonization/_generate.py +1472 -0
  123. aas_core_codegen/java/main.py +438 -0
  124. aas_core_codegen/java/naming.py +187 -0
  125. aas_core_codegen/java/optional.py +514 -0
  126. aas_core_codegen/java/reporting/__init__.py +4 -0
  127. aas_core_codegen/java/reporting/_generate.py +248 -0
  128. aas_core_codegen/java/stringification/__init__.py +4 -0
  129. aas_core_codegen/java/stringification/_generate.py +212 -0
  130. aas_core_codegen/java/structure/__init__.py +6 -0
  131. aas_core_codegen/java/structure/_generate.py +1767 -0
  132. aas_core_codegen/java/transpilation.py +1111 -0
  133. aas_core_codegen/java/verification/__init__.py +6 -0
  134. aas_core_codegen/java/verification/_generate.py +1536 -0
  135. aas_core_codegen/java/visitation/__init__.py +5 -0
  136. aas_core_codegen/java/visitation/_generate.py +689 -0
  137. aas_core_codegen/java/xmlization/__init__.py +4 -0
  138. aas_core_codegen/java/xmlization/_generate.py +2274 -0
  139. aas_core_codegen/jsonld/__init__.py +1 -0
  140. aas_core_codegen/jsonld/main.py +455 -0
  141. aas_core_codegen/jsonschema/__init__.py +1 -0
  142. aas_core_codegen/jsonschema/main.py +982 -0
  143. aas_core_codegen/main.py +245 -0
  144. aas_core_codegen/naming.py +133 -0
  145. aas_core_codegen/opcua/__init__.py +1 -0
  146. aas_core_codegen/opcua/main.py +1525 -0
  147. aas_core_codegen/opcua/naming.py +126 -0
  148. aas_core_codegen/parse/__init__.py +46 -0
  149. aas_core_codegen/parse/_rules.py +796 -0
  150. aas_core_codegen/parse/_stringify.py +532 -0
  151. aas_core_codegen/parse/_translate.py +3940 -0
  152. aas_core_codegen/parse/_types.py +973 -0
  153. aas_core_codegen/parse/retree/__init__.py +46 -0
  154. aas_core_codegen/parse/retree/_fix.py +434 -0
  155. aas_core_codegen/parse/retree/_parse.py +1143 -0
  156. aas_core_codegen/parse/retree/_render.py +298 -0
  157. aas_core_codegen/parse/retree/_stringify.py +199 -0
  158. aas_core_codegen/parse/retree/_types.py +362 -0
  159. aas_core_codegen/parse/retree/_visitor.py +70 -0
  160. aas_core_codegen/parse/tree.py +1303 -0
  161. aas_core_codegen/protobuf/__init__.py +1 -0
  162. aas_core_codegen/protobuf/common.py +225 -0
  163. aas_core_codegen/protobuf/description.py +1102 -0
  164. aas_core_codegen/protobuf/main.py +115 -0
  165. aas_core_codegen/protobuf/naming.py +143 -0
  166. aas_core_codegen/protobuf/structure/__init__.py +6 -0
  167. aas_core_codegen/protobuf/structure/_generate.py +502 -0
  168. aas_core_codegen/py.typed +1 -0
  169. aas_core_codegen/python/__init__.py +1 -0
  170. aas_core_codegen/python/aas_common/__init__.py +4 -0
  171. aas_core_codegen/python/aas_common/_generate.py +63 -0
  172. aas_core_codegen/python/common.py +406 -0
  173. aas_core_codegen/python/constants/__init__.py +5 -0
  174. aas_core_codegen/python/constants/_generate.py +377 -0
  175. aas_core_codegen/python/description.py +508 -0
  176. aas_core_codegen/python/jsonization/__init__.py +4 -0
  177. aas_core_codegen/python/jsonization/_generate.py +1391 -0
  178. aas_core_codegen/python/main.py +323 -0
  179. aas_core_codegen/python/naming.py +255 -0
  180. aas_core_codegen/python/stringification/__init__.py +4 -0
  181. aas_core_codegen/python/stringification/_generate.py +129 -0
  182. aas_core_codegen/python/structure/__init__.py +6 -0
  183. aas_core_codegen/python/structure/_generate.py +1801 -0
  184. aas_core_codegen/python/transpilation.py +958 -0
  185. aas_core_codegen/python/unrolling.py +156 -0
  186. aas_core_codegen/python/verification/__init__.py +6 -0
  187. aas_core_codegen/python/verification/_generate.py +1471 -0
  188. aas_core_codegen/python/xmlization/__init__.py +4 -0
  189. aas_core_codegen/python/xmlization/_generate.py +3003 -0
  190. aas_core_codegen/python_protobuf/__init__.py +1 -0
  191. aas_core_codegen/python_protobuf/main.py +1424 -0
  192. aas_core_codegen/python_protobuf/naming.py +85 -0
  193. aas_core_codegen/rdf_shacl/__init__.py +1 -0
  194. aas_core_codegen/rdf_shacl/_description.py +351 -0
  195. aas_core_codegen/rdf_shacl/common.py +206 -0
  196. aas_core_codegen/rdf_shacl/main.py +114 -0
  197. aas_core_codegen/rdf_shacl/naming.py +145 -0
  198. aas_core_codegen/rdf_shacl/rdf.py +435 -0
  199. aas_core_codegen/rdf_shacl/shacl.py +453 -0
  200. aas_core_codegen/run.py +124 -0
  201. aas_core_codegen/smoke/__init__.py +1 -0
  202. aas_core_codegen/smoke/main.py +219 -0
  203. aas_core_codegen/specific_implementations.py +72 -0
  204. aas_core_codegen/stringify.py +333 -0
  205. aas_core_codegen/typescript/__init__.py +1 -0
  206. aas_core_codegen/typescript/aas_common/__init__.py +4 -0
  207. aas_core_codegen/typescript/aas_common/_generate.py +472 -0
  208. aas_core_codegen/typescript/common.py +340 -0
  209. aas_core_codegen/typescript/constants/__init__.py +5 -0
  210. aas_core_codegen/typescript/constants/_generate.py +347 -0
  211. aas_core_codegen/typescript/description.py +530 -0
  212. aas_core_codegen/typescript/jsonization/__init__.py +4 -0
  213. aas_core_codegen/typescript/jsonization/_generate.py +1510 -0
  214. aas_core_codegen/typescript/main.py +258 -0
  215. aas_core_codegen/typescript/naming.py +189 -0
  216. aas_core_codegen/typescript/stringification/__init__.py +4 -0
  217. aas_core_codegen/typescript/stringification/_generate.py +367 -0
  218. aas_core_codegen/typescript/structure/__init__.py +6 -0
  219. aas_core_codegen/typescript/structure/_generate.py +2500 -0
  220. aas_core_codegen/typescript/transpilation.py +1051 -0
  221. aas_core_codegen/typescript/unrolling.py +159 -0
  222. aas_core_codegen/typescript/verification/__init__.py +6 -0
  223. aas_core_codegen/typescript/verification/_generate.py +1578 -0
  224. aas_core_codegen/xsd/__init__.py +1 -0
  225. aas_core_codegen/xsd/main.py +1187 -0
  226. aas_core_codegen/xsd/naming.py +83 -0
  227. aas_core_codegen/yielding/__init__.py +1 -0
  228. aas_core_codegen/yielding/flow.py +139 -0
  229. aas_core_codegen/yielding/linear.py +754 -0
  230. aas_core_codegen-0.0.16.dist-info/METADATA +211 -0
  231. aas_core_codegen-0.0.16.dist-info/RECORD +604 -0
  232. aas_core_codegen-0.0.16.dist-info/WHEEL +5 -0
  233. aas_core_codegen-0.0.16.dist-info/entry_points.txt +3 -0
  234. aas_core_codegen-0.0.16.dist-info/licenses/AUTHORS +9 -0
  235. aas_core_codegen-0.0.16.dist-info/licenses/LICENSE +23 -0
  236. aas_core_codegen-0.0.16.dist-info/top_level.txt +2 -0
  237. dev/continuous_integration/__init__.py +1 -0
  238. dev/continuous_integration/check_help_in_readme.py +208 -0
  239. dev/continuous_integration/check_init_and_pyproject_consistent.py +154 -0
  240. dev/continuous_integration/precommit.py +400 -0
  241. dev/dev_scripts/__init__.py +1 -0
  242. dev/dev_scripts/compare_rendered_regexes_against_source_py.py +42 -0
  243. dev/dev_scripts/copy_to_aas_core3_cpp.py +100 -0
  244. dev/dev_scripts/copy_to_aas_core3_java.py +90 -0
  245. dev/dev_scripts/download_latest_aas_core_meta_v3.py +114 -0
  246. dev/dev_scripts/draw_bipartite_graph_based_on_lines.py +37 -0
  247. dev/dev_scripts/run_tests_with_rerecord.py +69 -0
  248. dev/dev_scripts/update_to_aas_core_meta.py +174 -0
  249. dev/integration_tests/input/jsonschema/boilerplate/main.py +55 -0
  250. dev/integration_tests/input/meta_model.py +38 -0
  251. dev/integration_tests/input/python/boilerplate/main.py +153 -0
  252. dev/integration_tests/main.py +258 -0
  253. dev/test_data/csharp/test_structure/concrete_class_with_descendants/meta_model.py +15 -0
  254. dev/test_data/csharp/test_structure/constructor_without_arguments/all_properties_optional/meta_model.py +9 -0
  255. dev/test_data/csharp/test_structure/constructor_without_arguments/no_properties/meta_model.py +6 -0
  256. dev/test_data/csharp/test_verification/builtin_functions/len/on_list/meta_model.py +20 -0
  257. dev/test_data/csharp/test_verification/builtin_functions/len/on_str/meta_model.py +16 -0
  258. dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/as_prefix/meta_model.py +8 -0
  259. dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/as_suffix/meta_model.py +8 -0
  260. dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/in_group_with_quantifier/meta_model.py +8 -0
  261. dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/in_the_middle/meta_model.py +8 -0
  262. dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/in_union/meta_model.py +8 -0
  263. dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/single_utf32_literal/meta_model.py +8 -0
  264. dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/with_quantifier_within_group/meta_model.py +8 -0
  265. dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/with_quantifier_without_group/meta_model.py +8 -0
  266. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/at_the_beginning/meta_model.py +8 -0
  267. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/at_the_end/meta_model.py +8 -0
  268. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/in_the_middle/meta_model.py +8 -0
  269. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/multiple/meta_model.py +8 -0
  270. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/single/meta_model.py +8 -0
  271. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/single_with_quantifier/meta_model.py +8 -0
  272. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/mixed_with_non_utf32/meta_model.py +8 -0
  273. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/more_than_two_high_surrogates/meta_model.py +8 -0
  274. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/multiple_utf32_ranges/meta_model.py +8 -0
  275. 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
  276. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/same_high_surrogate/meta_model.py +8 -0
  277. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/same_high_surrogate_with_quantifier/meta_model.py +8 -0
  278. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/two_high_surrogates/meta_model.py +8 -0
  279. dev/test_data/intermediate/expected/class/empty/meta_model.py +6 -0
  280. dev/test_data/intermediate/expected/class/implementation_specific_method/meta_model.py +8 -0
  281. dev/test_data/intermediate/expected/class/inheritance/meta_model.py +41 -0
  282. dev/test_data/intermediate/expected/class/methods_with_contracts/meta_model.py +15 -0
  283. dev/test_data/intermediate/expected/class/only_method_no_property/meta_model.py +7 -0
  284. dev/test_data/intermediate/expected/class/only_property_no_method/meta_model.py +9 -0
  285. dev/test_data/intermediate/expected/constant/constant_set/of_enum/meta_model.py +12 -0
  286. dev/test_data/intermediate/expected/constant/constant_set/of_str/meta_model.py +4 -0
  287. dev/test_data/intermediate/expected/constant/constant_set/with_description/meta_model.py +6 -0
  288. dev/test_data/intermediate/expected/constant/constant_set/with_superset_of/meta_model.py +14 -0
  289. dev/test_data/intermediate/expected/constant/constant_str/only_value/meta_model.py +7 -0
  290. dev/test_data/intermediate/expected/constant/constant_str/with_description/meta_model.py +5 -0
  291. dev/test_data/intermediate/expected/documentation/docstring_with_special_characters_in_literal/meta_model.py +20 -0
  292. dev/test_data/intermediate/expected/documentation/docstring_with_special_characters_outside_literal/meta_model.py +20 -0
  293. dev/test_data/intermediate/expected/empty/meta_model.py +2 -0
  294. dev/test_data/intermediate/expected/enumeration/meta_model.py +9 -0
  295. dev/test_data/intermediate/expected/interface/basic/meta_model.py +14 -0
  296. dev/test_data/intermediate/expected/interface/empty/meta_model.py +7 -0
  297. dev/test_data/intermediate/expected/interface/inheritance/meta_model.py +27 -0
  298. dev/test_data/intermediate/expected/interface/method_signature/meta_model.py +10 -0
  299. dev/test_data/intermediate/expected/interface/only_constructor/meta_model.py +11 -0
  300. dev/test_data/intermediate/expected/method/non_mutating/implementation_specific/meta_model.py +12 -0
  301. dev/test_data/intermediate/expected/method/non_mutating/understood/meta_model.py +11 -0
  302. dev/test_data/intermediate/expected/type_annotation/atomic/meta_model.py +9 -0
  303. dev/test_data/intermediate/expected/type_annotation/subscripted/class/meta_model.py +13 -0
  304. dev/test_data/intermediate/expected/type_annotation/subscripted/primitive/meta_model.py +9 -0
  305. dev/test_data/intermediate/unexpected/constant_set/of_enum/enumeration_literals_in_subset_outside_of_superset/meta_model.py +20 -0
  306. dev/test_data/intermediate/unexpected/constant_set/of_enum/invalid_literal/meta_model.py +11 -0
  307. dev/test_data/intermediate/unexpected/constant_set/of_enum/mismatch_between_enumeration_and_literal/meta_model.py +30 -0
  308. dev/test_data/intermediate/unexpected/constant_set/of_enum/mismatch_in_enumerations_between_subset_and_superset/meta_model.py +21 -0
  309. dev/test_data/intermediate/unexpected/constant_set/of_str/literals_in_subset_outside_of_superset/meta_model.py +18 -0
  310. dev/test_data/intermediate/unexpected/constant_set/of_str/mismatch_between_type_annotation_and_literals/meta_model.py +10 -0
  311. dev/test_data/intermediate/unexpected/constant_set/of_str/superset_and_subset_mismatch_in_type/meta_model.py +12 -0
  312. dev/test_data/intermediate/unexpected/constraints/dangling_constraintref/meta_model.py +18 -0
  313. dev/test_data/intermediate/unexpected/constraints/duplicate_constraints/meta_model.py +20 -0
  314. dev/test_data/intermediate/unexpected/documentation/unexpected_documentation_elements/meta_model.py +34 -0
  315. dev/test_data/intermediate/unexpected/invariant/class_invariant_uses_re/meta_model.py +10 -0
  316. dev/test_data/intermediate/unexpected/invariant/invariant_of_constrained_primitive_uses_re/meta_model.py +7 -0
  317. dev/test_data/intermediate/unexpected/invariant/unexpected_argument_count_to_len/meta_model.py +20 -0
  318. dev/test_data/intermediate/unexpected/invariant/unhandled_built_in_function/meta_model.py +16 -0
  319. dev/test_data/intermediate/unexpected/method_definitions/non_constant_default/meta_model.py +7 -0
  320. dev/test_data/intermediate/unexpected/optional_constructor_arguments_wo_default/default_non_none/meta_model.py +16 -0
  321. dev/test_data/intermediate/unexpected/optional_constructor_arguments_wo_default/no_default/meta_model.py +16 -0
  322. dev/test_data/intermediate/unexpected/properties_and_constructor_arguments_do_not_match/after_inheritance/meta_model.py +58 -0
  323. dev/test_data/intermediate/unexpected/properties_and_constructor_arguments_do_not_match/type_missmatch/meta_model.py +9 -0
  324. dev/test_data/intermediate/unexpected/properties_and_constructor_arguments_do_not_match/within_class/meta_model.py +22 -0
  325. dev/test_data/jsonschema/test_main/regression_when_len_constraints_on_inherited_property/meta_model.py +28 -0
  326. dev/test_data/opcua/test_main/abstract_and_concrete_classes/meta_model.py +37 -0
  327. dev/test_data/opcua/test_main/classes_with_invariants/meta_model.py +21 -0
  328. dev/test_data/opcua/test_main/concrete_class_with_descendant/meta_model.py +27 -0
  329. dev/test_data/opcua/test_main/concrete_class_with_enum/meta_model.py +21 -0
  330. dev/test_data/opcua/test_main/concrete_class_with_list_of_instances/meta_model.py +21 -0
  331. dev/test_data/opcua/test_main/concrete_class_with_primitive_attributes/meta_model.py +41 -0
  332. dev/test_data/opcua/test_main/concrete_class_with_string/meta_model.py +13 -0
  333. dev/test_data/opcua/test_main/constrained_primitive/meta_model.py +20 -0
  334. dev/test_data/opcua/test_main/multiple_inheritance/meta_model.py +25 -0
  335. dev/test_data/parse/expected/constant/constant_set/of_enum/meta_model.py +12 -0
  336. dev/test_data/parse/expected/constant/constant_set/of_str/meta_model.py +4 -0
  337. dev/test_data/parse/expected/constant/constant_set/with_description/meta_model.py +6 -0
  338. dev/test_data/parse/expected/constant/constant_set/with_superset_of/meta_model.py +14 -0
  339. dev/test_data/parse/expected/constant/constant_str/only_value/meta_model.py +7 -0
  340. dev/test_data/parse/expected/constant/constant_str/with_description/meta_model.py +5 -0
  341. dev/test_data/parse/expected/enum/ok/meta_model.py +15 -0
  342. dev/test_data/parse/expected/implementation_specific_class/properties_and_methods_in_implementation_specific_class/meta_model.py +17 -0
  343. dev/test_data/parse/expected/inheritance/basic/meta_model.py +11 -0
  344. dev/test_data/parse/expected/inheritance/diamond/meta_model.py +26 -0
  345. dev/test_data/parse/expected/inheritance/inheritance_from_concrete_class/meta_model.py +10 -0
  346. dev/test_data/parse/expected/invariants/in_relation/meta_model.py +16 -0
  347. dev/test_data/parse/expected/method/arguments/meta_model.py +7 -0
  348. dev/test_data/parse/expected/method/basic/meta_model.py +7 -0
  349. dev/test_data/parse/expected/method/contracts/condition_as_keyword_argument/meta_model.py +8 -0
  350. dev/test_data/parse/expected/method/contracts/condition_as_positional_argument/meta_model.py +8 -0
  351. dev/test_data/parse/expected/method/contracts/description_as_keyword_argument/meta_model.py +8 -0
  352. dev/test_data/parse/expected/method/contracts/description_as_positional_argument/meta_model.py +8 -0
  353. dev/test_data/parse/expected/method/contracts/multiple_contracts_in_order/meta_model.py +17 -0
  354. dev/test_data/parse/expected/method/contracts/postcondition/basic/meta_model.py +10 -0
  355. dev/test_data/parse/expected/method/contracts/postcondition/snapshot/with_keyword_arguments/meta_model.py +9 -0
  356. dev/test_data/parse/expected/method/contracts/postcondition/snapshot/with_positional_arguments/meta_model.py +9 -0
  357. dev/test_data/parse/expected/method/default/meta_model.py +9 -0
  358. dev/test_data/parse/expected/method/description/meta_model.py +8 -0
  359. dev/test_data/parse/expected/method/is_implementation_specific/meta_model.py +8 -0
  360. dev/test_data/parse/expected/method/non_mutating/meta_model.py +11 -0
  361. dev/test_data/parse/expected/method/returns_none/meta_model.py +7 -0
  362. dev/test_data/parse/expected/method/returns_something/meta_model.py +7 -0
  363. dev/test_data/parse/expected/single_class/description/meta_model.py +12 -0
  364. dev/test_data/parse/expected/single_class/empty/meta_model.py +6 -0
  365. dev/test_data/parse/expected/single_class/property/description/meta_model.py +14 -0
  366. dev/test_data/parse/expected/single_class/property/mandatory/meta_model.py +6 -0
  367. dev/test_data/parse/expected/single_class/property/optional/meta_model.py +6 -0
  368. dev/test_data/parse/expected/single_class/property/recursion_to_entity/meta_model.py +6 -0
  369. dev/test_data/parse/unexpected/class_decorators/non_name_decorator/meta_model.py +7 -0
  370. dev/test_data/parse/unexpected/class_decorators/unknown_decorator/meta_model.py +7 -0
  371. dev/test_data/parse/unexpected/class_definitions/is_abstract_and_implementation_specific/meta_model.py +8 -0
  372. dev/test_data/parse/unexpected/class_definitions/unexpected_docstring_before_a_method/meta_model.py +11 -0
  373. dev/test_data/parse/unexpected/class_definitions/unexpected_docstring_for_a_pass/meta_model.py +9 -0
  374. dev/test_data/parse/unexpected/class_definitions/unexpected_double_description_for_a_property/meta_model.py +10 -0
  375. dev/test_data/parse/unexpected/class_inheritances/inheriting_from_implementation_specific_parent/meta_model.py +20 -0
  376. dev/test_data/parse/unexpected/class_inheritances/non_name_super_class/meta_model.py +6 -0
  377. dev/test_data/parse/unexpected/enum/expression_as_assignment_value/meta_model.py +6 -0
  378. dev/test_data/parse/unexpected/enum/non_assignment/meta_model.py +8 -0
  379. dev/test_data/parse/unexpected/enum/non_string_literal/meta_model.py +6 -0
  380. dev/test_data/parse/unexpected/enum/unexpected_inheritance/meta_model.py +6 -0
  381. dev/test_data/parse/unexpected/method_contracts/contract/non_lambda_condition/meta_model.py +8 -0
  382. dev/test_data/parse/unexpected/method_contracts/contract/non_string_literal_description/meta_model.py +8 -0
  383. dev/test_data/parse/unexpected/method_contracts/contract/without_any_arguments/meta_model.py +8 -0
  384. dev/test_data/parse/unexpected/method_contracts/contract/without_condition/meta_model.py +8 -0
  385. dev/test_data/parse/unexpected/method_contracts/postcondition/OLD_in_postcondition_without_snapshot/meta_model.py +8 -0
  386. dev/test_data/parse/unexpected/method_contracts/postcondition/argument_missing_in_function/meta_model.py +8 -0
  387. dev/test_data/parse/unexpected/method_contracts/precondition/argument_missing_in_function/meta_model.py +8 -0
  388. dev/test_data/parse/unexpected/method_contracts/snapshot/argument_missing_in_function/meta_model.py +8 -0
  389. dev/test_data/parse/unexpected/method_contracts/snapshot/capture_not_a_lambda/meta_model.py +8 -0
  390. dev/test_data/parse/unexpected/method_contracts/snapshot/invalid_name/meta_model.py +8 -0
  391. dev/test_data/parse/unexpected/method_contracts/snapshot/name_not_a_string_literal/meta_model.py +8 -0
  392. dev/test_data/parse/unexpected/method_contracts/snapshot/without_a_capture/meta_model.py +8 -0
  393. dev/test_data/parse/unexpected/method_contracts/snapshot/without_a_name/meta_model.py +8 -0
  394. dev/test_data/parse/unexpected/method_decorators/non_mutating/non_mutating_constructor/meta_model.py +8 -0
  395. dev/test_data/parse/unexpected/method_decorators/non_mutating/non_mutating_verification_function/meta_model.py +8 -0
  396. dev/test_data/parse/unexpected/method_decorators/non_name_decorator/meta_model.py +8 -0
  397. dev/test_data/parse/unexpected/method_decorators/unknown_call_decorator/meta_model.py +8 -0
  398. dev/test_data/parse/unexpected/method_decorators/unknown_name_decorator/meta_model.py +8 -0
  399. dev/test_data/parse/unexpected/method_definitions/argument_with_final/meta_model.py +7 -0
  400. dev/test_data/parse/unexpected/method_definitions/argument_without_a_type_annotation/meta_model.py +7 -0
  401. dev/test_data/parse/unexpected/method_definitions/default_for_self/meta_model.py +7 -0
  402. dev/test_data/parse/unexpected/method_definitions/dunder/meta_model.py +7 -0
  403. dev/test_data/parse/unexpected/method_definitions/init_with_return_type/meta_model.py +7 -0
  404. dev/test_data/parse/unexpected/method_definitions/with_keyword_only_arguments/meta_model.py +7 -0
  405. dev/test_data/parse/unexpected/method_definitions/with_positional_arguments/meta_model.py +7 -0
  406. dev/test_data/parse/unexpected/method_definitions/with_type_annotation_for_self/meta_model.py +7 -0
  407. dev/test_data/parse/unexpected/method_definitions/with_variable_arguments/meta_model.py +7 -0
  408. dev/test_data/parse/unexpected/method_definitions/with_variable_keyword_arguments/meta_model.py +7 -0
  409. dev/test_data/parse/unexpected/method_definitions/without_arguments/meta_model.py +7 -0
  410. dev/test_data/parse/unexpected/method_definitions/without_self/meta_model.py +7 -0
  411. dev/test_data/parse/unexpected/method_definitions/without_type_annotation_for_result/meta_model.py +7 -0
  412. dev/test_data/parse/unexpected/property_definitions/final_without_subscript/meta_model.py +6 -0
  413. dev/test_data/parse/unexpected/property_definitions/nested_final/meta_model.py +6 -0
  414. dev/test_data/parse/unexpected/property_definitions/non_simple/meta_model.py +6 -0
  415. dev/test_data/parse/unexpected/property_definitions/unexpected_assignment/meta_model.py +6 -0
  416. dev/test_data/parse/unexpected/property_definitions/unexpected_non_name_property/meta_model.py +6 -0
  417. dev/test_data/parse/unexpected/property_definitions/without_type_annotation/meta_model.py +6 -0
  418. dev/test_data/parse/unexpected/symbol_table/constant_set_with_a_non_set_subset/meta_model.py +6 -0
  419. dev/test_data/parse/unexpected/symbol_table/dangling_inheritance/meta_model.py +6 -0
  420. dev/test_data/parse/unexpected/symbol_table/dangling_reference_in_type_annotation_of_a_property/meta_model.py +6 -0
  421. dev/test_data/parse/unexpected/symbol_table/dangling_reference_in_type_annotation_of_an_argument/meta_model.py +7 -0
  422. dev/test_data/parse/unexpected/symbol_table/dangling_reference_in_type_annotation_of_constant_set/meta_model.py +6 -0
  423. dev/test_data/parse/unexpected/symbol_table/dangling_subset_in_constant_set/meta_model.py +4 -0
  424. dev/test_data/parse/unexpected/symbol_table/inheritance_from_non_class/meta_model.py +10 -0
  425. dev/test_data/parse_retree/expected/character_set/common_escaping/source.py +1 -0
  426. dev/test_data/parse_retree/expected/character_set/complementing/double_caret/source.py +1 -0
  427. dev/test_data/parse_retree/expected/character_set/complementing/multiple_ranges/source.py +1 -0
  428. dev/test_data/parse_retree/expected/character_set/complementing/suffix_dash/source.py +1 -0
  429. dev/test_data/parse_retree/expected/character_set/escape_first_caret/source.py +1 -0
  430. dev/test_data/parse_retree/expected/character_set/literals_which_need_no_escaping_in_characters_set_but_need_escaping_outside/source.py +1 -0
  431. dev/test_data/parse_retree/expected/character_set/multiple_ranges/source.py +1 -0
  432. dev/test_data/parse_retree/expected/character_set/single_literal/source.py +1 -0
  433. dev/test_data/parse_retree/expected/character_set/single_range/source.py +1 -0
  434. dev/test_data/parse_retree/expected/character_set/unescaped_dash/only_dash/source.py +1 -0
  435. dev/test_data/parse_retree/expected/character_set/unescaped_dash/prefix_dash/source.py +1 -0
  436. dev/test_data/parse_retree/expected/character_set/unescaped_dash/suffix_dash/source.py +1 -0
  437. dev/test_data/parse_retree/expected/dot/source.py +1 -0
  438. dev/test_data/parse_retree/expected/empty/group/source.py +1 -0
  439. dev/test_data/parse_retree/expected/empty/group_in_a_group/source.py +1 -0
  440. dev/test_data/parse_retree/expected/empty/group_of_union_of_empty_concatenations/source.py +1 -0
  441. dev/test_data/parse_retree/expected/empty/regex/source.py +1 -0
  442. dev/test_data/parse_retree/expected/empty/union_of_empty_concatenations/source.py +1 -0
  443. dev/test_data/parse_retree/expected/escaped_literals/source.py +1 -0
  444. dev/test_data/parse_retree/expected/formatted_value/at_the_beginning/source.py +1 -0
  445. dev/test_data/parse_retree/expected/formatted_value/at_the_end/source.py +1 -0
  446. dev/test_data/parse_retree/expected/formatted_value/in_the_middle/source.py +1 -0
  447. dev/test_data/parse_retree/expected/formatted_value/single_formatted_value/source.py +1 -0
  448. dev/test_data/parse_retree/expected/literal/source.py +1 -0
  449. dev/test_data/parse_retree/expected/quantifier/greedy/at_least_3/source.py +1 -0
  450. dev/test_data/parse_retree/expected/quantifier/greedy/at_least_one/source.py +1 -0
  451. dev/test_data/parse_retree/expected/quantifier/greedy/at_most_3/source.py +1 -0
  452. dev/test_data/parse_retree/expected/quantifier/greedy/exactly_3/source.py +1 -0
  453. dev/test_data/parse_retree/expected/quantifier/greedy/maybe/source.py +1 -0
  454. dev/test_data/parse_retree/expected/quantifier/greedy/zero_or_more/source.py +1 -0
  455. dev/test_data/parse_retree/expected/quantifier/non_greedy/at_least_3/source.py +1 -0
  456. dev/test_data/parse_retree/expected/quantifier/non_greedy/at_least_one/source.py +1 -0
  457. dev/test_data/parse_retree/expected/quantifier/non_greedy/at_most_3/source.py +1 -0
  458. dev/test_data/parse_retree/expected/quantifier/non_greedy/exactly_3/source.py +1 -0
  459. dev/test_data/parse_retree/expected/quantifier/non_greedy/maybe/source.py +1 -0
  460. dev/test_data/parse_retree/expected/quantifier/non_greedy/zero_or_more/source.py +1 -0
  461. dev/test_data/parse_retree/expected/quantifier/on_a_character_set/source.py +1 -0
  462. dev/test_data/parse_retree/expected/quantifier/on_a_formatted_value/source.py +1 -0
  463. dev/test_data/parse_retree/expected/quantifier/on_a_group/source.py +1 -0
  464. dev/test_data/parse_retree/expected/quantifier/on_a_literal/source.py +1 -0
  465. dev/test_data/parse_retree/expected/start_and_stop_symbols/double_end_symbol/source.py +1 -0
  466. dev/test_data/parse_retree/expected/start_and_stop_symbols/double_start_symbol/source.py +1 -0
  467. dev/test_data/parse_retree/expected/start_and_stop_symbols/end_symbol_in_the_middle/source.py +1 -0
  468. dev/test_data/parse_retree/expected/start_and_stop_symbols/only_start_symbol/source.py +1 -0
  469. dev/test_data/parse_retree/expected/start_and_stop_symbols/only_stop_symbol/source.py +1 -0
  470. dev/test_data/parse_retree/expected/start_and_stop_symbols/start_symbol_at_the_beginning/source.py +1 -0
  471. dev/test_data/parse_retree/expected/start_and_stop_symbols/start_symbol_in_the_middle/source.py +1 -0
  472. dev/test_data/parse_retree/expected/start_and_stop_symbols/stop_symbol_at_the_end/source.py +1 -0
  473. dev/test_data/parse_retree/expected/union/of_character_sets/source.py +1 -0
  474. dev/test_data/parse_retree/expected/union/of_groups/source.py +1 -0
  475. dev/test_data/parse_retree/expected/union/of_string_literals/source.py +1 -0
  476. dev/test_data/parse_retree/expected/union/within_group/source.py +1 -0
  477. dev/test_data/parse_retree/expected/whitespace/source.py +1 -0
  478. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/Uxxxxxxxx_out_of_range/source.py +1 -0
  479. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/only_backslash/source.py +1 -0
  480. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/short_Uxxxxxxxx/source.py +1 -0
  481. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/short_uxxxx/source.py +1 -0
  482. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/short_x/source.py +1 -0
  483. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unexpected_escaping/source.py +1 -0
  484. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/digit/source.py +1 -0
  485. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/not_digit/source.py +1 -0
  486. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/not_whitespace/source.py +1 -0
  487. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/not_word/source.py +1 -0
  488. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/whitespace/source.py +1 -0
  489. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/word/source.py +1 -0
  490. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/Uxxxxxxxx_out_of_range/source.py +1 -0
  491. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/only_backslash/source.py +1 -0
  492. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/short_Uxxxxxxxx/source.py +1 -0
  493. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/short_uxxxx/source.py +1 -0
  494. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/short_x/source.py +1 -0
  495. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unexpected_escaping/source.py +1 -0
  496. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/digit/source.py +1 -0
  497. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/not_digit/source.py +1 -0
  498. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/not_whitespace/source.py +1 -0
  499. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/not_word/source.py +1 -0
  500. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/whitespace/source.py +1 -0
  501. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/word/source.py +1 -0
  502. dev/test_data/parse_retree/unexpected/invalid_character_range/source.py +1 -0
  503. dev/test_data/parse_retree/unexpected/invalid_quantifier/at_least_x/source.py +1 -0
  504. dev/test_data/parse_retree/unexpected/invalid_quantifier/between_3_and_x/source.py +1 -0
  505. dev/test_data/parse_retree/unexpected/invalid_quantifier/exactly_x/source.py +1 -0
  506. dev/test_data/parse_retree/unexpected/unhandled_group_directives/source.py +1 -0
  507. dev/test_data/parse_retree/unexpected/unterminated/character_set/source.py +1 -0
  508. dev/test_data/parse_retree/unexpected/unterminated/group/source.py +1 -0
  509. dev/test_data/parse_retree/unexpected/unterminated/group_of_union_of_empty_concatenations/source.py +1 -0
  510. dev/test_data/parse_retree/unexpected/unterminated/quantifier/source.py +1 -0
  511. dev/test_data/parse_retree/unexpected/unterminated/quantifier_with_comma/source.py +1 -0
  512. dev/test_data/parse_retree/unexpected/unterminated/quantifier_with_number_and_comma/source.py +1 -0
  513. dev/test_data/proto/test_main/expected/abstract_and_concrete_classes/meta_model.py +37 -0
  514. dev/test_data/proto/test_main/expected/concrete_class_with_descendants/meta_model.py +30 -0
  515. dev/test_data/proto/test_main/expected/concrete_class_with_enum/meta_model.py +21 -0
  516. dev/test_data/proto/test_main/expected/concrete_class_with_list_of_instances/meta_model.py +21 -0
  517. dev/test_data/proto/test_main/expected/concrete_class_with_primitive_attributes/meta_model.py +41 -0
  518. dev/test_data/python_protobuf/test_main/abstract_and_concrete_classes/expected_output/pbization.py +532 -0
  519. dev/test_data/python_protobuf/test_main/abstract_and_concrete_classes/meta_model.py +37 -0
  520. dev/test_data/python_protobuf/test_main/concrete_class_with_descendant/expected_output/pbization.py +527 -0
  521. dev/test_data/python_protobuf/test_main/concrete_class_with_descendant/meta_model.py +27 -0
  522. dev/test_data/python_protobuf/test_main/concrete_class_with_enum/expected_output/pbization.py +290 -0
  523. dev/test_data/python_protobuf/test_main/concrete_class_with_enum/meta_model.py +21 -0
  524. dev/test_data/python_protobuf/test_main/concrete_class_with_list_of_instances/expected_output/pbization.py +328 -0
  525. dev/test_data/python_protobuf/test_main/concrete_class_with_list_of_instances/meta_model.py +23 -0
  526. dev/test_data/python_protobuf/test_main/concrete_class_with_primitive_attributes/expected_output/pbization.py +274 -0
  527. dev/test_data/python_protobuf/test_main/concrete_class_with_primitive_attributes/meta_model.py +41 -0
  528. dev/test_data/rdf_shacl/test_main/expected/regression_when_lang_string_class_is_missing/meta_model.py +29 -0
  529. dev/test_data/rdf_shacl/test_main/expected/regression_when_len_constraints_on_inherited_property/meta_model.py +27 -0
  530. dev/test_data/rdf_shacl/test_main/unexpected/regression_len_constraint_on_class_property/meta_model.py +61 -0
  531. dev/test_data/real_meta_models/aas_core_meta.v3.py +5721 -0
  532. dev/test_data/smoke/test_main/unexpected/infer_for_schema_error/meta_model.py +12 -0
  533. dev/test_data/smoke/test_main/unexpected/intermediate_error/meta_model.py +18 -0
  534. dev/test_data/smoke/test_main/unexpected/parse_error/meta_model.py +5 -0
  535. dev/test_data/smoke/test_main/unexpected/pattern_verification_unparsable_regex/direct_match/meta_model.py +8 -0
  536. dev/test_data/smoke/test_main/unexpected/type_error/meta_model.py +18 -0
  537. dev/tests/__init__.py +1 -0
  538. dev/tests/common.py +197 -0
  539. dev/tests/cpp/__init__.py +0 -0
  540. dev/tests/cpp/test_common.py +32 -0
  541. dev/tests/cpp/test_main.py +144 -0
  542. dev/tests/cpp/test_pattern.py +188 -0
  543. dev/tests/cpp/test_verification.py +189 -0
  544. dev/tests/cpp/test_yielding.py +225 -0
  545. dev/tests/csharp/__init__.py +0 -0
  546. dev/tests/csharp/live_test_main.py +109 -0
  547. dev/tests/csharp/test_common.py +28 -0
  548. dev/tests/csharp/test_description.py +684 -0
  549. dev/tests/csharp/test_main.py +129 -0
  550. dev/tests/csharp/test_structure.py +93 -0
  551. dev/tests/csharp/test_verification.py +82 -0
  552. dev/tests/description.py +29 -0
  553. dev/tests/golang/__init__.py +0 -0
  554. dev/tests/golang/test_common.py +78 -0
  555. dev/tests/golang/test_main.py +128 -0
  556. dev/tests/infer_for_schema/__init__.py +0 -0
  557. dev/tests/infer_for_schema/common.py +47 -0
  558. dev/tests/infer_for_schema/test_len_on_properties.py +955 -0
  559. dev/tests/infer_for_schema/test_len_on_self.py +580 -0
  560. dev/tests/infer_for_schema/test_patterns_on_properties.py +686 -0
  561. dev/tests/infer_for_schema/test_patterns_on_self.py +258 -0
  562. dev/tests/infer_for_schema/test_property_in_set_of_enumeration_literals.py +600 -0
  563. dev/tests/infer_for_schema/test_property_in_set_of_primitives.py +549 -0
  564. dev/tests/intermediate/__init__.py +0 -0
  565. dev/tests/intermediate/test_constructor.py +719 -0
  566. dev/tests/intermediate/test_hierarchy.py +221 -0
  567. dev/tests/intermediate/test_revm.py +134 -0
  568. dev/tests/intermediate/test_translate.py +337 -0
  569. dev/tests/intermediate/test_type_inference.py +333 -0
  570. dev/tests/intermediate/test_types.py +169 -0
  571. dev/tests/java/__init__.py +0 -0
  572. dev/tests/java/test_common.py +20 -0
  573. dev/tests/java/test_description.py +128 -0
  574. dev/tests/java/test_main.py +234 -0
  575. dev/tests/jsonld_context/test_main.py +79 -0
  576. dev/tests/opcua/__init__.py +3 -0
  577. dev/tests/opcua/test_main.py +110 -0
  578. dev/tests/our_jsonschema/__init__.py +3 -0
  579. dev/tests/our_jsonschema/test_main.py +232 -0
  580. dev/tests/parse/__init__.py +0 -0
  581. dev/tests/parse/test_parse.py +503 -0
  582. dev/tests/parse/test_retree.py +272 -0
  583. dev/tests/proto/__init__.py +0 -0
  584. dev/tests/proto/test_main.py +112 -0
  585. dev/tests/python/__init__.py +0 -0
  586. dev/tests/python/test_common.py +124 -0
  587. dev/tests/python/test_main.py +126 -0
  588. dev/tests/python/test_xml_playground.py +254 -0
  589. dev/tests/python_protobuf/__init__.py +0 -0
  590. dev/tests/python_protobuf/test_main.py +111 -0
  591. dev/tests/rdf_shacl/__init__.py +0 -0
  592. dev/tests/rdf_shacl/test_common.py +32 -0
  593. dev/tests/rdf_shacl/test_description.py +223 -0
  594. dev/tests/rdf_shacl/test_main.py +194 -0
  595. dev/tests/smoke/__init__.py +0 -0
  596. dev/tests/smoke/test_main.py +83 -0
  597. dev/tests/test_common.py +94 -0
  598. dev/tests/typescript/__init__.py +0 -0
  599. dev/tests/typescript/test_common.py +108 -0
  600. dev/tests/typescript/test_main.py +125 -0
  601. dev/tests/xsd/__init__.py +0 -0
  602. dev/tests/xsd/test_main.py +227 -0
  603. dev/tests/yielding/__init__.py +0 -0
  604. dev/tests/yielding/test_linear.py +558 -0
@@ -0,0 +1,1149 @@
1
+ """Generate C++ code of a virtual machine for matching regular expressions."""
2
+
3
+ import io
4
+
5
+ from icontract import ensure
6
+
7
+ from aas_core_codegen.common import (
8
+ Stripped,
9
+ )
10
+ from aas_core_codegen.cpp import common as cpp_common
11
+ from aas_core_codegen.cpp.common import (
12
+ INDENT as I,
13
+ INDENT2 as II,
14
+ INDENT3 as III,
15
+ INDENT4 as IIII,
16
+ INDENT5 as IIIII,
17
+ INDENT6 as IIIIII,
18
+ INDENT7 as IIIIIII,
19
+ INDENT8 as IIIIIIII,
20
+ )
21
+
22
+
23
+ # fmt: off
24
+ @ensure(
25
+ lambda result:
26
+ result.endswith('\n'),
27
+ "Trailing newline mandatory for valid end-of-files"
28
+ )
29
+ # fmt: on
30
+ def generate_header(library_namespace: Stripped) -> str:
31
+ """Generate the C++ header of a virtual machine for matching regexes."""
32
+ namespace = Stripped(f"{library_namespace}::{cpp_common.REVM_NAMESPACE}")
33
+
34
+ include_guard_var = cpp_common.include_guard_var(namespace)
35
+
36
+ blocks = [
37
+ Stripped(
38
+ f"""\
39
+ #ifndef {include_guard_var}
40
+ #define {include_guard_var}"""
41
+ ),
42
+ cpp_common.WARNING,
43
+ Stripped(
44
+ """\
45
+ #pragma warning(push, 0)
46
+ #include <cstdint>
47
+ #include <memory>
48
+ #include <string>
49
+ #include <vector>
50
+ #pragma warning(pop)"""
51
+ ),
52
+ cpp_common.generate_namespace_opening(library_namespace),
53
+ Stripped(
54
+ f"""\
55
+ /**
56
+ * \\defgroup {cpp_common.REVM_NAMESPACE} Match regular expressions using a multi-threaded virtual machine.
57
+ *
58
+ * The implementation in the standard library has exponential time complexity, so it was
59
+ * a major blocker for most of the practical inputs. For example, see this bug report:
60
+ * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93502
61
+ *
62
+ * This implementation is based on Ken Thompson's approach which uses a virtual
63
+ * machine to match regular expressions. The original technique has been
64
+ * published in:
65
+ * Thompson, K., "Regular expression search algorithm", ACM 11(6) (June 1968)
66
+ *
67
+ * We followed a very clear and concise blog post which described in detail:
68
+ * https://swtch.com/~rsc/regexp/regexp2.html
69
+ *
70
+ * The ideas for additional instructions were taken from:
71
+ * https://www.codeproject.com/Articles/5256833/Regex-as-a-Tiny-Threaded-Virtual-Machine
72
+ * @{{
73
+ */
74
+ namespace {cpp_common.REVM_NAMESPACE} {{
75
+
76
+ enum class InstructionKind : std::uint8_t {{
77
+ {I}Char,
78
+ {I}Set,
79
+ {I}NotSet,
80
+ {I}Any,
81
+ {I}Match,
82
+ {I}Jump,
83
+ {I}Split,
84
+ {I}End
85
+ }};
86
+
87
+ /**
88
+ * Represent an instruction of the virtual machine.
89
+ */
90
+ struct Instruction {{
91
+ {I}// NOTE (mristin):
92
+ {I}// We avoid RTTI for performance reasons, and use our own enumerator instead.
93
+ {I}virtual InstructionKind kind() const = 0;
94
+
95
+ {I}virtual ~Instruction() = default;
96
+ }};
97
+
98
+ /**
99
+ * Match a single character.
100
+ *
101
+ * If the character on the String Pointer does not match the `character`, stop this
102
+ * thread as it failed. Otherwise, move the String Pointer to the next character,
103
+ * and the Program Counter to the next instruction.
104
+ */
105
+ struct InstructionChar : Instruction {{
106
+ {I}wchar_t character;
107
+
108
+ {I}explicit InstructionChar(wchar_t a_character);
109
+ {I}InstructionKind kind() const override;
110
+ {I}~InstructionChar() override = default;
111
+ }};
112
+
113
+ std::string to_string(const InstructionChar& instruction);
114
+
115
+ /**
116
+ * Define a character range.
117
+ */
118
+ struct Range {{
119
+ {I}wchar_t first;
120
+ {I}wchar_t last;
121
+
122
+ {I}Range(wchar_t a_first, wchar_t a_last);
123
+ }};
124
+
125
+ std::string to_string(const Range& range);
126
+
127
+ /**
128
+ * Check whether the character is in any of the given character ranges.
129
+ *
130
+ * @return true if the character is in any of the ranges
131
+ */
132
+ bool CharacterInRanges(
133
+ {I}const std::vector<Range>& ranges,
134
+ {I}wchar_t character
135
+ );
136
+
137
+ /**
138
+ * Match a set of characters.
139
+ *
140
+ * If the character on the String Pointer *is not* in the given set, stop this
141
+ * thread as it failed. Otherwise, move the String Pointer to the next character,
142
+ * and the Program Counter to the next instruction.
143
+ */
144
+ struct InstructionSet : Instruction {{
145
+ {I}std::vector<Range> ranges;
146
+
147
+ {I}explicit InstructionSet(std::vector<Range> a_ranges);
148
+ {I}InstructionKind kind() const override;
149
+ {I}~InstructionSet() override = default;
150
+ }};
151
+
152
+ std::string to_string(const InstructionSet& instruction);
153
+
154
+ /**
155
+ * Match an out-of-set character.
156
+ *
157
+ * If the character on the String Pointer *is* in the given set, stop this
158
+ * thread as it failed. Otherwise, move the String Pointer to the next character,
159
+ * and the Program Counter to the next instruction.
160
+ */
161
+ struct InstructionNotSet : Instruction {{
162
+ {I}std::vector<Range> ranges;
163
+
164
+ {I}explicit InstructionNotSet(std::vector<Range> a_ranges);
165
+ {I}InstructionKind kind() const override;
166
+ {I}~InstructionNotSet() override = default;
167
+ }};
168
+
169
+ std::string to_string(const InstructionNotSet& instruction);
170
+
171
+ /**
172
+ * Match any character.
173
+ */
174
+ struct InstructionAny : Instruction {{
175
+ {I}InstructionKind kind() const override;
176
+ {I}~InstructionAny() override = default;
177
+ }};
178
+
179
+ std::string to_string(const InstructionAny&);
180
+
181
+ /**
182
+ * Stop this thread and signal that we found a match.
183
+ */
184
+ struct InstructionMatch : Instruction {{
185
+ {I}InstructionKind kind() const override;
186
+ {I}~InstructionMatch() override = default;
187
+ }};
188
+
189
+ std::string to_string(const InstructionMatch&);
190
+
191
+ /**
192
+ * Jump to the indicated position in the program.
193
+ */
194
+ struct InstructionJump : Instruction {{
195
+ {I}size_t target;
196
+
197
+ {I}explicit InstructionJump(size_t a_target);
198
+ {I}InstructionKind kind() const override;
199
+ {I}~InstructionJump() override = default;
200
+ }};
201
+
202
+ std::string to_string(const InstructionJump& instruction);
203
+
204
+ /**
205
+ * Split the program in two threads, both jumping to different locations. The string
206
+ * pointer is kept as-is.
207
+ */
208
+ struct InstructionSplit : Instruction {{
209
+ {I}size_t first_target;
210
+ {I}size_t second_target;
211
+
212
+ {I}explicit InstructionSplit(size_t a_first_target, size_t a_second_target);
213
+ {I}InstructionKind kind() const override;
214
+ {I}~InstructionSplit() override = default;
215
+ }};
216
+
217
+ std::string to_string(const InstructionSplit& instruction);
218
+
219
+ /**
220
+ * Match the end-of-input.
221
+ */
222
+ struct InstructionEnd : Instruction {{
223
+ {I}InstructionKind kind() const override;
224
+ {I}~InstructionEnd() override = default;
225
+ }};
226
+
227
+ std::string to_string(const InstructionEnd&);
228
+
229
+ std::string to_string(const Instruction& instruction);
230
+
231
+ std::string to_string(
232
+ {I}const std::vector<std::unique_ptr<Instruction> >& instructions
233
+ );
234
+
235
+ /**
236
+ * Try to match the program against the text.
237
+ * @return true if the text matches
238
+ */
239
+ bool Match(
240
+ {I}const std::vector<std::unique_ptr<Instruction> >& program,
241
+ {I}const std::wstring& text
242
+ );
243
+
244
+ }} // namespace {cpp_common.REVM_NAMESPACE}
245
+ /**@}}*/"""
246
+ ),
247
+ cpp_common.generate_namespace_closing(library_namespace),
248
+ cpp_common.WARNING,
249
+ Stripped(f"#endif // {include_guard_var}"),
250
+ ]
251
+
252
+ writer = io.StringIO()
253
+ for i, block in enumerate(blocks):
254
+ if i > 0:
255
+ writer.write("\n\n")
256
+
257
+ writer.write(block)
258
+
259
+ writer.write("\n")
260
+
261
+ return writer.getvalue()
262
+
263
+
264
+ # fmt: off
265
+ @ensure(
266
+ lambda result:
267
+ result.endswith('\n'),
268
+ "Trailing newline mandatory for valid end-of-files"
269
+ )
270
+ # fmt: on
271
+ def generate_implementation(
272
+ library_namespace: Stripped,
273
+ ) -> str:
274
+ """Generate the C++ implementation of a virtual machine for matching regexes."""
275
+ namespace = Stripped(f"{library_namespace}::{cpp_common.REVM_NAMESPACE}")
276
+
277
+ include_prefix_path = cpp_common.generate_include_prefix_path(library_namespace)
278
+
279
+ blocks = [
280
+ cpp_common.WARNING,
281
+ Stripped(
282
+ f"""\
283
+ #include "{include_prefix_path}/common.hpp"
284
+ #include "{include_prefix_path}/revm.hpp"
285
+
286
+ #pragma warning(push, 0)
287
+ #include <algorithm>
288
+ #include <iomanip>
289
+ #include <sstream>
290
+ #pragma warning(pop)"""
291
+ ),
292
+ cpp_common.generate_namespace_opening(namespace),
293
+ Stripped(
294
+ f"""\
295
+ /**
296
+ * Represent the character such that it can be printed in the console.
297
+ *
298
+ * To that end, we escape the character if it is out of the printable ASCII set.
299
+ *
300
+ * This function is mostly meant for debugging purposes.
301
+ */
302
+ std::string RepresentWCharacter(wchar_t character) {{
303
+ {I}switch (character) {{
304
+ {II}case L'\\\\':return "\\\\\\\\";
305
+ {II}case L'"':return "\\\\\\"";
306
+ {II}case L'\\'':return "\\\\'";
307
+ {II}case L'\\t':return "\\\\t";
308
+ {II}case L'\\n':return "\\\\n";
309
+ {II}case L'\\r':return "\\\\r";
310
+ {II}default: break;
311
+ {I}}}
312
+
313
+ {I}if (26 <= character && character <= 126) {{
314
+ {II}return std::string(1, static_cast<char>(character));
315
+ {I}}}
316
+
317
+ {I}static const char* digits = "0123456789ABCDEF";
318
+ {I}size_t digit_count = sizeof(wchar_t) * 2;
319
+
320
+ {I}std::string result;
321
+ {I}result.resize(digit_count + 2);
322
+ {I}result[0] = L'\\\\';
323
+ {I}result[1] = L'u';
324
+
325
+ {I}for (size_t i = 0, j = (digit_count - 1) * 4; i < digit_count; ++i, j -= 4) {{
326
+ {II}const size_t digit_i = (character >> j) & 0x0f;
327
+ {II}result[i + 2] = digits[digit_i];
328
+ {I}}}
329
+
330
+ {I}return result;
331
+ }}
332
+
333
+ /**
334
+ * Represent the wide string for debugging purposes where it is printed to the console.
335
+ *
336
+ * To that end, we escape the individual characters if they are out of printable ASCII
337
+ * set.
338
+ */
339
+ std::string RepresentWString(const std::wstring& text) {{
340
+ {I}std::vector<std::string> parts;
341
+ {I}parts.reserve(text.size());
342
+ {I}for (const wchar_t character : text) {{
343
+ {II}parts.emplace_back(RepresentWCharacter(character));
344
+ {I}}}
345
+
346
+ {I}size_t size = 0;
347
+ {I}for (const std::string& part : parts) {{
348
+ {II}size += part.size();
349
+ {I}}}
350
+
351
+ {I}std::string result;
352
+ {I}result.reserve(size);
353
+ {I}for (const std::string& part : parts) {{
354
+ {II}result.append(part);
355
+ {I}}}
356
+ {I}return result;
357
+ }}
358
+
359
+ InstructionChar::InstructionChar(
360
+ {I}wchar_t a_character
361
+ ) :
362
+ {I}character(a_character) {{
363
+ {I}// Intentionally empty.
364
+ }}
365
+
366
+ InstructionKind InstructionChar::kind() const {{
367
+ {I}return InstructionKind::Char;
368
+ }}
369
+
370
+ std::string to_string(const InstructionChar& instruction) {{
371
+ {I}return common::Concat(
372
+ {II}"char '",
373
+ {II}RepresentWCharacter(instruction.character),
374
+ {II}"'"
375
+ {I});
376
+ }}
377
+
378
+ Range::Range(
379
+ {I}wchar_t a_first,
380
+ {I}wchar_t a_last
381
+ ) :
382
+ {I}first(a_first),
383
+ {I}last(a_last) {{
384
+ {I}// NOTE (mristin):
385
+ {I}// We are aware that exceptions in constructors should be avoided to prevent
386
+ {I}// bug related to uninitialized object state. However, in this case, we do not
387
+ {I}// see any risk for such a mistake.
388
+ {I}if (a_first > a_last) {{
389
+ {II}throw std::invalid_argument(
390
+ {III}common::Concat(
391
+ {IIII}"The first character in a character range, ",
392
+ {IIII}RepresentWCharacter(a_first),
393
+ {IIII}", is larger than the last character in the range, ",
394
+ {IIII}RepresentWCharacter(a_last)
395
+ {III})
396
+ {II});
397
+ {I}}}
398
+ }}
399
+
400
+ std::string to_string(const Range& range) {{
401
+ {I}if (range.first == range.last) {{
402
+ {II}return RepresentWCharacter(range.first);
403
+ {I}}}
404
+
405
+ {I}return common::Concat(
406
+ {II}RepresentWCharacter(range.first),
407
+ {II}"-",
408
+ {II}RepresentWCharacter(range.last)
409
+ {I});
410
+ }}
411
+
412
+ InstructionSet::InstructionSet(
413
+ {I}std::vector<Range> a_ranges
414
+ ) :
415
+ {I}ranges(std::move(a_ranges)) {{
416
+ {I}// NOTE (mristin):
417
+ {I}// We are aware that exceptions in constructors should be avoided to prevent
418
+ {I}// bug related to uninitialized object state. However, in this case, we do not
419
+ {I}// see any risk for such a mistake.
420
+ {I}if (ranges.empty()) {{
421
+ {II}throw std::invalid_argument(
422
+ {III}"Unexpected NotSet instruction with empty ranges"
423
+ {II});
424
+ {I}}}
425
+
426
+ {I}for (size_t i = 1; i < ranges.size(); ++i) {{
427
+ {II}if (ranges[i - 1].last >= ranges[i].first) {{
428
+ {III}throw std::invalid_argument(
429
+ {IIII}common::Concat(
430
+ {IIIII}"The ranges for an InstructionSet are unexpectedly either "
431
+ {IIIII}"not sorted or overlapping. The range at index ",
432
+ {IIIII}std::to_string(i - 1),
433
+ {IIIII}" is ",
434
+ {IIIII}to_string(ranges[i - 1]),
435
+ {IIIII}" and the range at index ",
436
+ {IIIII}std::to_string(i),
437
+ {IIIII}" is ",
438
+ {IIIII}to_string(ranges[i])
439
+ {IIII})
440
+ {III});
441
+ {II}}}
442
+ {I}}}
443
+ }}
444
+
445
+ InstructionKind InstructionSet::kind() const {{
446
+ {I}return InstructionKind::Set;
447
+ }}
448
+
449
+ std::string to_string(const InstructionSet& instruction) {{
450
+ {I}std::stringstream ss;
451
+ {I}ss << "set '";
452
+
453
+ {I}for (const auto& range : instruction.ranges) {{
454
+ {II}ss << to_string(range);
455
+ {I}}}
456
+
457
+ {I}ss << "'";
458
+ {I}return ss.str();
459
+ }}
460
+
461
+ InstructionNotSet::InstructionNotSet(
462
+ {I}std::vector<Range> a_ranges
463
+ ) :
464
+ {I}ranges(std::move(a_ranges)) {{
465
+ {I}// NOTE (mristin):
466
+ {I}// We are aware that exceptions in constructors should be avoided to prevent
467
+ {I}// bug related to uninitialized object state. However, in this case, we do not
468
+ {I}// see any risk for such a mistake.
469
+ {I}if (ranges.empty()) {{
470
+ {II}throw std::invalid_argument(
471
+ {III}"Unexpected NotSet instruction with empty ranges"
472
+ {II});
473
+ {I}}}
474
+
475
+ {I}for (size_t i = 1; i < ranges.size(); ++i) {{
476
+ {II}if (ranges[i - 1].last >= ranges[i].first) {{
477
+ {III}throw std::invalid_argument(
478
+ {IIII}common::Concat(
479
+ {IIIII}"The ranges for an InstructionNotSet are unexpectedly either "
480
+ {IIIII}"not sorted or overlapping. The range at index ",
481
+ {IIIII}std::to_string(i - 1),
482
+ {IIIII}" is ",
483
+ {IIIII}to_string(ranges[i - 1]),
484
+ {IIIII}" and the range at index ",
485
+ {IIIII}std::to_string(i),
486
+ {IIIII}" is ",
487
+ {IIIII}to_string(ranges[i])
488
+ {IIII})
489
+ {III});
490
+ {II}}}
491
+ {I}}}
492
+ }}
493
+
494
+ InstructionKind InstructionNotSet::kind() const {{
495
+ {I}return InstructionKind::NotSet;
496
+ }}
497
+
498
+ std::string to_string(const InstructionNotSet& instruction) {{
499
+ {I}std::stringstream ss;
500
+ {I}ss << "not-set '";
501
+
502
+ {I}for (const auto& range : instruction.ranges) {{
503
+ {II}ss << to_string(range);
504
+ {I}}}
505
+
506
+ {I}ss << "'";
507
+ {I}return ss.str();
508
+ }}
509
+
510
+ InstructionKind InstructionAny::kind() const {{
511
+ {I}return InstructionKind::Any;
512
+ }}
513
+
514
+ std::string to_string(const InstructionAny&) {{
515
+ {I}return "any";
516
+ }}
517
+
518
+ InstructionKind InstructionMatch::kind() const {{
519
+ {I}return InstructionKind::Match;
520
+ }}
521
+
522
+ std::string to_string(const InstructionMatch&) {{
523
+ {I}return "match";
524
+ }}
525
+
526
+ InstructionJump::InstructionJump(
527
+ {I}size_t a_target
528
+ ) :
529
+ {I}target(a_target) {{
530
+ {I}// Intentionally empty.
531
+ }}
532
+
533
+ InstructionKind InstructionJump::kind() const {{
534
+ {I}return InstructionKind::Jump;
535
+ }}
536
+
537
+ std::string to_string(const InstructionJump& instruction) {{
538
+ {I}return common::Concat(
539
+ {II}"jump ",
540
+ {II}std::to_string(instruction.target)
541
+ {I});
542
+ }}
543
+
544
+ InstructionSplit::InstructionSplit(
545
+ {I}size_t a_first_target,
546
+ {I}size_t a_second_target
547
+ ) :
548
+ {I}first_target(a_first_target),
549
+ {I}second_target(a_second_target) {{
550
+ {I}// Intentionally empty.
551
+ }}
552
+
553
+ InstructionKind InstructionSplit::kind() const {{
554
+ {I}return InstructionKind::Split;
555
+ }}
556
+
557
+ std::string to_string(const InstructionSplit& instruction) {{
558
+ {I}return common::Concat(
559
+ {II}"split ",
560
+ {III}std::to_string(instruction.first_target),
561
+ {III}", ",
562
+ {III}std::to_string(instruction.second_target)
563
+ {I});
564
+ }}
565
+
566
+ InstructionKind InstructionEnd::kind() const {{
567
+ {I}return InstructionKind::End;
568
+ }}
569
+
570
+ std::string to_string(const InstructionEnd&) {{
571
+ {I}return "end";
572
+ }}
573
+
574
+ std::string to_string(const Instruction& instruction) {{
575
+ {I}switch (instruction.kind()) {{
576
+ {II}case InstructionKind::Char:
577
+ {III}return to_string(
578
+ {IIII}static_cast< // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
579
+ {IIIII}const InstructionChar&
580
+ {IIII}>(instruction)
581
+ {III});
582
+
583
+ {II}case InstructionKind::Set:
584
+ {III}return to_string(
585
+ {IIII}static_cast< // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
586
+ {IIIII}const InstructionSet&
587
+ {IIII}>(instruction)
588
+ {III});
589
+
590
+ {II}case InstructionKind::NotSet:
591
+ {III}return to_string(
592
+ {IIII}static_cast< // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
593
+ {IIIII}const InstructionNotSet&
594
+ {IIII}>(instruction)
595
+ {III});
596
+
597
+ {II}case InstructionKind::Any:
598
+ {III}return to_string(
599
+ {IIII}static_cast< // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
600
+ {IIIII}const InstructionAny&
601
+ {IIII}>(instruction)
602
+ {III});
603
+
604
+ {II}case InstructionKind::Match:
605
+ {III}return to_string(
606
+ {IIII}static_cast< // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
607
+ {IIIII}const InstructionMatch&
608
+ {IIII}>(instruction)
609
+ {III});
610
+
611
+ {II}case InstructionKind::Jump:
612
+ {III}return to_string(
613
+ {IIII}static_cast< // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
614
+ {IIIII}const InstructionJump&
615
+ {IIII}>(instruction)
616
+ {III});
617
+
618
+ {II}case InstructionKind::Split:
619
+ {III}return to_string(
620
+ {IIII}static_cast< // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
621
+ {IIIII}const InstructionSplit&
622
+ {IIII}>(instruction)
623
+ {III});
624
+
625
+ {II}case InstructionKind::End:
626
+ {III}return to_string(
627
+ {IIII}static_cast< // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
628
+ {IIIII}const InstructionEnd&
629
+ {IIII}>(instruction)
630
+ {III});
631
+
632
+ {II}default:
633
+ {III}throw std::logic_error(
634
+ {IIII}common::Concat(
635
+ {IIIII}"Unhandled instruction kind: ",
636
+ {IIIII}std::to_string(
637
+ {IIIIII}static_cast<std::uint8_t>(instruction.kind())
638
+ {IIIII})
639
+ {IIII})
640
+ {III});
641
+ {I}}}
642
+ }}
643
+
644
+ std::string to_string(
645
+ {I}const std::vector<std::unique_ptr<Instruction> >& instructions
646
+ ) {{
647
+ {I}std::stringstream ss;
648
+ {I}for (size_t i = 0; i < instructions.size(); ++i) {{
649
+ {II}ss
650
+ {III}<< std::setw(4) << i << ": "
651
+ {III}<< to_string(*instructions[i]) << std::endl;
652
+ {I}}}
653
+
654
+ {I}return ss.str();
655
+ }}
656
+
657
+ bool CharacterInRanges(
658
+ {I}const std::vector<Range>& ranges,
659
+ {I}wchar_t character
660
+ ) {{
661
+ {I}if (ranges.empty()) {{
662
+ {II}return false;
663
+ {I}}}
664
+
665
+ {I}if (ranges.size() == 1) {{
666
+ {II}return (ranges[0].first <= character && character <= ranges[0].last);
667
+ {I}}}
668
+
669
+ {I}// Binary search
670
+ {I}size_t begin = 0;
671
+ {I}size_t end = ranges.size();
672
+
673
+ {I}while (true) {{
674
+ {II}if (begin == end) {{
675
+ {III}return false;
676
+ {II}}}
677
+
678
+ {II}// NOTE (mristin):
679
+ {II}// Most implementations of the binary search are buggy, see:
680
+ {II}// https://en.wikipedia.org/wiki/Binary_search_algorithm#Implementation_issues.
681
+ {II}//
682
+ {II}// We try to avert some of the bugs by explicitly handling the case where there
683
+ {II}// are at most 3 elements in the segment, so we stop here instead of proceeding
684
+ {II}// recursively.
685
+ {II}if (end - begin <= 3) {{
686
+ {III}for (size_t i = begin; i < end; ++i) {{
687
+ {IIII}const Range& range = ranges[i];
688
+ {IIII}if (range.first <= character && character <= range.last) {{
689
+ {IIIII}return true;
690
+ {IIII}}}
691
+ {III}}}
692
+ {III}return false;
693
+ {II}}}
694
+
695
+ {II}const size_t middle = (begin + end) / 2;
696
+ {II}const Range& range = ranges[middle];
697
+ {II}if (character < range.first) {{
698
+ {III}end = middle;
699
+ {II}}} else if (character > range.last) {{
700
+ {III}begin = middle;
701
+ {II}}} else {{
702
+ {III}return true;
703
+ {II}}}
704
+ {I}}}
705
+ }}
706
+
707
+ /**
708
+ * Keep track of the threads currently being executed.
709
+ */
710
+ class ThreadList {{
711
+ public:
712
+ {I}explicit ThreadList(size_t program_size) {{
713
+ {II}has_.resize(program_size, false);
714
+ {II}items_.reserve(program_size);
715
+ {I}}}
716
+
717
+ {I}/**
718
+ {I} * Add a new thread for the given program counter if it is not already in the list.
719
+ {I} */
720
+ {I}void Spawn(size_t program_counter) {{
721
+ {II}#ifdef DEBUG
722
+ {II}if (program_counter >= program_size_) {{
723
+ {III}throw std::invalid_argument(
724
+ {IIII}common::Concat(
725
+ {IIIII}"Unexpected spawning of a thread at the program counter ",
726
+ {IIIII}std::to_string(program_counter),
727
+ {IIIII}" since the program size was indicated to be ",
728
+ {IIIII}std::to_string(program_size_)
729
+ {IIII})
730
+ {III});
731
+ {II}}}
732
+ {II}#endif
733
+
734
+ {II}if (has_[program_counter]) {{
735
+ {III}return;
736
+ {II}}}
737
+
738
+ {II}has_[program_counter] = true;
739
+ {II}items_.push_back(program_counter);
740
+ {I}}}
741
+
742
+ {I}bool Empty() const {{
743
+ {II}return items_.empty();
744
+ {I}}}
745
+
746
+ {I}/**
747
+ {I} * Pop the thread from the back, returning its program counter.
748
+ {I} *
749
+ {I} * The order of the threads is not guaranteed.
750
+ {I} */
751
+ {I}size_t Pop() {{
752
+ {II}#ifdef DEBUG
753
+ {II}if (items_.empty()) {{
754
+ {III}throw std::logic_error(
755
+ {IIII}"You tried to pop from an empty thread list."
756
+ {IIII});
757
+ {II}}}
758
+ {II}#endif
759
+
760
+ {II}const size_t program_counter = items_.back();
761
+ {II}items_.pop_back();
762
+ {II}has_[program_counter] = false;
763
+ {II}return program_counter;
764
+ {I}}}
765
+
766
+ {I}/**
767
+ {I} * Clear the thread list, keeping its memory capacity.
768
+ {I} */
769
+ {I}void Clear() {{
770
+ {II}std::fill(has_.begin(), has_.end(), false);
771
+ {II}items_.clear();
772
+ {I}}}
773
+
774
+ {I}/**
775
+ {I} * Return the program counters corresponding to the spawned threads.
776
+ {I} */
777
+ {I}const std::vector<size_t>& Items() const {{
778
+ {II}return items_;
779
+ {I}}};
780
+
781
+ private:
782
+ {I}/**
783
+ {I} * Keep track of the program counters corresponding to the threads so that we can
784
+ {I} * avoid the duplicate threads.
785
+ {I} */
786
+ {I}std::vector<bool> has_;
787
+
788
+ {I}/**
789
+ {I} * Keep track of the active threads.
790
+ {I} */
791
+ {I}std::vector<size_t> items_;
792
+ }};
793
+
794
+ std::string to_string(const ThreadList& thread_list) {{
795
+ {I}if (thread_list.Empty()) {{
796
+ {II}return "[]";
797
+ {I}}}
798
+
799
+ {I}std::vector<size_t> items(thread_list.Items());
800
+ {I}std::sort(items.begin(), items.end());
801
+
802
+ {I}std::stringstream ss;
803
+ {I}ss << "[";
804
+ {I}ss << std::to_string(items[0]);
805
+
806
+ {I}for (size_t i = 1; i < items.size(); ++i) {{
807
+ {II}ss << ", " << items[i];
808
+ {I}}}
809
+ {I}ss << "]";
810
+
811
+ {I}return ss.str();
812
+ }}
813
+
814
+ /**
815
+ * Try to match the program against the text.
816
+ *
817
+ * @return true if the text matches
818
+ */
819
+ bool Match(
820
+ {I}const std::vector<std::unique_ptr<Instruction> >& program,
821
+ {I}const std::wstring& text
822
+ ) {{
823
+ {I}if (program.empty()) {{
824
+ {II}return false;
825
+ {I}}}
826
+
827
+ {I}// NOTE (mristin):
828
+ {I}// We validate at the beginning so that we can avoid checks in
829
+ {I}// the instruction loops.
830
+ {I}for (size_t i = 0; i < program.size(); ++i) {{
831
+ {II}const Instruction& instruction = *program[i];
832
+
833
+ {II}switch (instruction.kind()) {{
834
+ {III}case InstructionKind::Jump: {{
835
+ {IIII}const auto& instruction_jump(
836
+ {IIIII}static_cast< // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
837
+ {IIIIII}const InstructionJump&
838
+ {IIIII}>(
839
+ {IIIIII}instruction
840
+ {IIIII})
841
+ {IIII});
842
+
843
+ {IIII}if (instruction_jump.target >= program.size()) {{
844
+ {IIIII}throw std::invalid_argument(
845
+ {IIIIII}common::Concat(
846
+ {IIIIIII}"Unexpected jump beyond the end of the program. Program has ",
847
+ {IIIIIII}std::to_string(program.size()),
848
+ {IIIIIII}" instruction(s), but the instruction ",
849
+ {IIIIIII}std::to_string(i),
850
+ {IIIIIII}" wants to jump to ",
851
+ {IIIIIII}std::to_string(instruction_jump.target)
852
+ {IIIIII})
853
+ {IIIII});
854
+ {IIII}}}
855
+ {IIII}break;
856
+ {III}}}
857
+
858
+ {III}case InstructionKind::Split: {{
859
+ {IIII}const auto& instruction_split(
860
+ {IIIII}static_cast< // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
861
+ {IIIIII}const InstructionSplit&
862
+ {IIIII}>(
863
+ {IIIIII}instruction
864
+ {IIIII})
865
+ {IIII});
866
+
867
+ {IIII}if (instruction_split.first_target >= program.size()) {{
868
+ {IIIII}throw std::invalid_argument(
869
+ {IIIIII}common::Concat(
870
+ {IIIIIII}"Unexpected split & jump beyond the end of the program. Program has ",
871
+ {IIIIIII}std::to_string(program.size()),
872
+ {IIIIIII}" instruction(s), but the instruction ",
873
+ {IIIIIII}std::to_string(i),
874
+ {IIIIIII}" wants to split and make the first jump to ",
875
+ {IIIIIII}std::to_string(instruction_split.first_target)
876
+ {IIIIII})
877
+ {IIIII});
878
+ {IIII}}}
879
+
880
+ {IIII}if (instruction_split.second_target >= program.size()) {{
881
+ {IIIII}throw std::invalid_argument(
882
+ {IIIIII}common::Concat(
883
+ {IIIIIII}"Unexpected split & jump beyond the end of the program. Program has ",
884
+ {IIIIIII}std::to_string(program.size()),
885
+ {IIIIIII}" instruction(s), but the instruction ",
886
+ {IIIIIII}std::to_string(i),
887
+ {IIIIIII}" wants to split and make the second jump to ",
888
+ {IIIIIII}std::to_string(instruction_split.second_target)
889
+ {IIIIII})
890
+ {IIIII});
891
+ {IIII}}}
892
+
893
+ {IIII}break;
894
+ {III}}}
895
+
896
+ {III}default:
897
+ {IIII}continue;
898
+ {II}}}
899
+ {I}}}
900
+
901
+ {I}// NOTE (mristin):
902
+ {I}// See: https://swtch.com/~rsc/regexp/regexp2.html,
903
+ {I}// Section "Thompson's Implementation".
904
+
905
+ {I}std::unique_ptr<ThreadList> clist(std::make_unique<ThreadList>(program.size()));
906
+ {I}std::unique_ptr<ThreadList> nlist(std::make_unique<ThreadList>(program.size()));
907
+
908
+ {I}clist->Spawn(0);
909
+
910
+ {I}for (const wchar_t character : text) {{
911
+ {II}#ifdef DEBUG
912
+ {II}if (!nlist->Empty()) {{
913
+ {III}throw std::logic_error(
914
+ {IIII}"Expected the list of next-to-be-executed threads to be empty, "
915
+ {IIII}"but it was not."
916
+ {III});
917
+ {II}}}
918
+ {II}#endif
919
+
920
+ {II}while (!clist->Empty()) {{
921
+ {III}const size_t program_counter = clist->Pop();
922
+
923
+ {III}#ifdef DEBUG
924
+ {III}if (program_counter >= program.size()) {{
925
+ {IIII}throw std::logic_error(
926
+ {IIIII}common::Concat(
927
+ {IIIIII}"Unexpected program counter beyond the program. The program size was ",
928
+ {IIIIII}std::to_string(program.size()),
929
+ {IIIIII}", while the program counter of a thread was ",
930
+ {IIIIII}std::to_string(program_counter)
931
+ {IIIII})
932
+ {IIII});
933
+ {III}}}
934
+ {III}#endif
935
+
936
+ {III}const Instruction& instruction = *program[program_counter];
937
+
938
+ {III}switch (instruction.kind()) {{
939
+ {IIII}case InstructionKind::Char: {{
940
+ {IIIII}const auto& instruction_char(
941
+ {IIIIII}static_cast< // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
942
+ {IIIIIII}const InstructionChar&
943
+ {IIIIII}>(instruction)
944
+ {IIIII});
945
+
946
+ {IIIII}if (character != instruction_char.character) {{
947
+ {IIIIII}// The matching failed for this thread.
948
+ {IIIIII}break;
949
+ {IIIII}}}
950
+
951
+ {IIIII}nlist->Spawn(program_counter + 1);
952
+ {IIIII}break;
953
+ {IIII}}}
954
+
955
+ {IIII}case InstructionKind::Set: {{
956
+ {IIIII}const auto& instruction_set(
957
+ {IIIIII}static_cast< // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
958
+ {IIIIIII}const InstructionSet&
959
+ {IIIIII}>(instruction)
960
+ {IIIII});
961
+
962
+ {IIIII}if (!CharacterInRanges(instruction_set.ranges, character)) {{
963
+ {IIIIII}// The matching failed for this thread.
964
+ {IIIIII}break;
965
+ {IIIII}}}
966
+
967
+ {IIIII}nlist->Spawn(program_counter + 1);
968
+ {IIIII}break;
969
+ {IIII}}}
970
+
971
+ {IIII}case InstructionKind::NotSet: {{
972
+ {IIIII}const auto& instruction_not_set(
973
+ {IIIIII}static_cast< // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
974
+ {IIIIIII}const InstructionNotSet&
975
+ {IIIIII}>(instruction)
976
+ {IIIII});
977
+
978
+ {IIIII}if (CharacterInRanges(instruction_not_set.ranges, character)) {{
979
+ {IIIIII}// The matching failed for this thread.
980
+ {IIIIII}break;
981
+ {IIIII}}}
982
+
983
+ {IIIII}nlist->Spawn(program_counter + 1);
984
+ {IIIII}break;
985
+ {IIII}}}
986
+
987
+ {IIII}case InstructionKind::Any: {{
988
+ {IIIII}// NOTE (mristin):
989
+ {IIIII}// We simply proceed to the next instruction at the next character without
990
+ {IIIII}// any checks.
991
+ {IIIII}nlist->Spawn(program_counter + 1);
992
+ {IIIII}break;
993
+ {IIII}}}
994
+
995
+ {IIII}case InstructionKind::Match:
996
+ {IIIII}return true;
997
+
998
+ {IIII}case InstructionKind::Jump: {{
999
+ {IIIII}const auto& instruction_jump(
1000
+ {IIIIII}static_cast< // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
1001
+ {IIIIIII}const InstructionJump&
1002
+ {IIIIII}>(instruction)
1003
+ {IIIII});
1004
+
1005
+ {IIIII}clist->Spawn(instruction_jump.target);
1006
+ {IIIII}break;
1007
+ {IIII}}}
1008
+
1009
+ {IIII}case InstructionKind::Split: {{
1010
+ {IIIII}const auto& instruction_split(
1011
+ {IIIIII}static_cast< // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
1012
+ {IIIIIII}const InstructionSplit&
1013
+ {IIIIII}>(instruction)
1014
+ {IIIII});
1015
+
1016
+ {IIIII}clist->Spawn(instruction_split.first_target);
1017
+ {IIIII}clist->Spawn(instruction_split.second_target);
1018
+ {IIIII}break;
1019
+ {IIII}}}
1020
+
1021
+ {IIII}case InstructionKind::End: {{
1022
+ {IIIII}// The matching failed for this thread as we have just consumed
1023
+ {IIIII}// a character.
1024
+ {IIIII}break;
1025
+ {IIII}}}
1026
+
1027
+ {IIII}default:
1028
+ {IIIII}throw std::logic_error(
1029
+ {IIIIII}common::Concat(
1030
+ {IIIIIII}"Unhandled instruction kind: ",
1031
+ {IIIIIII}std::to_string(
1032
+ {IIIIIIII}static_cast<std::uint8_t>(instruction.kind())
1033
+ {IIIIIII})
1034
+ {IIIIII})
1035
+ {IIIII});
1036
+ {III}}}
1037
+ {II}}}
1038
+
1039
+ {II}std::swap(clist, nlist);
1040
+ {II}nlist->Clear();
1041
+ {I}}}
1042
+
1043
+ {I}// NOTE (mristin):
1044
+ {I}// We need to process any pending jumps, splits and matches even tough there are
1045
+ {I}// no more characters to consume.
1046
+ {I}while (!clist->Empty()) {{
1047
+ {II}const size_t program_counter = clist->Pop();
1048
+
1049
+ {II}#ifdef DEBUG
1050
+ {II}if (program_counter >= program.size()) {{
1051
+ {III}throw std::logic_error(
1052
+ {IIII}common::Concat(
1053
+ {IIIII}"Unexpected program counter beyond the program. The program size was ",
1054
+ {IIIII}std::to_string(program.size()),
1055
+ {IIIII}", while the program counter of a thread was ",
1056
+ {IIIII}std::to_string(program_counter)
1057
+ {IIII})
1058
+ {III});
1059
+ {II}}}
1060
+ {II}#endif
1061
+
1062
+ {II}const Instruction& instruction = *program[program_counter];
1063
+
1064
+ {II}switch (instruction.kind()) {{
1065
+ {III}case InstructionKind::Char: {{ // NOLINT(bugprone-branch-clone)
1066
+ {IIII}// We reached the end-of-input so there are no characters to be matched.
1067
+ {IIII}// This thread needs therefore to die.
1068
+ {IIII}break;
1069
+ {III}}}
1070
+
1071
+ {III}case InstructionKind::Set: {{
1072
+ {IIII}// We reached the end-of-input so there are no character sets to be matched.
1073
+ {IIII}// This thread needs therefore to die.
1074
+ {IIII}break;
1075
+ {III}}}
1076
+
1077
+ {III}case InstructionKind::NotSet: {{
1078
+ {IIII}// We reached the end-of-input so there are no character sets to be matched.
1079
+ {IIII}// This thread needs therefore to die.
1080
+ {IIII}break;
1081
+ {III}}}
1082
+
1083
+ {III}case InstructionKind::Any: {{
1084
+ {IIII}// We reached the end-of-input so there are no characters to be matched.
1085
+ {IIII}// This thread needs therefore to die.
1086
+ {IIII}break;
1087
+ {III}}}
1088
+
1089
+ {III}case InstructionKind::Match:
1090
+ {IIII}return true;
1091
+
1092
+ {III}case InstructionKind::Jump: {{
1093
+ {IIII}const auto& instruction_jump(
1094
+ {IIIII}static_cast< // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
1095
+ {IIIIII}const InstructionJump&
1096
+ {IIIII}>(instruction)
1097
+ {IIII});
1098
+
1099
+ {IIII}clist->Spawn(instruction_jump.target);
1100
+ {IIII}break;
1101
+ {III}}}
1102
+
1103
+ {III}case InstructionKind::Split: {{
1104
+ {IIII}const auto& instruction_split(
1105
+ {IIIII}static_cast< // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
1106
+ {IIIIII}const InstructionSplit&
1107
+ {IIIII}>(instruction)
1108
+ {IIII});
1109
+
1110
+ {IIII}clist->Spawn(instruction_split.first_target);
1111
+ {IIII}clist->Spawn(instruction_split.second_target);
1112
+ {IIII}break;
1113
+ {III}}}
1114
+
1115
+ {III}case InstructionKind::End: {{
1116
+ {IIII}// We reached the end-of-input so we match and move to the next instruction.
1117
+ {IIII}clist->Spawn(program_counter + 1);
1118
+ {IIII}break;
1119
+ {III}}}
1120
+
1121
+ {III}default:
1122
+ {IIII}throw std::logic_error(
1123
+ {IIIII}common::Concat(
1124
+ {IIIIII}"Unhandled instruction kind: ",
1125
+ {IIIIII}std::to_string(
1126
+ {IIIIIII}static_cast<std::uint8_t>(instruction.kind())
1127
+ {IIIIII})
1128
+ {IIIII})
1129
+ {IIII});
1130
+ {II}}}
1131
+ {I}}}
1132
+
1133
+ {I}return false;
1134
+ }}"""
1135
+ ),
1136
+ cpp_common.generate_namespace_closing(namespace),
1137
+ cpp_common.WARNING,
1138
+ ]
1139
+
1140
+ writer = io.StringIO()
1141
+ for i, block in enumerate(blocks):
1142
+ if i > 0:
1143
+ writer.write("\n\n")
1144
+
1145
+ writer.write(block)
1146
+
1147
+ writer.write("\n")
1148
+
1149
+ return writer.getvalue()