longeron 0.2.0__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 (80) hide show
  1. longeron-0.2.0.dist-info/METADATA +449 -0
  2. longeron-0.2.0.dist-info/RECORD +80 -0
  3. longeron-0.2.0.dist-info/WHEEL +5 -0
  4. longeron-0.2.0.dist-info/entry_points.txt +2 -0
  5. longeron-0.2.0.dist-info/licenses/LICENSE +201 -0
  6. longeron-0.2.0.dist-info/top_level.txt +1 -0
  7. sysml2/__init__.py +92 -0
  8. sysml2/_gen/__init__.py +0 -0
  9. sysml2/_gen/kerml/KerML.interp +609 -0
  10. sysml2/_gen/kerml/KerML.tokens +309 -0
  11. sysml2/_gen/kerml/KerMLLexer.interp +503 -0
  12. sysml2/_gen/kerml/KerMLLexer.py +789 -0
  13. sysml2/_gen/kerml/KerMLLexer.tokens +309 -0
  14. sysml2/_gen/kerml/KerMLParser.py +19156 -0
  15. sysml2/_gen/kerml/KerMLVisitor.py +1413 -0
  16. sysml2/_gen/kerml/__init__.py +0 -0
  17. sysml2/_gen/sysml/SysML.interp +813 -0
  18. sysml2/_gen/sysml/SysML.tokens +353 -0
  19. sysml2/_gen/sysml/SysMLLexer.interp +569 -0
  20. sysml2/_gen/sysml/SysMLLexer.py +877 -0
  21. sysml2/_gen/sysml/SysMLLexer.tokens +353 -0
  22. sysml2/_gen/sysml/SysMLParser.py +29964 -0
  23. sysml2/_gen/sysml/SysMLVisitor.py +2213 -0
  24. sysml2/_gen/sysml/__init__.py +0 -0
  25. sysml2/_js/elk.bundled.js +6696 -0
  26. sysml2/_spec/README.md +7 -0
  27. sysml2/_spec/SysML.ecore +5556 -0
  28. sysml2/_stdlib/KernelShim.sysml +65 -0
  29. sysml2/_stdlib/README.md +14 -0
  30. sysml2/_stdlib/prebuilt.json +38103 -0
  31. sysml2/_stdlib/quantities/ISQ.sysml +42 -0
  32. sysml2/_stdlib/quantities/ISQBase.sysml +206 -0
  33. sysml2/_stdlib/quantities/MeasurementRefCalculations.sysml +30 -0
  34. sysml2/_stdlib/quantities/MeasurementReferences.sysml +526 -0
  35. sysml2/_stdlib/quantities/Quantities.sysml +107 -0
  36. sysml2/_stdlib/quantities/QuantityCalculations.sysml +70 -0
  37. sysml2/_stdlib/quantities/SI.sysml +378 -0
  38. sysml2/_stdlib/quantities/SIPrefixes.sysml +48 -0
  39. sysml2/_stdlib/quantities/TensorCalculations.sysml +50 -0
  40. sysml2/_stdlib/quantities/Time.sysml +274 -0
  41. sysml2/_stdlib/quantities/VectorCalculations.sysml +62 -0
  42. sysml2/_stdlib/systems/Actions.sysml +557 -0
  43. sysml2/_stdlib/systems/Allocations.sysml +29 -0
  44. sysml2/_stdlib/systems/AnalysisCases.sysml +38 -0
  45. sysml2/_stdlib/systems/Attributes.sysml +25 -0
  46. sysml2/_stdlib/systems/Calculations.sysml +37 -0
  47. sysml2/_stdlib/systems/Cases.sysml +71 -0
  48. sysml2/_stdlib/systems/Connections.sysml +60 -0
  49. sysml2/_stdlib/systems/Constraints.sysml +44 -0
  50. sysml2/_stdlib/systems/Flows.sysml +126 -0
  51. sysml2/_stdlib/systems/Interfaces.sysml +89 -0
  52. sysml2/_stdlib/systems/Items.sysml +153 -0
  53. sysml2/_stdlib/systems/Metadata.sysml +32 -0
  54. sysml2/_stdlib/systems/Parts.sysml +81 -0
  55. sysml2/_stdlib/systems/Ports.sysml +54 -0
  56. sysml2/_stdlib/systems/Requirements.sysml +194 -0
  57. sysml2/_stdlib/systems/StandardViewDefinitions.sysml +123 -0
  58. sysml2/_stdlib/systems/States.sysml +103 -0
  59. sysml2/_stdlib/systems/SysML.sysml +539 -0
  60. sysml2/_stdlib/systems/UseCases.sysml +57 -0
  61. sysml2/_stdlib/systems/VerificationCases.sysml +103 -0
  62. sysml2/_stdlib/systems/Views.sysml +164 -0
  63. sysml2/api.py +149 -0
  64. sysml2/ast.py +504 -0
  65. sysml2/builder.py +2048 -0
  66. sysml2/cli.py +199 -0
  67. sysml2/diagrams.py +621 -0
  68. sysml2/ecore.py +378 -0
  69. sysml2/errors.py +47 -0
  70. sysml2/export.py +749 -0
  71. sysml2/importer.py +82 -0
  72. sysml2/interpreter.py +2122 -0
  73. sysml2/kerml.py +253 -0
  74. sysml2/model.py +529 -0
  75. sysml2/parser.py +94 -0
  76. sysml2/render.py +470 -0
  77. sysml2/replay.py +491 -0
  78. sysml2/stdlib.py +123 -0
  79. sysml2/validation.py +338 -0
  80. sysml2/workspace.py +199 -0
