I really appreciate the KEBNF files in the repository! In working to get a functioning grammar from them I had to make a number of changes. I had claude go through my commit history and summarize each change, here they are:
-
Add missing FilterPackageImport rule (KerML KEBNF)
The FilterPackage rule referenced FilterPackageImport, but this rule was never defined. Added the rule with both membership-import and namespace-import alternatives, matching the Xtext definition.
-
Add missing InvocationTypeMember rule (KerML KEBNF)
The FunctionOperationExpression rule referenced InvocationTypeMember, but this rule was never defined. The Xtext grammar defines it as a trivial delegation to InstantiatedTypeMember. Added the missing rule.
-
Add AllocationDefinition to DefinitionElement (SysML KEBNF)
AllocationDefinition was defined as a standalone rule but was missing from the DefinitionElement choice, so allocation def could never appear in a package or definition body. Added it as an alternative.
-
Add EndUsagePrefix alternative to OccurrenceUsagePrefix (SysML KEBNF)
The KEBNF defined OccurrenceUsagePrefix using only BasicUsagePrefix, but the Xtext grammar shows it must also accept EndUsagePrefix (to support end occurrence usages like end port ...). Wrapped the body in a choice between EndUsagePrefix and the existing BasicUsagePrefix path.
-
Fix EntryTransitionMember reference: TargetSuccession to TransitionSuccession (SysML KEBNF)
The EntryTransitionMember rule referenced TargetSuccession in the 'then' branch, but the correct rule per Xtext is TransitionSuccession. TargetSuccession is a different construct used in action successions.
-
Fix FramedConcernUsage reference: CalculationUsageDeclaration to ConstraintUsageDeclaration (SysML KEBNF)
The FramedConcernUsage rule referenced CalculationUsageDeclaration, which does not exist. The Xtext grammar uses ConstraintUsageDeclaration, consistent with the pattern for concern/constraint usages.
-
Make 'standard' optional in LibraryPackage (SysML KEBNF + KerML KEBNF)
The KEBNF used ( isStandard ?= 'standard' ) — the ?= operator means "set to true if present", implying the keyword should be optional, but the surrounding parentheses without ? made it a required group. Changed to ( isStandard ?= 'standard' )? in both files.
-
Add DefaultInterfaceEnd to StructureUsageElement (SysML KEBNF)
Bare end usages (e.g., end myPort : PortType;) inside definition bodies require DefaultInterfaceEnd, but this alternative was missing from StructureUsageElement. The Xtext grammar includes it.
-
Add trailing dot to FlowEndSubsetting (SysML KEBNF)
The KEBNF rule FlowEndSubsetting defined the qualified-name branch as referencedFeature = [QualifiedName] without a trailing ., making it impossible for the parser to distinguish the subsetting context from the flow feature member that follows. The Xtext grammar includes the . as a separator.
-
Fix SendNode declaration: ActionUsageDeclaration to ActionNodeUsageDeclaration (SysML KEBNF)
SendNode used ActionUsageDeclaration? for its optional declaration prefix, but the Xtext grammar uses ActionNodeUsageDeclaration?. This parallels the pattern used by AcceptNode, AssignmentNode, and TerminateNode. The difference matters because ActionUsageDeclaration includes ValuePart? which creates ambiguity with the send payload.
-
Make 'assert' and 'not' optional in SatisfyRequirementUsage (SysML KEBNF)
The KEBNF required 'assert' before 'satisfy' and made isNegated ?= 'not' non-optional (same ?= without outer ? issue as the LibraryPackage fix). The Xtext grammar makes both keywords optional.
-
Fix CaseBodyItem to use CalculationBodyItem instead of ActionBodyItem (SysML KEBNF)
CaseBodyItem referenced ActionBodyItem as its base, but CaseDefinition extends CalculationDefinition in the metamodel, and calculations support ReturnParameterMember. The Xtext grammar uses CalculationBodyItem.
-
Add SysML ExpressionBody override using CalculationBodyPart (SysML KEBNF)
Body expressions (e.g., { in ref w = ...}) inside SysML calculations and constraints could not parse because the KerML ExpressionBody rule uses FunctionBodyPart, which only allows KerML-level syntax inside the braces. The Xtext SysML grammar explicitly overrides ExpressionBody to use CalculationBodyPart. Added a SysML-specific override.
-
Add UsageExtensionKeyword* prefix to EnumeratedValue (SysML KEBNF)
Enumerated values with prefix metadata annotations (e.g., #Security enum value1;) could not parse because EnumeratedValue did not allow UsageExtensionKeyword* before the optional 'enum' keyword. The Xtext grammar includes this prefix.
I really appreciate the KEBNF files in the repository! In working to get a functioning grammar from them I had to make a number of changes. I had claude go through my commit history and summarize each change, here they are:
Add missing
FilterPackageImportrule (KerML KEBNF)The
FilterPackagerule referencedFilterPackageImport, but this rule was never defined. Added the rule with both membership-import and namespace-import alternatives, matching the Xtext definition.Add missing
InvocationTypeMemberrule (KerML KEBNF)The
FunctionOperationExpressionrule referencedInvocationTypeMember, but this rule was never defined. The Xtext grammar defines it as a trivial delegation toInstantiatedTypeMember. Added the missing rule.Add
AllocationDefinitiontoDefinitionElement(SysML KEBNF)AllocationDefinitionwas defined as a standalone rule but was missing from theDefinitionElementchoice, soallocation defcould never appear in a package or definition body. Added it as an alternative.Add
EndUsagePrefixalternative toOccurrenceUsagePrefix(SysML KEBNF)The KEBNF defined
OccurrenceUsagePrefixusing onlyBasicUsagePrefix, but the Xtext grammar shows it must also acceptEndUsagePrefix(to supportendoccurrence usages likeend port ...). Wrapped the body in a choice betweenEndUsagePrefixand the existingBasicUsagePrefixpath.Fix
EntryTransitionMemberreference:TargetSuccessiontoTransitionSuccession(SysML KEBNF)The
EntryTransitionMemberrule referencedTargetSuccessionin the'then'branch, but the correct rule per Xtext isTransitionSuccession.TargetSuccessionis a different construct used in action successions.Fix
FramedConcernUsagereference:CalculationUsageDeclarationtoConstraintUsageDeclaration(SysML KEBNF)The
FramedConcernUsagerule referencedCalculationUsageDeclaration, which does not exist. The Xtext grammar usesConstraintUsageDeclaration, consistent with the pattern for concern/constraint usages.Make
'standard'optional inLibraryPackage(SysML KEBNF + KerML KEBNF)The KEBNF used
( isStandard ?= 'standard' )— the?=operator means "set to true if present", implying the keyword should be optional, but the surrounding parentheses without?made it a required group. Changed to( isStandard ?= 'standard' )?in both files.Add
DefaultInterfaceEndtoStructureUsageElement(SysML KEBNF)Bare
endusages (e.g.,end myPort : PortType;) inside definition bodies requireDefaultInterfaceEnd, but this alternative was missing fromStructureUsageElement. The Xtext grammar includes it.Add trailing dot to
FlowEndSubsetting(SysML KEBNF)The KEBNF rule
FlowEndSubsettingdefined the qualified-name branch asreferencedFeature = [QualifiedName]without a trailing., making it impossible for the parser to distinguish the subsetting context from the flow feature member that follows. The Xtext grammar includes the.as a separator.Fix
SendNodedeclaration:ActionUsageDeclarationtoActionNodeUsageDeclaration(SysML KEBNF)SendNodeusedActionUsageDeclaration?for its optional declaration prefix, but the Xtext grammar usesActionNodeUsageDeclaration?. This parallels the pattern used byAcceptNode,AssignmentNode, andTerminateNode. The difference matters becauseActionUsageDeclarationincludesValuePart?which creates ambiguity with the send payload.Make
'assert'and'not'optional inSatisfyRequirementUsage(SysML KEBNF)The KEBNF required
'assert'before'satisfy'and madeisNegated ?= 'not'non-optional (same?=without outer?issue as theLibraryPackagefix). The Xtext grammar makes both keywords optional.Fix
CaseBodyItemto useCalculationBodyIteminstead ofActionBodyItem(SysML KEBNF)CaseBodyItemreferencedActionBodyItemas its base, butCaseDefinitionextendsCalculationDefinitionin the metamodel, and calculations supportReturnParameterMember. The Xtext grammar usesCalculationBodyItem.Add SysML
ExpressionBodyoverride usingCalculationBodyPart(SysML KEBNF)Body expressions (e.g.,
{ in ref w = ...}) inside SysML calculations and constraints could not parse because the KerMLExpressionBodyrule usesFunctionBodyPart, which only allows KerML-level syntax inside the braces. The Xtext SysML grammar explicitly overridesExpressionBodyto useCalculationBodyPart. Added a SysML-specific override.Add
UsageExtensionKeyword*prefix toEnumeratedValue(SysML KEBNF)Enumerated values with prefix metadata annotations (e.g.,
#Security enum value1;) could not parse becauseEnumeratedValuedid not allowUsageExtensionKeyword*before the optional'enum'keyword. The Xtext grammar includes this prefix.