longeron 0.2.0__tar.gz
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.
- longeron-0.2.0/LICENSE +201 -0
- longeron-0.2.0/PKG-INFO +449 -0
- longeron-0.2.0/README.md +419 -0
- longeron-0.2.0/pyproject.toml +178 -0
- longeron-0.2.0/setup.cfg +4 -0
- longeron-0.2.0/src/longeron.egg-info/PKG-INFO +449 -0
- longeron-0.2.0/src/longeron.egg-info/SOURCES.txt +104 -0
- longeron-0.2.0/src/longeron.egg-info/dependency_links.txt +1 -0
- longeron-0.2.0/src/longeron.egg-info/entry_points.txt +2 -0
- longeron-0.2.0/src/longeron.egg-info/requires.txt +19 -0
- longeron-0.2.0/src/longeron.egg-info/top_level.txt +1 -0
- longeron-0.2.0/src/sysml2/__init__.py +92 -0
- longeron-0.2.0/src/sysml2/_gen/__init__.py +0 -0
- longeron-0.2.0/src/sysml2/_gen/kerml/KerML.interp +609 -0
- longeron-0.2.0/src/sysml2/_gen/kerml/KerML.tokens +309 -0
- longeron-0.2.0/src/sysml2/_gen/kerml/KerMLLexer.interp +503 -0
- longeron-0.2.0/src/sysml2/_gen/kerml/KerMLLexer.py +789 -0
- longeron-0.2.0/src/sysml2/_gen/kerml/KerMLLexer.tokens +309 -0
- longeron-0.2.0/src/sysml2/_gen/kerml/KerMLParser.py +19156 -0
- longeron-0.2.0/src/sysml2/_gen/kerml/KerMLVisitor.py +1413 -0
- longeron-0.2.0/src/sysml2/_gen/kerml/__init__.py +0 -0
- longeron-0.2.0/src/sysml2/_gen/sysml/SysML.interp +813 -0
- longeron-0.2.0/src/sysml2/_gen/sysml/SysML.tokens +353 -0
- longeron-0.2.0/src/sysml2/_gen/sysml/SysMLLexer.interp +569 -0
- longeron-0.2.0/src/sysml2/_gen/sysml/SysMLLexer.py +877 -0
- longeron-0.2.0/src/sysml2/_gen/sysml/SysMLLexer.tokens +353 -0
- longeron-0.2.0/src/sysml2/_gen/sysml/SysMLParser.py +29964 -0
- longeron-0.2.0/src/sysml2/_gen/sysml/SysMLVisitor.py +2213 -0
- longeron-0.2.0/src/sysml2/_gen/sysml/__init__.py +0 -0
- longeron-0.2.0/src/sysml2/_js/elk.bundled.js +6696 -0
- longeron-0.2.0/src/sysml2/_spec/README.md +7 -0
- longeron-0.2.0/src/sysml2/_spec/SysML.ecore +5556 -0
- longeron-0.2.0/src/sysml2/_stdlib/KernelShim.sysml +65 -0
- longeron-0.2.0/src/sysml2/_stdlib/README.md +14 -0
- longeron-0.2.0/src/sysml2/_stdlib/prebuilt.json +38103 -0
- longeron-0.2.0/src/sysml2/_stdlib/quantities/ISQ.sysml +42 -0
- longeron-0.2.0/src/sysml2/_stdlib/quantities/ISQBase.sysml +206 -0
- longeron-0.2.0/src/sysml2/_stdlib/quantities/MeasurementRefCalculations.sysml +30 -0
- longeron-0.2.0/src/sysml2/_stdlib/quantities/MeasurementReferences.sysml +526 -0
- longeron-0.2.0/src/sysml2/_stdlib/quantities/Quantities.sysml +107 -0
- longeron-0.2.0/src/sysml2/_stdlib/quantities/QuantityCalculations.sysml +70 -0
- longeron-0.2.0/src/sysml2/_stdlib/quantities/SI.sysml +378 -0
- longeron-0.2.0/src/sysml2/_stdlib/quantities/SIPrefixes.sysml +48 -0
- longeron-0.2.0/src/sysml2/_stdlib/quantities/TensorCalculations.sysml +50 -0
- longeron-0.2.0/src/sysml2/_stdlib/quantities/Time.sysml +274 -0
- longeron-0.2.0/src/sysml2/_stdlib/quantities/VectorCalculations.sysml +62 -0
- longeron-0.2.0/src/sysml2/_stdlib/systems/Actions.sysml +557 -0
- longeron-0.2.0/src/sysml2/_stdlib/systems/Allocations.sysml +29 -0
- longeron-0.2.0/src/sysml2/_stdlib/systems/AnalysisCases.sysml +38 -0
- longeron-0.2.0/src/sysml2/_stdlib/systems/Attributes.sysml +25 -0
- longeron-0.2.0/src/sysml2/_stdlib/systems/Calculations.sysml +37 -0
- longeron-0.2.0/src/sysml2/_stdlib/systems/Cases.sysml +71 -0
- longeron-0.2.0/src/sysml2/_stdlib/systems/Connections.sysml +60 -0
- longeron-0.2.0/src/sysml2/_stdlib/systems/Constraints.sysml +44 -0
- longeron-0.2.0/src/sysml2/_stdlib/systems/Flows.sysml +126 -0
- longeron-0.2.0/src/sysml2/_stdlib/systems/Interfaces.sysml +89 -0
- longeron-0.2.0/src/sysml2/_stdlib/systems/Items.sysml +153 -0
- longeron-0.2.0/src/sysml2/_stdlib/systems/Metadata.sysml +32 -0
- longeron-0.2.0/src/sysml2/_stdlib/systems/Parts.sysml +81 -0
- longeron-0.2.0/src/sysml2/_stdlib/systems/Ports.sysml +54 -0
- longeron-0.2.0/src/sysml2/_stdlib/systems/Requirements.sysml +194 -0
- longeron-0.2.0/src/sysml2/_stdlib/systems/StandardViewDefinitions.sysml +123 -0
- longeron-0.2.0/src/sysml2/_stdlib/systems/States.sysml +103 -0
- longeron-0.2.0/src/sysml2/_stdlib/systems/SysML.sysml +539 -0
- longeron-0.2.0/src/sysml2/_stdlib/systems/UseCases.sysml +57 -0
- longeron-0.2.0/src/sysml2/_stdlib/systems/VerificationCases.sysml +103 -0
- longeron-0.2.0/src/sysml2/_stdlib/systems/Views.sysml +164 -0
- longeron-0.2.0/src/sysml2/api.py +149 -0
- longeron-0.2.0/src/sysml2/ast.py +504 -0
- longeron-0.2.0/src/sysml2/builder.py +2048 -0
- longeron-0.2.0/src/sysml2/cli.py +199 -0
- longeron-0.2.0/src/sysml2/diagrams.py +621 -0
- longeron-0.2.0/src/sysml2/ecore.py +378 -0
- longeron-0.2.0/src/sysml2/errors.py +47 -0
- longeron-0.2.0/src/sysml2/export.py +749 -0
- longeron-0.2.0/src/sysml2/importer.py +82 -0
- longeron-0.2.0/src/sysml2/interpreter.py +2122 -0
- longeron-0.2.0/src/sysml2/kerml.py +253 -0
- longeron-0.2.0/src/sysml2/model.py +529 -0
- longeron-0.2.0/src/sysml2/parser.py +94 -0
- longeron-0.2.0/src/sysml2/render.py +470 -0
- longeron-0.2.0/src/sysml2/replay.py +491 -0
- longeron-0.2.0/src/sysml2/stdlib.py +123 -0
- longeron-0.2.0/src/sysml2/validation.py +338 -0
- longeron-0.2.0/src/sysml2/workspace.py +199 -0
- longeron-0.2.0/tests/test_actions.py +145 -0
- longeron-0.2.0/tests/test_api_json.py +90 -0
- longeron-0.2.0/tests/test_builder.py +169 -0
- longeron-0.2.0/tests/test_diagrams.py +202 -0
- longeron-0.2.0/tests/test_ecore.py +145 -0
- longeron-0.2.0/tests/test_export.py +181 -0
- longeron-0.2.0/tests/test_expressions.py +124 -0
- longeron-0.2.0/tests/test_full_coverage.py +176 -0
- longeron-0.2.0/tests/test_git_hooks.py +168 -0
- longeron-0.2.0/tests/test_interpreter.py +161 -0
- longeron-0.2.0/tests/test_json_import.py +145 -0
- longeron-0.2.0/tests/test_kerml_export.py +81 -0
- longeron-0.2.0/tests/test_notebooks.py +54 -0
- longeron-0.2.0/tests/test_parsing.py +72 -0
- longeron-0.2.0/tests/test_render.py +158 -0
- longeron-0.2.0/tests/test_replay.py +254 -0
- longeron-0.2.0/tests/test_semantics.py +315 -0
- longeron-0.2.0/tests/test_states.py +115 -0
- longeron-0.2.0/tests/test_stdlib.py +149 -0
- longeron-0.2.0/tests/test_validation.py +314 -0
- longeron-0.2.0/tests/test_workspace.py +195 -0
longeron-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
longeron-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: longeron
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Define, execute, and replay SysML v2 models in Python: ANTLR-based parser, validator, interpreter, and diagram renderers
|
|
5
|
+
Author: sanbales
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/sanbales/longeron
|
|
8
|
+
Project-URL: Repository, https://github.com/sanbales/longeron
|
|
9
|
+
Keywords: sysml,sysml2,kerml,mbse,systems-engineering,modeling
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: antlr4-python3-runtime==4.13.2
|
|
14
|
+
Provides-Extra: dev
|
|
15
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
16
|
+
Requires-Dist: pytest-cov>=5; extra == "dev"
|
|
17
|
+
Requires-Dist: mypy>=1.11; extra == "dev"
|
|
18
|
+
Requires-Dist: ruff>=0.6; extra == "dev"
|
|
19
|
+
Requires-Dist: pyecore>=0.15; extra == "dev"
|
|
20
|
+
Requires-Dist: nbformat>=5; extra == "dev"
|
|
21
|
+
Requires-Dist: nbclient>=0.10; extra == "dev"
|
|
22
|
+
Requires-Dist: ipykernel>=6; extra == "dev"
|
|
23
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
|
|
24
|
+
Requires-Dist: anywidget>=0.9; extra == "dev"
|
|
25
|
+
Provides-Extra: ecore
|
|
26
|
+
Requires-Dist: pyecore>=0.15; extra == "ecore"
|
|
27
|
+
Provides-Extra: replay
|
|
28
|
+
Requires-Dist: anywidget>=0.9; extra == "replay"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# Longeron
|
|
32
|
+
|
|
33
|
+
*The spine of your system model* — a Python package that defines,
|
|
34
|
+
exports, imports, and **executes** SysML v2 models (import name:
|
|
35
|
+
`sysml2`). The parsers are generated with ANTLR 4 from combined grammars
|
|
36
|
+
for SysML v2 and KerML, taken from
|
|
37
|
+
[hivecore-dev/hcf-runtime](https://github.com/hivecore-dev/hcf-runtime)
|
|
38
|
+
(`SysML.g4`, `KerML.g4`, with local patches — see
|
|
39
|
+
[Grammar patches](#grammar-patches)).
|
|
40
|
+
|
|
41
|
+
> SysML® is a registered trademark of the Object Management Group. This
|
|
42
|
+
> project is not affiliated with or endorsed by OMG, and is not a
|
|
43
|
+
> conformance-certified implementation.
|
|
44
|
+
|
|
45
|
+
## Capabilities
|
|
46
|
+
|
|
47
|
+
| Verb | What you get |
|
|
48
|
+
|---|---|
|
|
49
|
+
| **Define** | Parse SysML v2 textual notation into a fully-typed Python object model, import a model from its JSON export, or build models programmatically from dataclasses. Multi-file workspaces merge under one root; a content-addressed cache makes warm loads ~1000x faster. |
|
|
50
|
+
| **Export** | Serialize any model to JSON, back to parseable SysML v2 text, project it onto KerML, or emit OMG Systems-Modeling-API JSON records. Parse → print → parse round-trips preserve the model; JSON → model → JSON is lossless. |
|
|
51
|
+
| **Validate** | `sysml2.validate()` / `sysml2 lint`: dangling references, expression-name typos, duplicate names, specialization cycles, state-machine problems. Names resolve against the vendored standard library (a bare `Real` passes with no import; a typo like `Reall` warns), and plain definitions carry their *implied* specializations (`part def` → `Parts::Part`, `action def` → `Actions::Action`, which is how `start`/`done` resolve); opt out with `stdlib=False` / `--no-stdlib`. |
|
|
52
|
+
| **Execute** | Evaluate expressions, run `calc` definitions, instantiate `part` definitions (against the bundled standard library if you opt in), check constraints and requirements, run `action` definitions with succession-driven control flow, and simulate hierarchical/parallel state machines with a clock. |
|
|
53
|
+
| **Visualize** | `sysml2.diagrams`: interactive ELK diagrams in JupyterLab (structure, state machines, action flow) with click-selection that resolves back to model elements. |
|
|
54
|
+
| **Full loop** | Read a model, execute it, snapshot the results back into the model as bound part usages, and save (`.sysml`, `.json`, or `.kerml`). |
|
|
55
|
+
|
|
56
|
+
The builder covers the full grammar: every construct the SysML grammar
|
|
57
|
+
accepts (interfaces, views, flows, allocations, metadata annotations,
|
|
58
|
+
satisfy/verify/frame, filtered imports, ...) maps to a model class — there
|
|
59
|
+
is no lossy fallback. KerML support is asymmetric by design:
|
|
60
|
+
`parse_kerml_text` validates KerML sources syntactically, and `to_kerml`
|
|
61
|
+
projects SysML models onto the kernel language.
|
|
62
|
+
|
|
63
|
+
## Installation
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
python -m venv .venv && source .venv/bin/activate
|
|
67
|
+
pip install -e ".[dev]"
|
|
68
|
+
make check # ruff + mypy + 310 tests
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Optional: `pip install -e ".[ecore]"` enables the OMG spec-metamodel
|
|
72
|
+
projection and API JSON (pyecore); `pre-commit install` wires ruff+mypy
|
|
73
|
+
into every commit.
|
|
74
|
+
|
|
75
|
+
### With pixi (optional)
|
|
76
|
+
|
|
77
|
+
The repo also carries `[tool.pixi]` config in `pyproject.toml` (dependency
|
|
78
|
+
truth stays in `[project]`; pixi adds the locked toolchain on top):
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
pixi run check # lint + mypy + tests in a locked environment
|
|
82
|
+
pixi run -e py310 test # any supported Python: py310 | py311 | py312 | py313
|
|
83
|
+
pixi run parsers # regenerate ANTLR parsers -- no manual Java setup:
|
|
84
|
+
# conda-forge's antlr 4.13.2 ships the tool + JDK
|
|
85
|
+
pixi run lab # JupyterLab in notebooks/ (vendored ipyelk extension
|
|
86
|
+
# pre-registered -- diagrams render interactively)
|
|
87
|
+
pixi run stdlib | demo | coverage | format | notebooks
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
CI runs entirely on pixi (`prefix-dev/setup-pixi`, cached by `pixi.lock`):
|
|
91
|
+
a `check` job (lint + mypy + coverage), a test matrix across the four
|
|
92
|
+
Python environments, and a grammar-regen job that fails if the committed
|
|
93
|
+
parsers drift from the `.g4` sources. The `parsers` task is
|
|
94
|
+
input/output-cached locally and produces byte-identical output.
|
|
95
|
+
|
|
96
|
+
The generated ANTLR parsers are committed under `src/sysml2/_gen/`, so no
|
|
97
|
+
Java toolchain is needed to install or use the package. Java is only needed
|
|
98
|
+
to regenerate the parsers after a grammar change:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# any Java 11+ works; for example: mamba create -n jdk openjdk
|
|
102
|
+
python scripts/generate_parsers.py
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Quick start
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
import sysml2
|
|
109
|
+
|
|
110
|
+
model = sysml2.loads("""
|
|
111
|
+
package Demo {
|
|
112
|
+
part def Vehicle {
|
|
113
|
+
attribute mass : Real = 1200.0;
|
|
114
|
+
attribute maxMass : Real = 2000.0;
|
|
115
|
+
part wheels : Wheel[4];
|
|
116
|
+
assert constraint massLimit { mass <= maxMass }
|
|
117
|
+
}
|
|
118
|
+
part def Wheel { attribute diameter : Real = 0.66; }
|
|
119
|
+
calc def Double { in x : Real; return : Real = 2.0 * x; }
|
|
120
|
+
}
|
|
121
|
+
""")
|
|
122
|
+
|
|
123
|
+
# --- export -------------------------------------------------------------
|
|
124
|
+
print(sysml2.to_sysml(model)) # regenerated textual notation
|
|
125
|
+
print(sysml2.to_json(model)) # structured JSON
|
|
126
|
+
|
|
127
|
+
# --- execute ------------------------------------------------------------
|
|
128
|
+
interp = sysml2.Interpreter(model)
|
|
129
|
+
|
|
130
|
+
interp.call("Demo::Double", 21.0) # -> 42.0
|
|
131
|
+
car = interp.instantiate("Demo::Vehicle") # attributes evaluated
|
|
132
|
+
car.get("wheels") # -> [Instance, ...] (4 wheels)
|
|
133
|
+
interp.check(car)[0].passed # -> True (mass <= maxMass)
|
|
134
|
+
interp.evaluate("(1, 2, 3)->select { in x; x > 1 }") # -> [2, 3]
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Actions and state machines:
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
model = sysml2.loads("""
|
|
141
|
+
package Ops {
|
|
142
|
+
action def Plan {
|
|
143
|
+
in distance : Real;
|
|
144
|
+
out fuel : Real;
|
|
145
|
+
assign fuel := distance * 0.08;
|
|
146
|
+
}
|
|
147
|
+
state def Machine {
|
|
148
|
+
entry; then off;
|
|
149
|
+
state off;
|
|
150
|
+
transition first off accept start then on;
|
|
151
|
+
state on;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
""")
|
|
155
|
+
interp = sysml2.Interpreter(model)
|
|
156
|
+
interp.run_action("Ops::Plan", inputs={"distance": 100.0}).outputs
|
|
157
|
+
# -> {'fuel': 8.0}
|
|
158
|
+
interp.simulate("Ops::Machine", events=["start"]).final_state
|
|
159
|
+
# -> 'on'
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
A complete walk-through lives in `examples/demo.py`, and five executable
|
|
163
|
+
tutorials live in [`notebooks/`](notebooks/):
|
|
164
|
+
|
|
165
|
+
| Notebook | Covers |
|
|
166
|
+
|---|---|
|
|
167
|
+
| `01_define_and_explore` | parsing, the object model, programmatic authoring, workspaces |
|
|
168
|
+
| `02_export_and_interchange` | SysML/JSON round-trips, save/load, KerML, spec metamodel, API JSON |
|
|
169
|
+
| `03_calculations_and_constraints` | expressions, calcs, instantiation, constraints, requirements, the full loop |
|
|
170
|
+
| `04_actions_and_states` | action graphs, hierarchical/parallel state machines, time |
|
|
171
|
+
| `05_stdlib_and_validation` | the vendored standard library, `sysml2 lint` |
|
|
172
|
+
| `06_interactive_diagrams` | ipyelk structure/state/action diagrams, click-selection |
|
|
173
|
+
|
|
174
|
+
The notebooks are executed by the test suite (`tests/test_notebooks.py`) and
|
|
175
|
+
can be refreshed with `pixi run notebooks`.
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
python examples/demo.py
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### The full loop: read → run → save
|
|
182
|
+
|
|
183
|
+
```python
|
|
184
|
+
model = sysml2.load("examples/drone.sysml")
|
|
185
|
+
interp = sysml2.Interpreter(model)
|
|
186
|
+
|
|
187
|
+
# run
|
|
188
|
+
flown = interp.instantiate("Drone::QuadCopter", payloadMass=0.35)
|
|
189
|
+
|
|
190
|
+
# write computed values back into the model as a bound part usage
|
|
191
|
+
model.find("Drone").add(interp.snapshot(flown, name="asFlown"))
|
|
192
|
+
|
|
193
|
+
# save in any format (inferred from the suffix)
|
|
194
|
+
sysml2.save(model, "drone_with_results.sysml")
|
|
195
|
+
sysml2.save(model, "drone_with_results.json")
|
|
196
|
+
sysml2.save(model, "drone_with_results.kerml")
|
|
197
|
+
|
|
198
|
+
# the JSON export is lossless: reload and keep executing
|
|
199
|
+
again = sysml2.load("drone_with_results.json")
|
|
200
|
+
sysml2.Interpreter(again).instantiate("Drone::QuadCopter")
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
SysML or KerML text can be generated from just the JSON definition:
|
|
204
|
+
|
|
205
|
+
```python
|
|
206
|
+
model = sysml2.from_json(json_text) # or sysml2.from_dict(data)
|
|
207
|
+
print(sysml2.to_sysml(model))
|
|
208
|
+
print(sysml2.to_kerml(model)) # kernel-language projection
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Multi-file projects and caching
|
|
212
|
+
|
|
213
|
+
`load()` accepts a single `.sysml` file, a `.json` export, or a directory:
|
|
214
|
+
|
|
215
|
+
```python
|
|
216
|
+
model = sysml2.load("models/") # every *.sysml file, merged
|
|
217
|
+
model = sysml2.load_many(["lib.sysml", "app.json"]) # explicit set
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Directory loads merge all files under one root namespace, so cross-file
|
|
221
|
+
imports (`private import Units::*;`) and qualified references resolve.
|
|
222
|
+
Files load in sorted path order for determinism.
|
|
223
|
+
|
|
224
|
+
Built models are cached (as JSON — the same lossless schema as `to_json`,
|
|
225
|
+
never pickles) in `~/.cache/sysml2` (override with `$SYSML2_CACHE_DIR`),
|
|
226
|
+
keyed by source content plus a fingerprint of the generated parser and
|
|
227
|
+
builder code — edits, grammar regeneration, and package upgrades invalidate
|
|
228
|
+
cleanly. Caching is on by default for directories, off for single files
|
|
229
|
+
(`cache=` overrides; `sysml2.clear_cache()` wipes it). Warm directory loads
|
|
230
|
+
are ~1000x faster than cold parses with the ANTLR Python runtime.
|
|
231
|
+
|
|
232
|
+
## Command line
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
sysml2 parse examples/drone.sysml # syntax check (file or dir)
|
|
236
|
+
sysml2 export examples/drone.sysml --format sysml # json | sysml | kerml
|
|
237
|
+
sysml2 export model.json --format sysml # JSON in, SysML out
|
|
238
|
+
sysml2 export models/ --format json # whole directory, merged
|
|
239
|
+
sysml2 calc examples/drone.sysml Drone::HoverTime capacity=5200
|
|
240
|
+
sysml2 check examples/drone.sysml Drone::QuadCopter payloadMass=0.9
|
|
241
|
+
sysml2 run examples/drone.sysml Drone::PlanBattery distanceKm=20
|
|
242
|
+
sysml2 simulate examples/drone.sysml Drone::FlightStates --events launch,airborne
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Every model-consuming command accepts `.sysml`, `.json`, or a directory;
|
|
246
|
+
`--no-cache` bypasses the model cache.
|
|
247
|
+
|
|
248
|
+
## Project layout
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
grammars/ SysML.g4 + KerML.g4 (upstream + local patches)
|
|
252
|
+
scripts/generate_parsers.py regenerate src/sysml2/_gen from the grammars
|
|
253
|
+
src/sysml2/
|
|
254
|
+
_gen/ generated ANTLR lexers/parsers (committed)
|
|
255
|
+
parser.py text -> parse tree, error collection
|
|
256
|
+
builder.py parse tree -> model (the SysML front-end)
|
|
257
|
+
model.py model element dataclasses (Literal-typed vocabularies)
|
|
258
|
+
ast.py expression AST + precedence-aware printer
|
|
259
|
+
export.py model -> JSON / SysML text, save()
|
|
260
|
+
importer.py JSON -> model (lossless round-trip)
|
|
261
|
+
workspace.py multi-file loading + content-addressed model cache
|
|
262
|
+
kerml.py model -> KerML projection
|
|
263
|
+
validation.py sysml2 lint / validate()
|
|
264
|
+
stdlib.py + _stdlib/ vendored OMG standard library (+ prebuilt pickle)
|
|
265
|
+
ecore.py + _spec/ projection onto the OMG spec metamodel (pyecore)
|
|
266
|
+
api.py OMG Systems Modeling API JSON interchange
|
|
267
|
+
diagrams.py interactive ELK diagrams (ipyelk)
|
|
268
|
+
render.py + _js/ headless SVG/PNG export (vendored elkjs via node)
|
|
269
|
+
vendor/ipyelk/ vendored ipyelk 2.1.1 + local fixes (editable)
|
|
270
|
+
interpreter.py evaluation, instantiation, actions, states, snapshot
|
|
271
|
+
cli.py the `sysml2` console command
|
|
272
|
+
examples/ drone.sysml + kernel.kerml + demo.py
|
|
273
|
+
tests/ 310 pytest tests (84% coverage)
|
|
274
|
+
.github/workflows/ci.yml pixi-based: check + test matrix (3.10-3.13)
|
|
275
|
+
+ grammar-regen drift check (antlr/JDK from lock)
|
|
276
|
+
Makefile make check = ruff + mypy + pytest (venv/pip route)
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### How a model flows through the package
|
|
280
|
+
|
|
281
|
+
1. `parser.py` runs the generated ANTLR parser and collects syntax errors.
|
|
282
|
+
2. `builder.py` walks the parse tree and produces `model.py` dataclasses.
|
|
283
|
+
Expressions become compact AST nodes (`ast.py`), not parse-tree references.
|
|
284
|
+
3. `export.py` renders the model to JSON or textual notation; `importer.py`
|
|
285
|
+
reads the JSON back; `kerml.py` projects onto KerML.
|
|
286
|
+
4. `interpreter.py` resolves qualified names (imports, aliases,
|
|
287
|
+
specialization) and executes the model; `snapshot` converts runtime
|
|
288
|
+
instances back into model elements.
|
|
289
|
+
|
|
290
|
+
## Code quality
|
|
291
|
+
|
|
292
|
+
- **Typing**: modern PEP 585/604 annotations throughout; closed string
|
|
293
|
+
vocabularies (`kind`, `direction`, `visibility`, operators, ...) are
|
|
294
|
+
`typing.Literal` aliases (`model.UsageKind`, `ast.BinaryOp`, ...).
|
|
295
|
+
`mypy` runs clean over `src/sysml2` (generated code excluded).
|
|
296
|
+
- **Linting**: `ruff` with `E, W, F, I, UP, B, C4, RUF` rules.
|
|
297
|
+
- `make check` runs ruff + mypy + the full test suite.
|
|
298
|
+
|
|
299
|
+
## Execution semantics (and their limits)
|
|
300
|
+
|
|
301
|
+
This is a modeling sandbox, not a full KerML semantic engine. What executes:
|
|
302
|
+
|
|
303
|
+
- **Actions**: bodies without successions run in declaration order. Bodies
|
|
304
|
+
with explicit successions (`first start then a; first a then b;`) run as
|
|
305
|
+
a control-flow graph: unreachable steps do not execute, `decide` nodes
|
|
306
|
+
choose the first satisfied guard (with `else` fallback), guarded loops
|
|
307
|
+
back-edge, and `fork`/`join` branches run sequentially in declaration
|
|
308
|
+
order (no interleaving). `accept after d` / `accept at t` advance the
|
|
309
|
+
action's clock (`ActionResult.time`); `accept when c` raises on a false
|
|
310
|
+
condition (a would-be deadlock).
|
|
311
|
+
- **State machines** are hierarchical: composite states enter through their
|
|
312
|
+
own `entry; then S;` transition, inner states get the first chance to
|
|
313
|
+
consume an event, and exits cascade innermost-first. `parallel` states
|
|
314
|
+
activate all child regions concurrently (`SimulationResult.active_states`).
|
|
315
|
+
Time triggers (`accept after`/`accept at`) fire when a plain number in the
|
|
316
|
+
event list advances the simulation clock; `accept when c` transitions fire
|
|
317
|
+
as soon as their condition holds.
|
|
318
|
+
- Quantities evaluate to their magnitude: `10 [SI::m]` evaluates to `10`.
|
|
319
|
+
- **Standard library**: a curated subset of the official model library ships
|
|
320
|
+
with the package (all 21 Systems Library files + core Quantities/Units +
|
|
321
|
+
a KerML-kernel shim; see `sysml2/_stdlib/README.md`). Opt in with
|
|
322
|
+
`sysml2.add_standard_library(model)` or `--stdlib` on the CLI: library
|
|
323
|
+
types resolve (`Parts::Part`, `ISQ::mass`, `SI::kg`), `public import`
|
|
324
|
+
re-exports and aliases follow, and `istype` checks work against library
|
|
325
|
+
definitions. A bundled prebuilt pickle makes loading instant; the KerML
|
|
326
|
+
Kernel Libraries themselves are not loaded (KerML is parse-only), so
|
|
327
|
+
inherited library defaults that need unimplemented kernel functions
|
|
328
|
+
degrade to `None` instead of failing. The prebuilt ships as plain JSON
|
|
329
|
+
(`_stdlib/prebuilt.json`) — inspectable text, no pickles anywhere.
|
|
330
|
+
- Multiplicity expansion: exact bounds (`[4]`) expand fully; ranges
|
|
331
|
+
populate their lower bound (`[0..*]` gives an empty list), which keeps
|
|
332
|
+
the library's self-referential compositions finite.
|
|
333
|
+
|
|
334
|
+
## Interactive diagrams
|
|
335
|
+
|
|
336
|
+
`sysml2.diagrams` renders models as interactive ELK diagrams in JupyterLab
|
|
337
|
+
(see `notebooks/06_interactive_diagrams.ipynb`):
|
|
338
|
+
|
|
339
|
+
```python
|
|
340
|
+
from sysml2 import diagrams
|
|
341
|
+
|
|
342
|
+
diagrams.structure_diagram(model) # defs, compartments, edges
|
|
343
|
+
diagrams.state_diagram(model.find("P::Machine")) # hierarchical states
|
|
344
|
+
diagrams.action_diagram(model.find("P::Flow")) # the executed succession graph
|
|
345
|
+
diagrams.diagram(element) # dispatch by kind
|
|
346
|
+
|
|
347
|
+
diagrams.on_select(widget, model, callback) # clicks -> model elements
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
Node ids are qualified names, so browser selections resolve straight back to
|
|
351
|
+
model elements. Layout runs in the browser (elkjs), so diagrams also build
|
|
352
|
+
headlessly (tests, nbclient).
|
|
353
|
+
|
|
354
|
+
The same views export to images without a browser — `sysml2.render` runs
|
|
355
|
+
the vendored elkjs (0.9.3, EPL-2.0, `sysml2/_js/`) in a node subprocess and
|
|
356
|
+
draws styled SVG, with PNG via cairosvg (node + cairo ship in the pixi
|
|
357
|
+
environments):
|
|
358
|
+
|
|
359
|
+
```python
|
|
360
|
+
from sysml2 import render
|
|
361
|
+
|
|
362
|
+
render.to_svg(diagrams.state_diagram(machine), "machine.svg")
|
|
363
|
+
render.to_png(model, "model.png") # builds a view automatically
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
State-machine simulations replay over that same diagram: `sysml2.replay`
|
|
367
|
+
records a simulation (the `Interpreter.simulate` event protocol -- names
|
|
368
|
+
send events, numbers advance the clock) and animates it in the notebook
|
|
369
|
+
with play/pause, speed, and scrubbing. Active states light up green and
|
|
370
|
+
fired transitions pulse orange. Needs the `replay` extra
|
|
371
|
+
(`pip install "longeron[replay]"`, anywidget):
|
|
372
|
+
|
|
373
|
+
```python
|
|
374
|
+
from sysml2 import replay
|
|
375
|
+
|
|
376
|
+
replay.replay_widget(interp, "Machines::Player",
|
|
377
|
+
events=["play", 3600.0, "play"])
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
ipyelk is **vendored** (`vendor/ipyelk`, BSD-3-Clause, tag v2.1.1) and
|
|
381
|
+
installed editable (`pip install -e vendor/ipyelk`; pixi does this
|
|
382
|
+
automatically) so it can be patched as needed. Current local fixes, all
|
|
383
|
+
marked `LOCAL PATCH` and tracked by `git log -- vendor/ipyelk`:
|
|
384
|
+
|
|
385
|
+
1. **Headless-safe scheduling** — `Pipe.schedule_run` raised
|
|
386
|
+
`RuntimeError: no running event loop` outside Jupyter (plain scripts,
|
|
387
|
+
pytest); it now no-ops cleanly when there is no frontend to lay out for.
|
|
388
|
+
2. **Prebuilt labextension grafted** — the git tree only carries TypeScript
|
|
389
|
+
sources; the built JupyterLab extension from the 2.1.1 wheel is vendored
|
|
390
|
+
under `src/_d/` so the editable install renders without a node toolchain.
|
|
391
|
+
|
|
392
|
+
## Spec-metamodel projection and API interchange
|
|
393
|
+
|
|
394
|
+
With the `ecore` extra installed, models project onto the OMG abstract
|
|
395
|
+
syntax (the pilot implementation's `SysML.ecore`, 175 metaclasses, vendored
|
|
396
|
+
under `sysml2/_spec/`):
|
|
397
|
+
|
|
398
|
+
```python
|
|
399
|
+
from sysml2 import ecore, api
|
|
400
|
+
|
|
401
|
+
spec = ecore.to_spec(model) # reified memberships, FeatureTyping, ...
|
|
402
|
+
spec.report # what was covered / skipped
|
|
403
|
+
spec.save_xmi("model.xmi") # EMF XMI
|
|
404
|
+
|
|
405
|
+
api.to_api_json(model) # OMG Systems Modeling API records
|
|
406
|
+
api.from_api_json(text) # records -> spec instances
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
Both are structural prototypes: names, flags, ownership, and
|
|
410
|
+
specialization/typing relationships are mapped; expression trees are not
|
|
411
|
+
(counted in `SpecReport`, never silently dropped).
|
|
412
|
+
|
|
413
|
+
## Grammar patches
|
|
414
|
+
|
|
415
|
+
Deviations from the upstream grammars, each marked with a ``LOCAL PATCH``
|
|
416
|
+
comment in the `.g4` files:
|
|
417
|
+
|
|
418
|
+
1. **`import` visibility (SysML.g4).** Upstream required a visibility
|
|
419
|
+
keyword before every `import`, which rejects the spec's own examples
|
|
420
|
+
(`import ScalarValues::*;`). Aligned with KerML.g4's optional prefix.
|
|
421
|
+
2. **Entry transitions (SysML.g4).** Upstream required `entry; then then S;`
|
|
422
|
+
because `targetSuccession` already contains `then`. The patch accepts the
|
|
423
|
+
spec form `entry; then S;`.
|
|
424
|
+
3. **Unary operator precedence (both grammars).** Upstream parsed `-3 + 1`
|
|
425
|
+
as `-(3 + 1)` because the unary alternative sat below the binary
|
|
426
|
+
alternatives with a non-rightmost recursion. The patch moves unary above
|
|
427
|
+
the binary operators, so `-3 + 1` is `(-3) + 1`.
|
|
428
|
+
4. **`@` vs `at` (SysML.g4, four sites).** In SysML, `AT` is the keyword
|
|
429
|
+
`at` (trigger times) and the `@` symbol is `AT_SIGN`; upstream used `AT`
|
|
430
|
+
in the metadata and classification rules copied from KerML (where `AT`
|
|
431
|
+
itself is `'@'`). Upstream therefore required `at Safety` instead of
|
|
432
|
+
`@Safety`, and `x at T` instead of `x @ T`.
|
|
433
|
+
5. **Flow ends (SysML.g4).** `flowEndSubsetting` dropped the spec's `'.'`
|
|
434
|
+
after `QualifiedName`, so `flow from a.out to b.in` could not parse.
|
|
435
|
+
|
|
436
|
+
One known deviation from the OMG spec remains, inherited from upstream: the
|
|
437
|
+
grammar groups `??`/`or`/`and`/`implies` at one precedence level and
|
|
438
|
+
`|`/`&`/`xor` at another, and `**` is left-associative. Parenthesize when in
|
|
439
|
+
doubt; the exporter always prints round-trip-safe parentheses.
|
|
440
|
+
|
|
441
|
+
## Regenerating the parsers
|
|
442
|
+
|
|
443
|
+
```bash
|
|
444
|
+
python scripts/generate_parsers.py
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
The script finds Java via `JAVA_HOME`, `PATH`, or a conda/mamba env, and the
|
|
448
|
+
ANTLR 4.13.2 jar via `ANTLR_JAR`, `~/.m2`, or Maven Central. Regenerate
|
|
449
|
+
whenever a `.g4` file changes, then run `pytest`.
|