Skip to content

Update vendored ANTLR4 grammar to OMG release 2026-05 (daltskin v2026.05.0) - #2

Open
HansBug wants to merge 2 commits into
mycr0ft:mainfrom
HansBug:grammar-refresh-2026-05
Open

Update vendored ANTLR4 grammar to OMG release 2026-05 (daltskin v2026.05.0)#2
HansBug wants to merge 2 commits into
mycr0ft:mainfrom
HansBug:grammar-refresh-2026-05

Conversation

@HansBug

@HansBug HansBug commented Aug 16, 2026

Copy link
Copy Markdown

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

Change What changed Official basis
annotatingMember : annotatingElement: memberPrefix annotatingElement SYSML21-319 "AnnotatingMember does not allow visibility" (SysML 2.1 RTF Ballot 1), implemented in Pilot PR ST6RI-945 #775
payloadFeature identification now required in the typed alternatives; ownedFeatureTyping / ownedMultiplicity pair normalized; identification-optional specialization alternative added OMG 2026-05 BNF sync, via daltskin PR #9 "Update grammar to OMG release 2026-05"
framedConcernUsage (2nd alternative) calculationBodyrequirementBody; calculationUsageDeclarationconstraintUsageDeclaration SYSML21-366 "Error in FramedConcernUsage production" (SysML 2.1 RTF Ballot 1), implemented in Pilot PR ST6RI-945 #775
filterPackage removed the filterPackageImport ( filterPackageMember )+ alternative and the filterPackageImport : IDENTIFIER /* TODO */ stub (the official 2026-05 KeBNF defines a real FilterPackageImport production; the parser now only uses filterPackageImportDeclaration) OMG 2026-05 KeBNF update (bnf/SysML-textual-bnf.kebnf)
Regenerated parser sources SysMLv2Parser.py / SysMLv2ParserVisitor.py / SysMLv2ParserListener.py / .interp / .tokens regenerated 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.md Release tag 2026-032026-05
antlr_parser.py docstring "generated from the OMG SysML v2 specification (2026-03 release)" → "(2026-05 release)"

Each grammar edit carries an inline comment citing the corresponding OMG issue / Pilot PR / BNF production, so the change trail is visible in the .g4 itself.

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.pygrammar/classes.pyusage.py/definition.py):

Production Downstream impact
annotatingMember The visitor already drops annotating members inside enumeration bodies today (verified: enum def Color { doc /* … */ enum red; } round-trips without the doc member 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_feature only reads ownedFeatureTyping and falls back to getText(); robust to the alternative reordering. No change needed (verified against the 54-model state-machine corpus: identical results before/after).
framedConcernUsage The visitor explicitly skips framedConcernMember ("skip for now" in antlr_visitor.py); no change needed.
filterPackage The visitor already reads filterPackageImportDeclaration() 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)
  • identification accepts qualifiedIdentification (qualified subject names)
  • metadataAccessExpression, invocationExpression, ownedExpression DOT bodyExpression
  • view-rendering keywords (COLOR, SHAPE, SHOW, EVENTS, ANNOTATION)
  • importRule keeps visibilityIndicator required

These 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 bare import is a syntax error, exactly as the official XPECT fixture Import_Visibility_Valid expects). This local deviation from daltskin is therefore kept, and a comment in the .g4 cites the official production. Related known gap (upstream, not touched here): tests/sysmlv2/validation/valid/Import_Visibility_Valid.sysml has no .error sidecar, so the conformance runner expects a clean parse even though the official fixture expects a syntax error at the bare import — a runner/fixture configuration issue worth a separate fix.

Verification

  • The updated grammar was compared rule-by-rule against daltskin v2026.05.0: every changed rule matches upstream exactly (modulo whitespace style and the preserved local patches listed above).
  • 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.
  • Quick smoke: state-machine models with transition first … accept … if … then … still parse correctly.

Scope notes

  • The conformance fixture corpus under tests/sysmlv2/ is still the 2026-03 XPect suite (unchanged). Updating it to the 2026-05 suite can be a follow-up PR.
  • AnnotatingMember now 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.

….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
HansBug force-pushed the grammar-refresh-2026-05 branch 2 times, most recently from 21f300b to 6619aa8 Compare August 16, 2026 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant