Repository navigation
Description
Description
The SysML2Tools grammar accepts not in front of a classification test with no parentheses, for example filter not @SysML::Documentation;. This is a syntax error in the OMG Pilot Implementation and does not conform to the KerML/SysML expression grammar. lint reports nothing. Models that use this idiom, which the project documents and tests, are rejected by spec-conforming tools. The same applies to and/or/xor/implies operands that are unparenthesized classification tests: filter @SysML::PartDefinition and not @SysML::Documentation;, and to the bracket form expose P::**[not @SysML::Documentation];.
Found while loading the self-model (docs/sysml2/views/design-views.sysml, filter not @SysML::Documentation;) into the Pilot.
Steps to Reproduce
filter-not.sysml:
package P {
part def A {
doc /* d */
}
view V {
expose P::A;
filter not @SysML::Documentation;
}
}
Run on main at fe8ac24 (Release build, CLI 0.0.0+9db01131b76caed6b79141d87a7395d2e6176f01, net10.0):
dotnet <repo>/src/DemaConsulting.SysML2Tools.Tool/bin/Release/net10.0/DemaConsulting.SysML2Tools.dll lint filter-not.sysmlOther forms that are also accepted by SysML2Tools and rejected by the Pilot:
filter @SysML::PartDefinition and not @SysML::Documentation;
expose P::**[not @SysML::Documentation];
Actual Behavior
SysML2Tools:
Linting 1 file(s)...
lint: no errors found. # exit 0
Pilot (release 2026-09.1, jupyter-sysml-kernel-0.63.1, headless SysMLInteractive.process):
ERRORS filter-not.sysml
ERROR:no viable alternative at input '@' (line 7 column 20)
The same error (no viable alternative at input '@') is reported for the and not @... filter and for the [not @...] expose filter. The parenthesized form filter not (@SysML::Documentation); loads with no issues in the Pilot, and SysML2Tools also accepts it.
Expected Behavior
lint reports a syntax error (exit code non-zero) at the @ that follows not, e.g. filter-not.sysml(7,20): error: .... The model must be written filter not (@SysML::Documentation);.
Grammar productions
Pilot KerMLExpressions.xtext (the executable form of KerML 8.2.5.8.1). The unary operand is an ExtentExpression, i.e. a primary expression, and the classification test @ T is a lower-precedence ClassificationExpression:
ClassificationExpression returns SysML::Expression :
RelationalExpression
( {OperatorExpression.operand += current} operator = ClassificationTestOperator ownedRelationship += TypeReferenceMember
| {OperatorExpression.operand += current} operator = CastOperator ownedRelationship += TypeResultMember )?
| {OperatorExpression} operand += SelfReferenceExpression operator = ClassificationTestOperator ownedRelationship += TypeReferenceMember
| ...
ClassificationTestOperator : 'hastype' | 'istype' | '@' ;
UnaryExpression returns SysML::Expression:
{OperatorExpression} operator = UnaryOperator operand += ExtentExpression
| ExtentExpression ;
UnaryOperator : '+' | '-' | '~' | 'not' ;
ExtentExpression returns SysML::Expression :
{OperatorExpression} operator = 'all' ownedRelationship += TypeResultMember
| PrimaryExpression ;
Because not binds a UnaryExpression/ExtentExpression operand, and @ T is only reachable at ClassificationExpression level (looser than RelationalExpression, tighter than EqualityExpression), not @T has no derivation; it must be not (@T). The same holds wherever not appears, for example as an operand of and/or.
SysML2Tools SysMLv2Parser.g4 (src/DemaConsulting.SysML2Tools.Language/Grammar/Grammar/SysMLv2Parser.g4):
elementFilterMember
: memberPrefix FILTER ownedExpression SEMI
;
ownedExpression
: ...
| ( PLUS | MINUS | TILDE | NOT ) ownedExpression // unary operand is any ownedExpression
| ( AT_SIGN | AT_AT ) typeReference // prefix '@ T' / '@@ T' is an ordinary alternative
| ownedExpression ( ISTYPE | HASTYPE | AT_SIGN ) typeReference
...The unary alternative takes ownedExpression as its operand rather than the spec's ExtentExpression, and the prefix @ T is a plain alternative of ownedExpression, so NOT followed by AT_SIGN typeReference parses. The same flattening affects the other unary operators (-, +, ~), where a unary operand can be a lower-precedence expression such as a classification test; the exact precedence effects of the left-recursive alternative order also deserve a check against Table 6.
Spec references
- KerML 8.2.5.8.1 Operator Expressions: productions
UnaryOperatorExpression/UnaryOperator = '+' | '-' | '~' | 'not',ClassificationExpressionwithClassificationTestOperator = 'istype' | 'hastype' | '@'. Note 2 in that clause: nested operator expressions "shall be implicitly grouped according to the precedence of the operators involved, as given in Table 6". The Pilot grammar above is the executable form of that precedence (unary operators bind tighter than the classification operators). - SysML v2 8.2.2.5.1 Packages:
ElementFilterMember : ElementFilterMembership = MemberPrefix 'filter' ownedRelatedElement += OwnedExpression ';'andFilterPackageMember(the[ ... ]form), both taking anOwnedExpression. - SysML v2 7.26.2 (cited by the project's own tests for view conditions): the
filterand expose-filter condition forms.
Impact (where the unparenthesized form is used today)
docs/user_guide/introduction.md (4 places), .github/standards/sysml2-modeling.md (2), docs/verification/.../general-view-layout-strategy.md, tests in WorkspaceLoaderTests, GeneralViewLayoutStrategyTests, ExposeScopeResolverTests, FilterExpressionParserTests, and the self-model view design-views.sysml (SysML2Tools-model branch). The CLI --filter "not @X" expression is a separate "Phase 1" filter dialect and can be decided independently. Fixing the grammar will require updating those samples to not (@X).
Tool Version
0.0.0+9db01131b76caed6b79141d87a7395d2e6176f01 (main fe8ac24)
Environment
.NET 10 (net10.0), Windows. Pilot comparison: OMG SysML-v2-Pilot-Implementation 2026-09.1.
Activity
Reject unparenthesized classification test as unary operand (not @x) (#…