@@ -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`.
@@ -0,0 +1,80 @@
1
+ longeron-0.2.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
2
+ sysml2/__init__.py,sha256=Oeys_uj3h9wqtoKL1Pj3fdtM70mx-5sqcmC50Dmcfa8,2903
3
+ sysml2/api.py,sha256=aV0jFTo9fdJ-ZG13mDbKK8lumzqWNvaABXbKVNMPwbo,5397
4
+ sysml2/ast.py,sha256=r4PofNGYimw_q4tZJNe_IbqyFLehHBW5O9rXbp0ORR8,15208
5
+ sysml2/builder.py,sha256=Cg2mrLlxgyBhAFGfy6p9oa_BuQ93UG2sVtSiNQAAKHU,98945
6
+ sysml2/cli.py,sha256=EUgp_OMd3tG0NKTblF7ieUVvp0mGI8-2SI-KfEWypHw,7442
7
+ sysml2/diagrams.py,sha256=O3ymnM_uDdZ__I6Z4cisAi5MHxnVy9Z0OD0fWNUFzIA,26370
8
+ sysml2/ecore.py,sha256=_W_RQLnVDlU8CTh6wXyE0Q_VU0_on3diozFMTmjomuo,16577
9
+ sysml2/errors.py,sha256=VloCcKgPsfo4oIyIPo5Eu6hlYeA5C4vbYvdBQ58oE9c,1251
10
+ sysml2/export.py,sha256=5D2p9Afjd_IPufWBNKm62tL_i175TjXY1UMFuHqGHyc,28375
11
+ sysml2/importer.py,sha256=ndo307D9O3ZAt2mUyeR-phxGaxi_8o25xrhy-GqJDHk,2612
12
+ sysml2/interpreter.py,sha256=1w-2zbnfJhibEIciIV0dPk6reFa-yKmBLc317RhYTHM,88510
13
+ sysml2/kerml.py,sha256=dE2czUo8lZC1fnSPhwmLwGNd85__vkZ9VMauH0HVYIQ,9533
14
+ sysml2/model.py,sha256=LaL5BAt9omLGplBNd8jfpAiRHemcH1lCRYpbYFqq4o8,15765
15
+ sysml2/parser.py,sha256=FNEgy9jTdi-top-giRAnZVs5qBWD_lLn26XmYr7cKiQ,3451
16
+ sysml2/render.py,sha256=D9C5OxLCbyv7ZH5RFqRlOQXge2WprsNDUovpuziWbpw,19962
17
+ sysml2/replay.py,sha256=kzdEB-HBaw2aqpR3yNb28inYWke1EDY2wv-RhikvPRg,18552
18
+ sysml2/stdlib.py,sha256=uJQnJgIIYPd30H8UavKbS_owGFUyJeI4qRpUdJzOxlo,4087
19
+ sysml2/validation.py,sha256=C4eI7sFZ-4GWp9LOfTNX5BymLUGwktBQzGpbyE0nUSE,14770
20
+ sysml2/workspace.py,sha256=8s6SiK88h0Z-FB8CB3ocIhlwXZ3u7l19mMVQ9-WaAMw,6629
21
+ sysml2/_gen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
+ sysml2/_gen/kerml/KerML.interp,sha256=311dnbltqNFByAZ3pAYy6EOd7uXSJX-Yoo-EH1qxtGg,88296
23
+ sysml2/_gen/kerml/KerML.tokens,sha256=sWboUUa4Fiuvb-hCI0ZS777dObqxjtJtu-DhpX84tVY,3540
24
+ sysml2/_gen/kerml/KerMLLexer.interp,sha256=5pE5hyI8mHI7m-mdWC2OQ8aTC-gXWaoFViFlqGrHqpY,48360
25
+ sysml2/_gen/kerml/KerMLLexer.py,sha256=qZ2AgOI2rn7421K2cCQ22TXn1odC8GpHFID7AncoRWM,47683
26
+ sysml2/_gen/kerml/KerMLLexer.tokens,sha256=sWboUUa4Fiuvb-hCI0ZS777dObqxjtJtu-DhpX84tVY,3540
27
+ sysml2/_gen/kerml/KerMLParser.py,sha256=-E0Dqrzv7vpNNJSk_F7p4ExZBJmNmNAOtan1tCI7Wi4,665151
28
+ sysml2/_gen/kerml/KerMLVisitor.py,sha256=asbiL6kCSkueJrt4SH-539mLmYamTP8ynA2rY_8JVAM,52862
29
+ sysml2/_gen/kerml/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
+ sysml2/_gen/sysml/SysML.interp,sha256=4Sj2b19JAFOpoBnqscQQrmYser6SJO5Z8RunXuydXVY,140415
31
+ sysml2/_gen/sysml/SysML.tokens,sha256=P5BMXwYuzLnU5wDQsrQ_PNYa9aR1s8_jJXJD3aUEbPQ,3965
32
+ sysml2/_gen/sysml/SysMLLexer.interp,sha256=Mp28YhTZPvNNSl1XgZ-rpj8j3aZDKo6NKz8mg_J7Iiw,53702
33
+ sysml2/_gen/sysml/SysMLLexer.py,sha256=u7XGBpj3KxOETDIXMxq65cIsouBzuRjMq6hW7OLdmrA,53000
34
+ sysml2/_gen/sysml/SysMLLexer.tokens,sha256=P5BMXwYuzLnU5wDQsrQ_PNYa9aR1s8_jJXJD3aUEbPQ,3965
35
+ sysml2/_gen/sysml/SysMLParser.py,sha256=j5zylGJV84zjMEIOKbKDvtl-uiw1vcd36Jn9qdZfwBU,1044082
36
+ sysml2/_gen/sysml/SysMLVisitor.py,sha256=WdXf1tv_ifMwxruCH-WCIle8-3GCHaZIorKOiSoxGzM,84464
37
+ sysml2/_gen/sysml/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
+ sysml2/_js/elk.bundled.js,sha256=sHRavX8jzZFpChWH43ftvhn9cjPHgzACkJNnIFRiFtQ,1606238
39
+ sysml2/_spec/README.md,sha256=cP-IIVpQ6w1npvxBSW7PxmluWbQb1IIY8V89vqI3nYs,401
40
+ sysml2/_spec/SysML.ecore,sha256=3Tlg4KADHQdK2wEWLZt-xlUbLnqh2Ssmtveg6kW0ZNY,624054
41
+ sysml2/_stdlib/KernelShim.sysml,sha256=F8cxWkwoOrk6Jla227j1jdt-bsS-A7spMEbmE7_jbTM,2120
42
+ sysml2/_stdlib/README.md,sha256=VcfpbIaVY_VaMBhDwk-e_1J7tBeHpSUEOfMGZQqR0Bw,682
43
+ sysml2/_stdlib/prebuilt.json,sha256=khz4RMbuV6bbTwzR8I2DC3PprbSqHFv4oZC10Yu4NWs,889703
44
+ sysml2/_stdlib/quantities/ISQ.sysml,sha256=ERSi81VudXZ2do0F3i-_ixgE_eWJLWjJduER24ERf9o,2096
45
+ sysml2/_stdlib/quantities/ISQBase.sysml,sha256=zF3HMNKnFn6RRDGm8S0DGPeSpcbiogSjffmrM_XphDU,12219
46
+ sysml2/_stdlib/quantities/MeasurementRefCalculations.sysml,sha256=UeFdOJ84Nt83gvh9ZFCh1qisCN_Zos_d7zOK5W3WiNw,1600
47
+ sysml2/_stdlib/quantities/MeasurementReferences.sysml,sha256=MtJbE-lkh_dxspOrjpyoKjnM2NplU9lEkAujtQAyO7g,21401
48
+ sysml2/_stdlib/quantities/Quantities.sysml,sha256=blllP-Q55yH3B-ALwl84Q7SXMYAZTq9dgmt-KDYAzUU,4580
49
+ sysml2/_stdlib/quantities/QuantityCalculations.sysml,sha256=ZOUzyXjLc7KfAxXlE69J965IjBqjxxLL-UQ9ngfQCbQ,4218
50
+ sysml2/_stdlib/quantities/SI.sysml,sha256=j6UzNQZWrEL5zj6aQGjsElHVTgdK8IEJza_EesCyQog,30924
51
+ sysml2/_stdlib/quantities/SIPrefixes.sysml,sha256=kOYE_NpA-OySARSkVwl8sv7W2JjUIsgCd7TI6cPnBjg,3400
52
+ sysml2/_stdlib/quantities/TensorCalculations.sysml,sha256=vVimg1hPpyUlbUaHyfbrUsCfoX6mXjDYTBMT3hd3uAw,2446
53
+ sysml2/_stdlib/quantities/Time.sysml,sha256=HrAgM0Y8dA01cF0Dot19ZGhtiMEQ7Xow7wHgK9stykc,10429
54
+ sysml2/_stdlib/quantities/VectorCalculations.sysml,sha256=HPAfTLyw0mtEPNnv2SdiJPNbjhjRjzdB27rOjNHyV74,3057
55
+ sysml2/_stdlib/systems/Actions.sysml,sha256=r7F7R-oSKL70HveRuk_0JTxIpEWJ5_1JeLHXeT6k_3c,14971
56
+ sysml2/_stdlib/systems/Allocations.sysml,sha256=CtkApMJdiOuW2j1X42X2w4zYcBm8qsWrke7pUjtfDtE,788
57
+ sysml2/_stdlib/systems/AnalysisCases.sysml,sha256=K7iPYRePLO_VRBYA0tmA7R4aT_xct7PKkgft7lw1D4c,1038
58
+ sysml2/_stdlib/systems/Attributes.sysml,sha256=D_mwrMPwp71o_v5rEQ6RNvGRHQxIN0GATDuMoH9fU40,626
59
+ sysml2/_stdlib/systems/Calculations.sysml,sha256=GfXCrFU8CgNFUCkt5r-mAeaUj8gdWveBtZyUDu4uX3I,990
60
+ sysml2/_stdlib/systems/Cases.sysml,sha256=LEwMuqpGb59yC6aa86AZUXygp3QaVh94gABrrpRr8k8,1619
61
+ sysml2/_stdlib/systems/Connections.sysml,sha256=cwO2jUbuMRXibvvSLSCWQM0PgacbTA8PRvARARFTscY,2133
62
+ sysml2/_stdlib/systems/Constraints.sysml,sha256=hN1lmEq9DDXDe3XvV2a_pjyDaqdaHHWp0-tfQjD6j90,1263
63
+ sysml2/_stdlib/systems/Flows.sysml,sha256=GRp0EDbN_93vMQ2Ku_EM9iJyTKg30-M5U9-VZkiQ3kE,4766
64
+ sysml2/_stdlib/systems/Interfaces.sysml,sha256=YrXDwrw5YOjSVjMjHDkzqB5CKzqQTclUG4eHET0HbGY,3467
65
+ sysml2/_stdlib/systems/Items.sysml,sha256=WjssLS6zEEGGpeIAxAZH0deYaFpi2wMBzkyjYWUQFbc,4121
66
+ sysml2/_stdlib/systems/Metadata.sysml,sha256=yGpoobf48z8ofYEngNJEYCGu77MoTyi5wQ3-KxoT3tY,884
67
+ sysml2/_stdlib/systems/Parts.sysml,sha256=oiuSanu9zaIBSSAKYf1ByfHjkkyJKe99aNtSn7jnv1E,1882
68
+ sysml2/_stdlib/systems/Ports.sysml,sha256=_r1mF8O7nQ-Tx3ciuYh02JtJc_e5PuiFCQl7LoC8aZU,1594
69
+ sysml2/_stdlib/systems/Requirements.sysml,sha256=xDao_ilZs4DuPYrnwcIGMRqpwSFdE4ALIV-ZUuEhZjI,5466
70
+ sysml2/_stdlib/systems/StandardViewDefinitions.sysml,sha256=spiCsCQOPMJyG2bGvJ_R0tJDGjToDhcM1GWRH_jYM6U,6115
71
+ sysml2/_stdlib/systems/States.sysml,sha256=GoTijUGo12_xy86BMSJX2sl7R7zVRcMfijT3MJisE7w,3371
72
+ sysml2/_stdlib/systems/SysML.sysml,sha256=lxLtauxZ4v8xyRXFjsjUIVjEFckwnpZTJib27l-PFZw,30789
73
+ sysml2/_stdlib/systems/UseCases.sysml,sha256=JC5RlEwyAyIV12qf8f2WfYujbv_9nXjaHEI6WxAqLPY,1271
74
+ sysml2/_stdlib/systems/VerificationCases.sysml,sha256=2-5yVeFt-cXPC97ZbEPLYLHlAmtpc8X7EXYxaQKsR7k,2488
75
+ sysml2/_stdlib/systems/Views.sysml,sha256=C88Qr9Sd0JyMZIRNqX_EwBpKNf79TkoXmovAqKJhyKg,3973
76
+ longeron-0.2.0.dist-info/METADATA,sha256=vvGodkPhAkONitCzUSQBTMUlsQsdkag79ScqZFkWWBU,20767
77
+ longeron-0.2.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
78
+ longeron-0.2.0.dist-info/entry_points.txt,sha256=TMvZZip94OfJ_RCmNKDQops_Bo3qoQ6Tny5aI48H848,43
79
+ longeron-0.2.0.dist-info/top_level.txt,sha256=pUscTQzOLxuSbXVM4hC4Ix-oSAScCfH3vlpUWwB9YEU,7
80
+ longeron-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ sysml2 = sysml2.cli:main