Update vendored ANTLR4 grammar to OMG release 2026-05 (daltskin v2026.05.0) - #2
Open
HansBug wants to merge 2 commits into
Open
Update vendored ANTLR4 grammar to OMG release 2026-05 (daltskin v2026.05.0)#2HansBug wants to merge 2 commits into
HansBug wants to merge 2 commits into
Conversation
….05.0) Sync the grammar layer with the latest official SysML v2 release: - annotatingMember: allow explicit visibility (MemberPrefix) - SYSML21-319 - payloadFeature: normalize identification/typing alternatives - 2026-05 KeBNF sync - framedConcernUsage: requirement body instead of calculation body - SYSML21-366 - filterPackage: drop the TODO stub in favor of the official production Regenerated parser sources with ANTLR 4.13.2 (same version as checked-in generated files). Existing local grammar patches (GUARD keyword, qualifiedIdentification, metadataAccessExpression, DOT bodyExpression, view-rendering keywords) are preserved unchanged.
HansBug
force-pushed
the
grammar-refresh-2026-05
branch
2 times, most recently
from
August 16, 2026 06:02
21f300b to
6619aa8
Compare
HansBug
force-pushed
the
grammar-refresh-2026-05
branch
from
August 16, 2026 06:05
6619aa8 to
333c794
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR refreshes the vendored ANTLR4 grammar from the OMG 2026-03 release to the OMG 2026-05 release (the latest official release, published 2026-07-22). The grammar is generated from the official machine-readable KeBNF by daltskin/sysml-v2-grammar; this PR brings sysmlpy in line with daltskin v2026.05.0 while preserving all of sysmlpy's existing local grammar patches.
Changes and official basis
annotatingMember: annotatingElement→: memberPrefix annotatingElementpayloadFeatureidentificationnow required in the typed alternatives;ownedFeatureTyping/ownedMultiplicitypair normalized; identification-optional specialization alternative addedframedConcernUsage(2nd alternative)calculationBody→requirementBody;calculationUsageDeclaration→constraintUsageDeclarationfilterPackagefilterPackageImport ( filterPackageMember )+alternative and thefilterPackageImport : IDENTIFIER /* TODO */stub (the official 2026-05 KeBNF defines a realFilterPackageImportproduction; the parser now only usesfilterPackageImportDeclaration)SysMLv2Parser.py/SysMLv2ParserVisitor.py/SysMLv2ParserListener.py/.interp/.tokensregenerated with ANTLR 4.13.2 (same version as the currently checked-in generated files); the lexer generated files are untouched (the lexer grammar did not change)grammar/antlr4/README.md2026-03→2026-05antlr_parser.pydocstringEach grammar edit carries an inline comment citing the corresponding OMG issue / Pilot PR / BNF production, so the change trail is visible in the
.g4itself.Downstream impact analysis (why no visitor/classes changes are included)
The four changed productions were checked one by one against the downstream layers (
antlr_visitor.py→grammar/classes.py→usage.py/definition.py):annotatingMemberenum def Color { doc /* … */ enum red; }round-trips without thedocmember both before and after this change — a pre-existing gap). With this PR,public doc …additionally parses (as required by SYSML21-319), and is dropped the same way. Full round-trip support for enum annotating members (including the visibility prefix) is a separate pre-existing gap, tracked as a follow-up.payloadFeature_visit_payload_featureonly readsownedFeatureTypingand falls back togetText(); robust to the alternative reordering. No change needed (verified against the 54-model state-machine corpus: identical results before/after).framedConcernUsageframedConcernMember("skip for now" inantlr_visitor.py); no change needed.filterPackagefilterPackageImportDeclaration()only; the removed stub had no visitor counterpart. No change needed.What was preserved (and why it must stay)
sysmlpy's local grammar patches are carried over unchanged:
guardExpressionMember : (IF | GUARD) ownedExpression(guard keyword)identificationacceptsqualifiedIdentification(qualified subject names)metadataAccessExpression,invocationExpression,ownedExpression DOT bodyExpressionCOLOR,SHAPE,SHOW,EVENTS,ANNOTATION)importRulekeepsvisibilityIndicatorrequiredThese are load-bearing: swapping in daltskin v2026.05.0 verbatim breaks two official fixtures (
expression/PathExpressions.sysml,simpletests/EnumerationTest.sysml) in the conformance suite, so a plain "use the exact upstream file" update is not viable.Note on
importRule: daltskin's translation makes import visibility optional, but the official KerML/SysML 2026-05 BNF requires it (Import = visibility = VisibilityIndicator 'import' …, KerML §8.2.3.4.2). sysmlpy's local "required" shape matches the official syntax (a bareimportis a syntax error, exactly as the official XPECT fixtureImport_Visibility_Validexpects). This local deviation from daltskin is therefore kept, and a comment in the.g4cites the official production. Related known gap (upstream, not touched here):tests/sysmlv2/validation/valid/Import_Visibility_Valid.sysmlhas no.errorsidecar, so the conformance runner expects a clean parse even though the official fixture expects a syntax error at the bareimport— a runner/fixture configuration issue worth a separate fix.Verification
poetry run pytest tests/grammar_test.py: 95 passed.poetry run pytest -m conformance: 111 passed; the 12 pre-existing failures are byte-identical before and after this change (Metadata/Import_Visibility fixtures).poetry run pytest tests/ -m "not conformance": 588 passed; the 8 failures are pre-existing (2 PlantUML rendering assertions and 6 missing optional dependencies: networkx/kuzu/cayley), identical before and after this change.transition first … accept … if … then …still parse correctly.Scope notes
tests/sysmlv2/is still the 2026-03 XPect suite (unchanged). Updating it to the 2026-05 suite can be a follow-up PR.AnnotatingMembernow accepts an explicit visibility in the parser; full object-model round-trip of enum annotating members (with or without visibility) remains a pre-existing gap and is a candidate follow-up.Happy to adjust anything.