Grammar conformance¶
The parsers are generated with ANTLR 4 from combined grammars for
SysML v2 and KerML (grammars/SysML.g4, grammars/KerML.g4), taken from
hivecore-dev/hcf-runtime
and locally patched. This page states exactly what conforms, what was
patched, and the one known deviation.
SysML® is a registered trademark of the Object Management Group. This project is not affiliated with or endorsed by OMG, and is not a conformance-certified implementation.
The corpus result: 309 of 309 files parse and build¶
The official
SysML-v2-Release
repository carries a corpus of 309 .sysml example files. Every file in
that corpus parses, and every file builds into the object model, with no
lossy fallback. Before grammar patches 6–10, the score was 283 parsed and
280 built.
The corpus itself is not vendored. Two things keep the number honest:
scripts/check_corpus.pyreproduces the sweep. It downloads the pinned release commit (the same revision the vendored standard library comes from), then parses and builds every.sysmlfile in it, printing309/309 files parse and build. Run it after grammar or builder changes; it is not part of the regular test suite.Each grammar patch carries regression tests derived from the corpus constructs that exposed it (
tests/test_parsing.py,tests/test_builder.py). Those derived snippets – not the full corpus – are what every test run re-checks.
In two places the release BNF and the corpus contradict each other (patches 8 and 10 below). There the grammar follows the corpus, and the README entry for the patch records the conflict.
The patch table¶
Each patch is marked with a LOCAL PATCH comment in the .g4 files.
The README
carries the full rationale for each; the table below is the summary.
# |
Grammar |
Patch |
|---|---|---|
1 |
SysML |
|
2 |
SysML |
Entry transitions accept the spec form |
3 |
both |
Unary operators bind tighter than binary operators, so |
4 |
SysML |
Metadata and classification use the |
5 |
SysML |
Flow ends accept dotted paths, so |
6 |
SysML |
State-body transitions put the |
7 |
SysML |
|
8 |
SysML |
Named send nodes accept the corpus form |
9 |
both |
A |
10 |
SysML |
Enumerated values accept metadata prefixes, the corpus form |
The known deviation: operator precedence¶
One deviation from the OMG specification remains, inherited from the upstream grammars:
??,or,and, andimpliesshare one precedence level, and|,&, andxorshare another, where the specification separates them;**is left-associative.
When an expression mixes these operators, parenthesize. The exporter always prints round-trip-safe parentheses, so exported text never depends on the deviation.
Regenerating the parsers¶
The generated parsers are committed under src/longeron/_gen/, so
installing and using the package needs no Java. Regenerate only after a
.g4 change:
python scripts/generate_parsers.py # or: pixi run parsers
The script finds Java through JAVA_HOME, PATH, or a conda/mamba
environment, and the ANTLR 4.13.2 jar through ANTLR_JAR, ~/.m2, or
Maven Central. pixi run parsers needs no setup at all: conda-forge’s
antlr package ships the tool and a JDK, and the task caches on its
inputs and produces byte-identical output. CI fails if the committed
parsers drift from the .g4 sources.