From b5580c06a72cac6682c749eedeb5bad02ad9ab4b Mon Sep 17 00:00:00 2001 From: antoineatsoprasteria Date: Thu, 12 Nov 2026 13:58:46 +0100 Subject: [PATCH 1/2] [Add] kgbnf.g4 grammar, generated parser and GraphicalNotationSpecificationVisitor for SysML-graphical-bnf.kgbnf --- Resources/SysML-graphical-bnf.kgbnf | 2264 +++++++++++++++++ Resources/kgbnf.g4 | 71 + ...NotationSpecificationVisitorTestFixture.cs | 96 + .../NET/CodeGenerator/Grammar/kgbnf.interp | 61 + .../NET/CodeGenerator/Grammar/kgbnf.tokens | 29 + .../Grammar/kgbnfBaseListener.cs | 197 ++ .../CodeGenerator/Grammar/kgbnfBaseVisitor.cs | 159 ++ .../NET/CodeGenerator/Grammar/kgbnfLexer.cs | 160 ++ .../CodeGenerator/Grammar/kgbnfLexer.interp | 74 + .../CodeGenerator/Grammar/kgbnfLexer.tokens | 29 + .../CodeGenerator/Grammar/kgbnfListener.cs | 155 ++ .../NET/CodeGenerator/Grammar/kgbnfParser.cs | 993 ++++++++ .../NET/CodeGenerator/Grammar/kgbnfVisitor.cs | 108 + .../GraphicalNotationSpecificationVisitor.cs | 138 + .../Grammar/Model/GraphicalAlternatives.cs | 24 + .../Grammar/Model/GraphicalEdgeEndElement.cs | 22 + .../Grammar/Model/GraphicalGroupElement.cs | 24 + .../Grammar/Model/GraphicalImageElement.cs | 22 + .../Model/GraphicalNonTerminalElement.cs | 28 + .../Grammar/Model/GraphicalNotationRule.cs | 35 + .../Model/GraphicalNotationSpecification.cs | 24 + .../Grammar/Model/GraphicalRuleElement.cs | 22 + .../Grammar/Model/GraphicalTerminalElement.cs | 22 + .../SysML2.NET.CodeGenerator.csproj | 7 + 24 files changed, 4764 insertions(+) create mode 100644 Resources/SysML-graphical-bnf.kgbnf create mode 100644 Resources/kgbnf.g4 create mode 100644 SysML2.NET.CodeGenerator.Tests/Grammar/GraphicalNotationSpecificationVisitorTestFixture.cs create mode 100644 SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnf.interp create mode 100644 SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnf.tokens create mode 100644 SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfBaseListener.cs create mode 100644 SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfBaseVisitor.cs create mode 100644 SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfLexer.cs create mode 100644 SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfLexer.interp create mode 100644 SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfLexer.tokens create mode 100644 SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfListener.cs create mode 100644 SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfParser.cs create mode 100644 SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfVisitor.cs create mode 100644 SysML2.NET.CodeGenerator/Grammar/GraphicalNotationSpecificationVisitor.cs create mode 100644 SysML2.NET.CodeGenerator/Grammar/Model/GraphicalAlternatives.cs create mode 100644 SysML2.NET.CodeGenerator/Grammar/Model/GraphicalEdgeEndElement.cs create mode 100644 SysML2.NET.CodeGenerator/Grammar/Model/GraphicalGroupElement.cs create mode 100644 SysML2.NET.CodeGenerator/Grammar/Model/GraphicalImageElement.cs create mode 100644 SysML2.NET.CodeGenerator/Grammar/Model/GraphicalNonTerminalElement.cs create mode 100644 SysML2.NET.CodeGenerator/Grammar/Model/GraphicalNotationRule.cs create mode 100644 SysML2.NET.CodeGenerator/Grammar/Model/GraphicalNotationSpecification.cs create mode 100644 SysML2.NET.CodeGenerator/Grammar/Model/GraphicalRuleElement.cs create mode 100644 SysML2.NET.CodeGenerator/Grammar/Model/GraphicalTerminalElement.cs diff --git a/Resources/SysML-graphical-bnf.kgbnf b/Resources/SysML-graphical-bnf.kgbnf new file mode 100644 index 000000000..7d20382b8 --- /dev/null +++ b/Resources/SysML-graphical-bnf.kgbnf @@ -0,0 +1,2264 @@ +// Corrected manually by HP de Koning + +// Part 2 - Systems Modeling Language (SysML) + +// Clause 8.2.3 Graphical Notation + +// Clause 8.2.3.1 Graphical Notation Overview + +// Clause 8.2.3.2 Elements and Relationships Graphical Notation + +element = + dependencies-and-annotations-element + | general-element + | element-inside-textual-compartment + +compartment =| general-compartment + +general-compartment = + + general-view + +general-view = + (general-element)* + (dependencies-and-annotations-element)* + (ellipsis-at-lower-left-corner)? + +ellipsis-at-lower-left-corner = '...' + +general-element = + general-node + | general-relationship + +element-node = + usage-node | definition-node | annotation-node | namespace-node + +element-inside-textual-compartment = + + +rel-name = + Identification + | QualifiedName + +// Note. An element inside a textual compartment is selected by graying out a substring containing the element. The grayed-out section must cover a single element within the textual syntax inside the compartment. + +// Clause 8.2.3.3 Dependencies Graphical Notation + +dependencies-and-annotations-element =| dependencies-element + +dependencies-element =| + binary-dependency + | n-ary-dependency + +binary-dependency = + + +n-ary-dependency = + &n-ary-association-dot (n-ary-dependency-client-or-supplier-link &element-node)+ + +n-ary-dependency-client-or-supplier-link = + n-ary-dependency-client-link + | n-ary-dependency-supplier-link + +n-ary-association-dot = + + +n-ary-dependency-client-link = + + +n-ary-dependency-supplier-link = + + +// Note. An n-ary dependency must have two or more client elements or two or more supplier elements. + +// Clause 8.2.3.4 Annotations Graphical Notation + +dependencies-and-annotations-element =| + annotation-node + | annotation-link + +annotation-node = + comment-node + | documentation-node + | textual-representation-node + +text-block = (LINE_TEXT)* + +comment-node = + comment-without-keyword + | comment-with-keyword + +comment-without-keyword = + + +comment-with-keyword = + + +documentation-node = + + +documentation-compartment = + + Identification + text-block + +textual-representation-node = + + +language-string = 'language' STRING_VALUE + +annotation-link = + + +annotated-element = + element + | element-inside-textual-compartment + +// Note. A comment node may be attached to zero, one, or more than one annotated elements. All other annotation nodes must be attached to one and only one annotated element. + +// Clause 8.2.3.5 Namespaces and Packages Graphical Notation + +general-node =| namespace-node + +namespace-node =| package-node + +package-node = + package-with-name-inside + | package-with-name-in-tab + | imported-package-with-name-inside + | imported-package-with-name-in-tab + +package-with-name-inside = + + +package-with-name-in-tab = + + +imported-package-with-name-inside = + + +imported-package-with-name-in-tab = + + +package-compartment = + general-compartment + | documentation-compartment + | packages-compartment + | members-compartment + | relationships-compartment + +compartment =| package-compartment + +packages-compartment = + + packages-compartment-contents + +packages-compartment-contents = packages-compartment-element* '…'? + +packages-compartment-element = el-prefix? Identification + +members-compartment = + + members-compartment-contents + +members-compartment-contents = members-compartment-element* '…'? + +members-compartment-element = el-prefix? (DefinitionElement | UsageElement) + +relationships-compartment = + + relationships-compartment-contents + +relationships-compartment-contents = (relationships-compartment-element)* '…'? + +relationships-compartment-element = el-prefix? relationship-name QualifiedName + +relationship-name = + 'defines' | 'defined by' | 'specializes' | 'specialized by' | 'connect to' + | 'subsets' | 'subsetted by' | 'performs' | 'performed by' | 'allocated' | 'allocated to' + | 'satisfy' | 'satisfied by' + +general-relationship =| + import + | top-level-import + | recursive-import + | owned-membership + | unowned-membership + +import = + + +top-level-import = + + +recursive-import = + + +owned-membership = + + +unowned-membership = + + +// Clause 8.2.3.6 Definition and Usage Graphical Notation + +general-node =| type-node + +type-node = + definition-node + | usage-node + +general-node =| usage-node definition-node + +namespace-node =| type-node + +definition-name-with-alias = + DefinitionDeclaration + ( '«alias»' ( QualifiedName (',' QualifiedName)* ) )? + +usage-name-with-alias = + '^'? UsageDeclaration + ( '«alias»' ( QualifiedName (',' QualifiedName)* ) )? + +compartment-stack = (compartment)* + +compartment =| + features-compartment + | variants-compartment + | variant-elementusages-compartment + +features-compartment = + + features-compartment-contents + +features-compartment-contents = (features-compartment-element)* '…'? + +features-compartment-element = el-prefix? UsagePrefix usage-cp + +variants-compartment = + + variants-compartment-contents + +variants-compartment-contents = members-compartment-contents + +variant-elementusages-compartment = + + variants-compartment-contents + +general-relationship =| + type-relationship + +type-relationship = + subclassification + | subsetting + | definition + | redefinition + | composite-feature-membership + | noncomposite-feature-membership + +subclassification = + + +definition = + + +subsetting = + + +reference-subsetting = + + +redefinition = + + +composite-feature-membership = + + +noncomposite-feature-membership = + + +el-prefix = '^' | '/' + +usage-cp = usageDeclaration ValuePart? + +extended-def = + + +extended-def-name-compartment = + '«' BasicDefinitionPrefix? DefinitionExtensionKeyword+ 'def' '»' + definition-name-with-alias + +// Note. This production is only valid for cases where one or more +// DefinitionExtensionKeyword names a MetadataDefinition that is a direct +// or indirect specialization of KerML metaclass SemanticMetadata. + +definition-node =| extended-def + +extended-usage = + + +extended-usage-name-compartment = + '«' BasicUsagePrefix? UsageExtensionKeyword+ '»' + usage-name-with-alias + +// Note. This production is only valid for cases where one or more +// UsageExtensionKeyword names a MetadataDefinition that is a direct +// or indirect specialization of KerML metaclass SemanticMetadata. + +usage-node =| extended-usage + +// Clause 8.2.3.7 Attributes Graphical Notation + +definition-node =| attribute-def + +attribute-def = + + +attribute-def-name-compartment = + '«' DefinitionPrefix 'attribute' 'def' '»' + definition-name-with-alias + +usage-node =| attribute + +attribute = + + +attribute-name-compartment = + '«' UsagePrefix 'attribute' '»' + usage-name-with-alias + +compartment =| attributes-compartment + +attributes-compartment = + + attributes-compartment-contents + +attributes-compartment-contents = (attributes-compartment-element)* '…'? + +attributes-compartment-element = el-prefix? UsagePrefix usage-cp + +// Clause 8.2.3.8 Enumerations Graphical Notation + +definition-node =| enumeration-def + +enumeration-def = + + +enumeration-def-name-compartment = + '«' DefinitionPrefix 'enum' 'def' '»' + definition-name-with-alias + +usage-node =| enumeration + +enumeration = + + +enumeration-name-compartment = + '«' UsagePrefix 'enum' '»' + usage-name-with-alias + +compartment =| enums-compartment + +enums-compartment = + + enums-compartment-contents + +enums-compartment-contents = (enums-compartment-element)* '…'? + +enums-compartment-element = el-prefix? UsagePrefix usage-cp + +// Clause 8.2.3.9 Occurrences Graphical Notation + +definition-node =| occurrence-def + +general-relationship =| portion-relationship + +occurrence-def = + + +occurrence-def-name-compartment = + '«' DefinitionPrefix 'occurrence' 'def' '»' + definition-name-with-alias + +usage-node =| + occurrence + | occurrence-ref + | timeslice-or-snapshot-node + +occurrence = + + +occurrence-ref = + + +occurrence-name-compartment = + '«' OccurrenceUsagePrefix 'occurrence' '»' + usage-name-with-alias + +timeslice-or-snapshot-node = + timeslice + | snapshot + +timeslice = + + +timeslice-name-compartment = + '«timeslice»' + usage-name-with-alias + +snapshot = + + +snapshots-name-compartment = + '«snapshot»' + usage-name-with-alias + +event-occurrence-def = + + +event-occurrence-def-name-compartment = + '«' DefinitionPrefix 'event' 'occurrence' 'def' '»' + definition-name-with-alias + +definition-node =| event-occurrence-def + +event-occurrence = + + +event-occurrence-name-compartment = + '«' OccurrenceUsagePrefix 'event' 'occurrence' '»' + usage-name-with-alias + +usage-node =| event-occurrence + +event-edge = + + +eventer = usage-node | definition-node + +portion-relationship = + + +compartment =| + occurrences-compartment + | individuals-compartment + | timeslices-compartment + | snapshots-compartment + | sequence-compartment + +occurrences-compartment = + + occurrences-compartment-contents + +occurrences-compartment-contents = (occurrences-compartment-element)* '…'? + +occurrences-compartment-element = el-prefix? OccurrenceUsagePrefix usage-cp + +individuals-compartment = + + individuals-compartment-contents + +individuals-compartment-contents = (individuals-compartment-element)* '…'? + +individuals-compartment-element = occurrences-compartment-element + +timeslices-compartment = + + timeslices-compartment-contents + +timeslices-compartment-contents = (timeslices-compartment-element)* '…'? + +timeslices-compartment-element = occurrences-compartment-element + +snapshots-compartment = + + snapshots-compartment-contents + +snapshots-compartment-contents = (snapshots-compartment-element)* '…'? + +snapshots-compartment-element = occurrences-compartment-element + +sequence-compartment = + + sequence-view + +sequence-view = (sq-graphical-element)* + +sq-graphical-element = + sq-graphical-node + | sq-graphical-relationship + | dependencies-and-annotations-element + +sq-graphical-node = sq-head-node | lifeline + +sq-head-node = sq-part | sq-port + +sq-part = + + +sq-port = + + +sq-port-label = UsageDeclaration + +sq-l-node = + lifeline + | sq-proxy + +lifeline = + + +sq-proxy = + + | + + +proxy-label = '.'? FeatureChainMember + +sq-graphical-relationship = message | sq-succession + +succession-label = UsageDeclaration? + +sq-succession = + + +succession-label = Identification + +// Note: the proxy nodes attached to a succession must refer to an event + +// Clause 8.2.3.10 Items Graphical Notation + +definition-node =| item-def + +interconnection-element =| item| item-ref + +item-def = + + +item-def-name-compartment = + '«' DefinitionPrefix 'item' 'def' '»' + definition-name-with-alias + +usage-node =| item + +item = + + +item-name-compartment = + '«' OccurrenceUsagePrefix 'item' '»' + usage-name-with-alias + +item-ref = + + +compartment =| items-compartment + +items-compartment = + + items-compartment-contents + +items-compartment-contents = (items-compartment-element)* '…' + +items-compartment-element = el-prefix? OccurrenceUsagePrefix usage-cp + +// Clause 8.2.3.11 Parts Graphical Notation + +definition-node =| part-def + +interconnection-element =| part | part-ref + +part-def = + + +part-def-name-compartment = + '«' DefinitionPrefix 'part' 'def' '»' + definition-name-with-alias + +usage-node =| part + +part = + + +part-name-compartment = + '«' OccurrenceUsagePrefix 'part' '»' + usage-name-with-alias + +part-ref = + + +compartment =| + parts-compartment + | directed-features-compartment + | interconnection-compartment + +parts-compartment = + + parts-compartment-contents + +parts-compartment-contents = (parts-compartment-element)* '…'? + +parts-compartment-element = el-prefix? OccurrenceUsagePrefix usage-cp + +directed-features-compartment = + + directed-features-compartment-contents + +directed-features-compartment-contents = (directed-features-compartment-element)* '…'? + +directed-features-compartment-element = + el-prefix FeatureDirection DefinitionBodyItem* + +interconnection-compartment = + + interconnection-view + +interconnection-view =| + (interconnection-element)* + (dependencies-and-annotations-element)* + (ellipsis-at-lower-left-corner)? + +general-view =| interconnection-view + +// Clause 8.2.3.12 Ports Graphical Notation + +definition-node =| port-def + +port-def = + + +port-def-name-compartment = + '«' DefinitionPrefix 'port' 'def' '»' + definition-name-with-alias + +usage-node =| port-usage + +port-usage = + + +port-name-compartment = + '«' OccurrenceUsagePrefix 'port' '»' + usage-name-with-alias + +compartment =| ports-compartment + +ports-compartment = + + ports-compartment-contents + +ports-compartment-contents = (ports-compartment-element)* '…'? + +ports-compartment-element = el-prefix? OccurrenceUsagePrefix usage-cp + +interconnection-element =| port-def | port-usage + +pdh = + + | + + | + + +pdv = + + | + + | + + +port-l = + + | + + | + + | + proxy-v + +port-r = + + | + + | + + | + proxy-v + +port-t = + + | + + | + + | + proxy-h + +port-b = + + | + + | + + | + proxy-h + +port-label = QualifiedName (':' QualifiedName)? + +proxy-v = + + | + + +proxy-h = + + | + + +// Note. Dotted line port productions (references) are only possible for nested ports + +// Note. The proxy option of a port production is valid only on a part usage contained within an interconnection view. + +// Clause 8.2.3.13 Connections Graphical Notation + +definition-node =| connection-def + +connection-def = + + +connection-def-name-compartment = + '«' DefinitionPrefix 'connection' 'def' '»' + definition-name-with-alias + +usage-node =| connection + +connection = + + +connection-name-compartment = + '«' OccurrenceUsagePrefix 'connection' '»' + usage-name-with-alias + +compartment =| connections-compartment + +connections-compartment = + + connections-compartment-contents + +connections-compartment-contents = (connections-compartment-element)* '…'? + +connections-compartment-element = + el-prefix? OccurrenceUsagePrefix UsageDeclaration + +interconnection-element =| + connection-def + | connection + | connection-relationship + | attribute + +connection-relationship = + binding-connection + | connection-graphical + | n-ary-connection + | n-ary-connection-def + | connection-definition-elaboration + | connection-usage-elaboration + | connection-def-graphical + +connection-graphical = + + | + + +c-adornment = + (a-property | a-direction | a-subsetting |a-redefinition)* + +a-property = + 'ordered' | 'nonunique' | 'abstract' | 'derived' | 'readonly' + +a-direction = + 'in' | 'out' | 'inout' + +a-subsetting = + 'subsets' OwnedSubsetting (',' OwnedSubsetting)* + +a-redefinition = + 'redefines' OwnedRedefinition (',' OwnedRedefinition)* + +connection-end = usage-node | usage-edge + +usage-edge =| connection-graphical | binding-connection + +connection-label = UsageDeclaration + +connection-def-graphical = + + | + + +general-relationship =| connection-def-graphical + +cdef-label = Identification + +n-ary-connection-def = + n-ary-def-connection-dot n-ary-def-segment+ + +n-ary-def-connection-dot = + + +n-ary-def-segment = + + +definition-node =| n-ary-def-connection-dot + +general-relationship =| n-ary-def-segment + +n-ary-connection = + n-ary-connection-dot n-ary-segment+ + +n-ary-connection-dot = + + +usage-node =| n-ary-connection-dot + +cdot-label = UsageDeclaration + +n-ary-segment = + + +binding-connection = + + +rolename = Identification? + +multiplicity = MultiplicityRange? + +connection-definition-elaboration = + + +connection-usage-elaboration = + + +// Note. The usage-nodes at the ends of a binding-connection must be of compatible types. + +// Clause 8.2.3.14 Interfaces Graphical Notation + +definition-node =| interface-def + +interconnection-element =| interface + +interface-def = + + +interface-def-name-compartment = + '«' DefinitionPrefix 'interface' 'def' '»' + definition-name-with-alias + +usage-node =| interface + +interface = + + +interface-name-compartment = + '«' OccurrenceUsagePrefix 'interface' '»' + usage-name-with-alias + +compartment =| + interfaces-compartment + | ends-compartment + +interfaces-compartment = + + interfaces-compartment-contents + +interfaces-compartment-contents = (interfaces-compartment-element)* '…'? + +interfaces-compartment-element = + el-prefix? OccurrenceUsagePrefix InterfaceUsageDeclaration + +ends-compartment = + + ends-compartment-contents + +ends-compartment-contents = (ends-compartment-element)* '…'? + +ends-compartment-element = QualifiedName (':' QualifiedName)? + +connection-relationship =| + interface-connection + +interface-connection = + + +interface-label = UsageDeclaration? + +// Clause 8.2.3.15 Allocations Graphical Notation + +definition-node =| allocation-def + +allocation-def = + + +allocation-def-name-compartment = + '«' DefinitionPrefix 'allocation' 'def' '»' + definition-name-with-alias + +usage-node =| allocation + +allocation = + + +allocation-name-compartment = + '«' OccurrenceUsagePrefix 'allocation' '»' + usage-name-with-alias + +compartment =| allocations-compartment + +allocations-compartment = + + allocations-compartment-contents + +allocations-compartment-contents = (allocations-compartment-element)* '…'? + +allocations-compartment-element = + el-prefix? OccurrenceUsagePrefix AllocationUsageDeclaration UsageBody* + +general-relationship =| allocate-relationship + +allocate-relationship = + + +allocation-node = + general-node + | element-in-textual-compartment + +usage-edge =| allocate-relationship + +// Clause 8.2.3.16 Flows Graphical Notation + +definition-node =| flow-def + +flow-def = + + +flow-def-name-compartment = + '«' DefinitionPrefix 'succession'? 'flow' 'def' '»' + definition-name-with-alias + +usage-node =| flow-node + +flow-node = + + +flow-name-compartment = + '«' OccurrenceUsagePrefix ( 'message' | 'succession'? 'flow' ) '»' + usage-name-with-alias + +compartment =| flows-compartment + +flows-compartment = + + flows-compartment-contents + +flows-compartment-contents = (flows-compartment-element)* '...'? + +flows-compartment-element = + el-prefix? OccurrenceUsagePrefix + ( 'message' MessageDeclaration + | 'succession'? FlowDeclaration + ) + +interconnection-element =| + flow-def + | flow + +connection-relationship =| + message-connection + | flow + | succession-flow + | flow-on-connection + +usage-edge =| message | flow | succession-flow + +msg-end-node = + occurrence| sq-l-node| item | part | port | action | state + | use-case | verification-case | analysis-case | proxy + +message = + + +// Note: proxy nodes and ends of messages must refer to occurrences + +message-label = + UsageDeclaration? ('of' FlowPayloadFeatureMember)? | FlowPayloadFeatureMember + +flow = + + +flow-label = + UsageDeclaration? ('of' FlowPayloadFeatureMember)? | FlowPayloadFeatureMember + +flow-end-node = + parameter | proxy + +// Note: proxy nodes at ends of flows must refer to directed features + +succession-flow = + + +succession-flow-label = flow-label + +flow-on-connection = + + +flow-node = + flow-node-r + | flow-node-l + | sflow-node-r + | sflow-node-l + | message-node-r + | message-node-l + +flow-node-r = + + +flow-node-l = + + +sflow-node-r = + + +sflow-node-l = + + +message-node-r = + + +message-node-l = + + +flow-label = + Identification | FlowPayloadFeatureMember + +// Clause 8.2.3.17 Actions Graphical Notation + +definition-node =| action-def + +action-def = + + +action-def-name-compartment = + '«' DefinitionPrefix 'action' 'def' '»' + definition-name-with-alias + +usage-node =| + action + | perform-action-usage + +action = + + +action-name-compartment = + '«' OccurrenceUsagePrefix 'action' '»' + usage-name-with-alias + +perform-action-usage = + + +action-ref = + + +perform-action-name-compartment = + '«' OccurrenceUsagePrefix 'perform' 'action' '»' + usage-name-with-alias + +compartment =| + actions-compartment + | perform-actions-compartment + | parameters-compartment + | action-flow-compartment + +actions-compartment = + + actions-compartment-contents + +actions-compartment-contents = (actions-compartment-element)* '…'? + +actions-compartment-element = + el-prefix? OccurrenceUsagePrefix ActionUsageDeclaration + +perform-actions-compartment = + + perform-actions-compartment-contents + +perform-actions-compartment-contents = (perform-actions-compartment-element)* '…'? + +perform-actions-compartment-element = + el-prefix? OccurrenceUsagePrefix PerformActionUsageDeclaration + +parameters-compartment = + + parameters-compartment-contents + +parameters-compartment-contents = (parameters-compartment-element)* '…'? + +parameters-compartment-element = + el-prefix? FeatureDirection UsageDeclaration ValueOrFlowPart? DefinitionBodyItem* + +performed-by-compartment = + + performed-by-compartment-contents + +performed-by-compartment-contents = QualifiedName* '…'? + +action-flow-compartment = + + action-flow-view + +action-flow-view = + (dependencies-and-annotations-element)* + (action-flow-element)* + (perform-action-swimlanes)? + +action-flow-element =| + action-ref + | action + | action-flow-node + | action-flow-relationship + +action-flow-node = + start-node + | done-node + | terminate-node + | fork-node + | join-node + | decision-node + | merge-node + | send-action-node + | accept-action-node + | while-loop-action-node + | for-loop-action-node + | if-else-action-node + | assign-action-node + +action-flow-relationship = + flow + | aflow-succession + | binding-connection + | else-branch + +param-l = + + | + + | + proxy-v + +param-r = + + | + + | + proxy-v + +param-t = + + | + + | + proxy-h + +param-b = + + | + + | + proxy-h + +param-label = QualifiedName (':' QualifiedName)* + +start-node = + + +done-node = + + +terminate-node = + + +fork-node = + + +join-node = + + +decision-node = + + +merge-node = + + +send-action-node = + + +send-action-name-compartment = + '«' OccurrenceUsagePrefix 'send' 'action' '»' + usage-name-with-alias + +send-action-expression = NodeParameterMember 'to' NodeParameterMember + +accept-action-node = + + +accept-action-name-compartment = + '«' OccurrenceUsagePrefix 'accept' 'action' '»' + usage-name-with-alias + +accept-action-expression = AcceptParameterPart + +while-loop-action-node = + + +while-condition = + + condition-expression + +until-condition = + + condition-expression + +while-loop-action-name-compartment = + '«' OccurrenceUsagePrefix 'loop' '»' + usage-name-with-alias + +for-loop-action-node = + + +iteration = + + iteration-expression + +loop-body = + + action-body + +for-loop-action-name-compartment = + '«' OccurrenceUsagePrefix 'loop' '»' + usage-name-with-alias + +if-else-action-node = + + +if-condition = + + condition-expression + +then-body = + + action-body + +else-body = + + action-body + +ifelse-action-name-compartment = + '«' OccurrenceUsagePrefix 'if' '»' + usage-name-with-alias + +action-body = + action-body-textual | action-flow-view + +condition-expression = + ExpressionParameterMember + +iteration-expression = + ForVariableDeclarationMember 'in' NodeParameterMember + +action-body-textual = + ActionBodyParameterMember + +assign-action-node = + + +assign-action-name-compartment = + '«' OccurrenceUsagePrefix 'assign' '»' + usage-name-with-alias + +perform-actions-swimlanes = (swimlane)* + +swimlane = + + +parameter = + param-l | param-r | param-t | param-b + +aflow-succession = + + +else-branch = + + +perform-edge = + + +performer-node = part | action | part-def | action-def | distinguished-parameter + +usage-edge =| succession perform-edge + +guard-expression = '[' OwnedExpression ']' + +// Note. All swimlanes are attached to each other on vertical edges and aligned along the top and bottom horizontal edges. + +// Note. The proxy option of a parameter production is valid only on an action usage contained within an action flow view. + +// Clause 8.2.3.18 States Graphical Notation + +definition-node =| state-def + +state-def = + + +state-def-name-compartment = + '«' DefinitionPrefix 'state' 'def' '»' + definition-name-with-alias + ('«' 'parallel' '»')? + +usage-node =| + state + | exhibit-state-usage + +state = + + +state-ref = + + +state-name-compartment = + '«' OccurrenceUsagePrefix 'state' '»' + usage-name-with-alias + ('«' 'parallel' '»')? + +exhibit-state-usage = + + +state-subaction-body = state-subaction-body-textual | action-flow-view + +state-subaction-body-textual = state-subaction-declaration? ( '{' ActionBodyItem* '}' )? + +state-subaction-declaration = + PerformActionUsageDeclaration + | AcceptNodeDeclaration + | SendNodeDeclaration + | AssignmentNodeDeclaration + +state-do-action = + + state-subaction-body + +state-entry-action = + + state-subaction-body + +state-exit-action = + + state-subaction-body + +entry-action = + + | + + +entry-action-name-comp = + '«' 'entry' OccurrenceUsagePrefix 'action' '»' + usage-name-with-alias + +exit-action = + + +exit-action-name-comp = + '«' 'exit' OccurrenceUsagePrefix 'action' '»' + usage-name-with-alias + +do-action = + + +do-action-name-comp = + '«' 'do' OccurrenceUsagePrefix 'action' '»' + usage-name-with-alias + +exhibit-state-name-compartment = + '«exhibit-state»' + state-name-compartment + +compartment =| + states-compartment + | state-actions-compartment + | exhibit-states-compartment + | successions-compartment + | state-transition-compartment + +states-compartment = + + states-compartment-contents + +states-compartment-contents = (states-compartment-element)* '…'? + +states-compartment-element = + el-prefix? OccurrenceUsagePrefix ActionUsageDeclaration + +state-actions-compartment = + + state-actions-compartment-contents + +state-actions-compartment-contents = (state-actions-compartment-element)* '…'? + +state-actions-compartment-element = + el-prefix? EntryActionMember | DoActionMember | ExitActionMember + +exhibit-states-compartment = + + exhibit-states-compartment-contents + +exhibit-states-compartment-contents = exhibit-state-scompartment-element* '…'? + +exhibit-states-compartment-element-compartment = UsageDeclaration + +successions-compartment = + + successions-compartment-contents + +successions-compartment-contents = QualifiedName* '…'? + +state-transition-compartment = + + state-transition-view + +state-transition-view = + (state-transition-element)* + (dependencies-and-annotations-element)* + +state-transition-element = + state-transition-node + | transition + | st-succession + +state-transition-node = + state + | state-ref + | start-node + | entry-action + | do-action + | exit-action + | done-node + | fork-node + | join-node + | decision-node + | merge-node + | terminate-node + | action + | perform-action-usage + | action-ref + +transition = + + | + + +state-source = + state | state-ref + +transition-label = trigger-expression '/' ActionUsage + +trigger-expression = AcceptParameterPart (guard-expression)? + +st-succession = + + | + + +exhibit-edge = + + +exhibitor = part | part-def + +general-relationship =| exhibit-edge + +usage-edge =| transition | st-succession | exhibit-edge + +// Clause 8.2.3.19 Calculations Graphical Notation + +definition-node =| calc-def + +calc-def = + + +calc-def-name-compartment = + '«' DefinitionPrefix 'calc' 'def' '»' + definition-name-with-alias + +usage-node =| calc + +calc = + + +calc-name-compartment = + '«' OccurrenceUsagePrefix 'calc' '»' + usage-name-with-alias + +action-flow-element =| + calc-def + | calc + +compartment =| + calcs-compartment + | result-compartment + +calcs-compartment = + + calcs-compartment-contents + +calcs-compartment-contents = calcs-compartment-element* '…'? + +calcs-compartment-element = el-prefix? OccurrenceUsagePrefix ActionUsageDeclaration + +result-compartment = + + result-compartment-contents + +result-compartment-contents = OwnedExpression + +// Clause 8.2.3.20 Constraints Graphical Notation + +definition-node =| constraint-def + +constraint-def = + + +constraint-def-name-compartment = + '«' DefinitionPrefix 'constraint' 'def' '»' + definition-name-with-alias + +usage-node = + constraint + | assert-constraint-node + +constraint = + + +constraint-ref = + + +constraint-name-compartment = + '«' OccurrenceUsagePrefix 'constraint' '»' + usage-name-with-alias + +assert-constraint-node = + + +assert-constraint-name-compartment = + '«assert constraint»' + constraint-name-compartment + +assume-constraint-node = + + +assume-constraint-name-compartment = + '«' OccurrenceUsagePrefix 'assume' 'constraint' '»' + usage-name-with-alias + +usage-node =| assume-constraint-node | assert-constraint-node + +assume-edge = + + +assumer = requirement | requirement-def + +general-relationship =| assume-edge + +assert-edge = + + +assertor = usage-node | definition-node + +general-relationship =| assert-edge + +compartment =| + constraints-compartment + | assert-constraints-compartment + +constraints-compartment = + + constraints-compartment-contents + +constraints-compartment-contents = (constraints-usage-compartment-element)* '…'? + +constraints-usage-compartment-element = + el-prefix? OccurrenceUsagePrefix ConstraintUsageDeclaration CalculationBody* + +assert-constraints-compartment = + + assert-constraints-compartment-contents + +assert-constraints-compartment-contents = (assert-constraints-compartment-element)* '…'? + +assert-constraints-compartment-element = + el-prefix? OccurrenceUsagePrefix ( 'not' )? + ( OwnedSubsetting FeatureSpecializationPart? | UsageDeclaration ) + CalculationUsageParameterPart CalculationBody + +interconnection-element =| + constraint-ref + | constraint + +// Clause 8.2.3.21 Requirements Graphical Notation + +definition-node =| + requirement-def + | concern-def + +requirement-def = + + +requirement-def-name-compartment = + '«' DefinitionPrefix 'requirement' 'def' '»' + definition-name-with-alias + +usage-node = + requirement + | satisfy-requirement-usage + | concern + +requirement = + + +requirement-ref = + + +requirement-name-compartment = + '«' OccurrenceUsagePrefix 'requirement' '»' + usage-name-with-alias + +satisfy-requirement-usage = + + +satisfy-requirement-name-compartment = + '«satisfy requirement»' + requirement-name-compartment + +concern-def = + + +concern-def-name-compartment = + '«' DefinitionPrefix 'concern' 'def' '»' + definition-name-with-alias + +concern = + + +concern-name-compartment = + '«' OccurrenceUsagePrefix 'concern' '»' + usage-name-with-alias + +compartment =| + constraints-compartment + | assert-constraints-compartment + +compartment =| + requirements-compartment + | require-constraints-compartment + | assume-constraints-compartment + | satisfy-requirements-compartment + | satisfies-compartment + | actors-compartment + | subject-compartment + | stakeholders-compartment + | frames-compartment + +requirements-compartment = + + requirements-compartment-contents + +requirements-compartment-contents = (requirements-compartment-element)* '…'? + +requirements-compartment-element = + OccurrenceUsagePrefix ConstraintUsageDeclaration + +require-constraints-compartment = + + require-constraints-compartment-contents + +require-constraints-compartment-contents = require-constraint-element* '…'? + +require-constraint-element = + el-prefix? requireMemberPrefix? RequirementConstraintUsage + +assume-constraints-compartment = + + assume-constraints-compartment-contents + +assume-constraints-compartment-contents = require-constraint-element* '…'? + +satisfy-requirements-compartment = + + satisfy-requirements-compartment-contents + +satisfy-requirements-compartment-contents = text-block + +satisfies-compartment = + + satisfies-compartment-contents + +satisfies-compartment-contents = UsageDeclaration* '…'? + +actors-compartment = + + actors-compartment-contents + +actors-compartment-contents = (actors-compartment-element)* '…'? + +actors-compartment-element = el-prefix? MemberPrefix usage-cp + +subject-compartment = + + subject-compartment-contents + +subject-compartment-contents = (subject-compartment-element)* '…'? + +subject-compartment-element = el-prefix? MemberPrefix usage-cp + +stakeholders-compartment = + + stakeholders-compartment-contents + +stakeholders-compartment-contents = (stakeholders-compartment-element)* '…'? + +stakeholders-compartment-element = el-prefix? MemberPrefix usage-cp + +frames-compartment = + + frames-compartment-contents + +frames-compartment-contents = (frames-compartment-element)* '…'? + +frames-compartment-element = el-prefix* MemberPrefix? FramedConcernUsage + +concerns-compartment = + + concerns-compartment-contents + +interconnection-element =| + requirement-ref + | requirement + | concern + | distinguished-parameter + | distinguished-parameter-link + | concern-stakeholder-link + +general-relationship =| frame-relationship + +subject-actors-stakeholders-node =| requirement + +distinguished-parameter = + subject + | actor + | stakeholder + +subject = + + +actor = + + | + + +stakeholder = + + +subject-name = UsageDeclaration + +actor-name = UsageDeclaration + +stakeholder-name = UsageDeclaration + +distinguished-parameter-link = + + +frame-relationship = + + +concern-stakeholder-link = + + +satisfy-edge = + + +satisfier = usage-node | definition-node + +general-relationship =| satisfy-edge + +require-edge = + + +requirer = usage-node | definition-node + +general-relationship =| require-edge + +require-constraint-node = + + +require-constraint-name-compartment = + '«' OccurrenceUsagePrefix 'require' 'constraint' '»' + usage-name-with-alias + +usage-node =| require-constraint-node + +frame-concern-node = + + +frame-concern-name-compartment = + '«' OccurrenceUsagePrefix 'frame' 'concern' '»' + usage-name-with-alias + +usage-node =| frame-concern-node + +frame-edge = + + +framer = requirement | requirement-def | viewpoint | viewpoint-def + +general-relationship =| frame-edge + +// Clause 8.2.3.22 Cases Graphical Notation + +compartment =| objective-compartment + +objective-compartment = + + objective-compartment-contents + +objective-compartment-contents = (objective-compartment-element)* '…'? + +objective-compartment-element = + comp-prefix? MemberPrefix ConstraintUsageDeclaration RequirementBody + +// Clause 8.2.3.23 Analysis Cases Graphical Notation + +definition-node =| analysis-def + +analysis-def = + + +analysis-def-name-compartment = + '«' DefinitionPrefix 'analysis' 'def' '»' + definition-name-with-alias + +usage-node =| analysis + +analysis = + + +analysis-name-compartment = + '«' OccurrenceUsagePrefix 'analysis' '»' + usage-name-with-alias + +compartment =| analyses-compartment + +analyses-compartment = + + analyses-compartment-contents + +analyses-compartment-contents = analyses-compartment-element* '…'? + +analyses-compartment-element = + el-prefix? OccurrenceUsagePrefix ConstraintUsageDeclaration CaseBody + +action-flow-element =| + analysis-def + | analysis + +subject-actors-stakeholders-node =| analysis | analysis-def + +// Clause 8.2.3.24 Verification Cases Graphical Notation + +definition-node =| verification-def + +verification-def = + + +verification-def-name-compartment = + '«' DefinitionPrefix 'verification' 'def' '»' + definition-name-with-alias + +usage-node =| verification + +verification = + + +verification-name-compartment = + '«' OccurrenceUsagePrefix 'verification' '»' + usage-name-with-alias + +verify-requirement-node = + + +verify-requirement-name-compartment = + '«' OccurrenceUsagePrefix 'verify' 'requirement' '»' + usage-name-with-alias + +usage-node =| verify-requirement-node + +compartment =| + verifications-compartment + | verifies-compartment + | verification-methods-compartment + +verifications-compartment = + + verifications-compartment-contents + +verifications-compartment-contents = (verifications-compartment-element)* '…'? + +verifications-compartment-element = + el-prefix? OccurrenceUsagePrefix ConstraintUsageDeclaration CaseBody '…' + +verifies-compartment = + + verifies-compartment-contents + +verifies-compartment-contents = (verifies-compartment-element)* '…'? + +verifies-compartment-element = el-prefix? MemberPrefix RequirementVerificationUsage '…' + +verification-methods-compartment = + + verification-methods-compartment-contents + +verification-methods-compartment-contents = (verification-methods-compartment-element)* '…'? + +verification-methods-compartment-element = MetadataBody + +action-flow-element =| + verification-def + | verification + +general-relationship =| verify-relationship + +verify-relationship = + + +subject-actors-stakeholders-node =| verification | verification-def + +// Clause 8.2.3.25 Use Cases Graphical Notation + +definition-node =| use-case-def + +use-case-def = + + +use-case-def-name-compartment = + '«' DefinitionPrefix 'use' 'case' 'def' '»' + definition-name-with-alias + +usage-node =| + use-case + | include-use-case-usage + +use-case = + + +use-case-name-compartment = + '«' OccurrenceUsagePrefix 'use' 'case' '»' + usage-name-with-alias + +include-use-case-usage = + + +include-use-case-name-compartment = + '«include use case»' + requirement-name-compartment + +compartment =| + use-cases-compartment + | include-actions-compartment + | includes-compartment + +use-cases-compartment = + + use-cases-compartment-contents + +use-cases-compartment-contents = use-cases-compartment-element* '…'? + +use-cases-compartment-element = el-prefix? OccurrenceUsagePrefix ConstraintUsageDeclaration + +include-use-cases-compartment = + + include-use-cases-compartment-contents + +include-use-cases-compartment-contents = (include-use-cases-compartment-element)* '…'? + +include-use-cases-compartment-element = + el-prefix? OccurrenceUsagePrefix + ( OwnedSubsetting FeatureSpecializationPart? | UsageDeclaration ) + ( ValuePart | ActionUsageParameterList )? CaseBody + +includes-compartment = + + includes-compartment-contents + +includes-compartment-contents = (includes-compartment-element)* '…'? + +includes-compartment-element = + el-prefix? OccurrenceUsagePrefix + ( OwnedSubsetting FeatureSpecializationPart? | UsageDeclaration ) + +action-flow-element =| + use-case-def + | use-case + +general-relationship =| include-use-case-relationship + +include-use-case-relationship = + + +subject-actors-stakeholders-node =| use-case | use-case-def + +// Clause 8.2.3.26 Views and Viewpoints Graphical Notation + +root-view = + framed-view + +definition-node =| + viewpoint-def + | view-def + +viewpoint-def = + + +viewpoint-def-name-compartment = + '«' DefinitionPrefix 'viewpoint' 'def' '»' + definition-name-with-alias + +view-def = + + +view-def-name-compartment = + '«' DefinitionPrefix 'view' 'def' '»' + definition-name-with-alias + +usage-node =| + viewpoint + | view + | framed-view + +viewpoint = + + +viewpoint-name-compartment = + '«' OccurrenceUsagePrefix 'viewpoint' '»' + usage-name-with-alias + +view = + + +view-name-compartment = + '«' OccurrenceUsagePrefix 'view' '»' + usage-name-with-alias + +compartment =| + views-compartment + | viewpoints-compartment + | exposes-compartment + | filters-compartment + | rendering-compartment + +views-compartment = + + views-compartment-contents + +views-compartment-contents = (views-compartment-element)* '…' + +views-compartment-element = + el-prefix? OccurrenceUsagePrefix UsageDeclaration? ValueOrFlowPart? ViewBody + +viewpoints-compartment = + + viewpoints-compartment-contents + +viewpoints-compartment-contents = (viewpoints-compartment-element)* '…'? + +viewpoints-compartment-element = + el-prefix? OccurrenceUsagePrefix ConstraintUsageDeclaration RequirementBody + +exposes-compartment = + + exposes-compartment-contents + +exposes-compartment-contents = exposes-compartment-element* '…'? + +exposes-compartment-element = MembershipExpose | NamespaceExpose + +filters-compartment = + + filters-compartment-contents + +filters-compartment-contents = (filters-compartment-element)* '…'? + +filters-compartment-element = el-prefix? MemberPrefix OwnedExpression + +rendering-compartment = + + rendering-compartment-contents + +rendering-compartment-contents = usage-cp* '…'? + +interconnection-element =| + viewpoint-def + | viewpoint + | view-def + | view + +framed-view = + + +frameless-view = + general-view + | interconnection-view + | action-flow-view + | state-transition-view + | sequence-view + +view-frame-name-compartment = '«view»' QualifiedName (':' QualifiedName)? + +view-frame-info-contents = Expose? ElementFilterMember? AnnotatingElement* + +view-frame-info-compartment-tr = + + +view-frame-info-compartment-bl = + + +view-frame-info-compartment-br = + + +general-relationship =| expose-relationship + +expose-relationship = + expose-r | toplevel-expose-r | recursive-expose-r + +expose-r = + + +toplevel-expose-r = + + +recursive-expose-r = + + +// Note. The view frame info compartments are optional elements. The AnnotatingElement* enables adding any relevant supporting information related to a view, possibly using a configurable rendering. + +// Note. A model library in Section 9.2.18 defines standard graphical view definitions for SysML. These may be supplemented by further, customized view definitions specific to a model. + +// Clause 8.2.3.27 Metadata Graphical Notation + +annotation-node =| metadata-feature-annotation-node + +metadata-feature-annotation-node = + + +metadata-feature-decl = Identification + +metadata-feature-name-value-list = + ( metadata-feature-name '=' expression-text )* + +metadata-feature-name = Identification + +expression-text = text-block + +metadata-def = + + +metadata-def-name-compartment = + '«' BasicUsagePrefix? keyword* 'metadata' 'def' '»' + definition-name-with-alias + +// End of BNF + + + +// Consolidated partial productions: + +// action-flow-element = +// action | action-flow-node | action-flow-relationship | action-ref | analysis | analysis-def | calc | calc-def +// | use-case | use-case-def | verification | verification-def + +// annotation-node = +// metadata-feature-annotation-node + +// compartment = +// action-flow-compartment | actions-compartment | actors-compartment | allocations-compartment | analyses-compartment +// | assert-constraints-compartment | assert-constraints-compartment | assume-constraints-compartment +// | attributes-compartment | calcs-compartment | connections-compartment | constraints-compartment +// | constraints-compartment | directed-features-compartment | ends-compartment | enums-compartment +// | exhibit-states-compartment | exposes-compartment | features-compartment | filters-compartment | flows-compartment +// | frames-compartment | general-compartment | include-actions-compartment | includes-compartment +// | individuals-compartment | interconnection-compartment | interfaces-compartment | items-compartment +// | objective-compartment | occurrences-compartment | package-compartment | parameters-compartment | parts-compartment +// | perform-actions-compartment | ports-compartment | rendering-compartment | require-constraints-compartment +// | requirements-compartment | result-compartment | satisfies-compartment | satisfy-requirements-compartment +// | sequence-compartment | snapshots-compartment | stakeholders-compartment | state-actions-compartment +// | state-transition-compartment | states-compartment | subject-compartment | successions-compartment +// | timeslices-compartment | use-cases-compartment | variant-elementusages-compartment | variants-compartment +// | verification-methods-compartment | verifications-compartment | verifies-compartment | viewpoints-compartment +// | views-compartment + +// connection-relationship = +// flow | flow-on-connection | interface-connection | message-connection | succession-flow + +// definition-node = +// action-def | allocation-def | analysis-def | attribute-def | calc-def | concern-def | connection-def +// | constraint-def | enumeration-def | event-occurrence-def | extended-def | flow-def | interface-def | item-def +// | n-ary-def-connection-dot | occurrence-def | part-def | port-def | requirement-def | state-def | use-case-def +// | verification-def | view-def | viewpoint-def + +// dependencies-and-annotations-element = +// annotation-link | annotation-node | dependencies-element + +// dependencies-element = +// binary-dependency | n-ary-dependency + +// general-node = +// definition-node | namespace-node | type-node | usage-node + +// general-relationship = +// allocate-relationship | assert-edge | assume-edge | connection-def-graphical | exhibit-edge | expose-relationship +// | frame-edge | frame-relationship | import | include-use-case-relationship | n-ary-def-segment | owned-membership +// | portion-relationship | recursive-import | require-edge | satisfy-edge | top-level-import | type-relationship +// | unowned-membership | verify-relationship + +// general-view = +// interconnection-view + +// interconnection-element = +// attribute | concern | concern-stakeholder-link | connection | connection-def | connection-relationship | constraint +// | constraint-ref | distinguished-parameter | distinguished-parameter-link | flow | flow-def | interface | item +// | item-ref | part | part-ref | port-def | port-usage | requirement | requirement-ref | view | view-def | viewpoint +// | viewpoint-def + +// interconnection-view = +// dependencies-and-annotations-element | ellipsis-at-lower-left-corner | interconnection-element + +// namespace-node = +// package-node | type-node + +// subject-actors-stakeholders-node = +// analysis | analysis-def | requirement | use-case | use-case-def | verification | verification-def + +// usage-edge = +// allocate-relationship | binding-connection | connection-graphical | exhibit-edge | flow | message | perform-edge +// | st-succession | succession | succession-flow | transition + +// usage-node = +// action | allocation | analysis | assert-constraint-node | assume-constraint-node | attribute | calc | connection +// | enumeration | event-occurrence | exhibit-state-usage | extended-usage | flow-node | frame-concern-node | framed-view +// | include-use-case-usage | interface | item | n-ary-connection-dot | occurrence | occurrence-ref | part +// | perform-action-usage | port-usage | require-constraint-node | state | timeslice-or-snapshot-node | use-case +// | verification | verify-requirement-node | view | viewpoint + diff --git a/Resources/kgbnf.g4 b/Resources/kgbnf.g4 new file mode 100644 index 000000000..2cb479716 --- /dev/null +++ b/Resources/kgbnf.g4 @@ -0,0 +1,71 @@ +// Grammar + +grammar kgbnf; + +specification : (NL)* rule_definition+ EOF ; + +rule_definition + : name=GRAPHICAL_NAME op=(ASSIGN | PARTIAL_ASSIGN) rule_body=alternatives NL+ + ; + +alternatives + : alternative (PIPE alternative)* + ; + +alternative + : element* + ; + +element + : group + | terminal + | image + | edge_end + | non_terminal + ; + +group + : LPAREN alternatives RPAREN (suffix=suffix_op)? + ; + +terminal + : val=SINGLE_QUOTED_STRING (suffix=suffix_op)? + ; + +image + : IMG_OPEN attribute* TAG_CLOSE + ; + +attribute + : attribute_name=GRAPHICAL_NAME ASSIGN attribute_value=DOUBLE_QUOTED_STRING + ; + +edge_end + : AMPERSAND name=GRAPHICAL_NAME (suffix=suffix_op)? + ; + +non_terminal + : name=(GRAPHICAL_NAME | TEXTUAL_NAME) (suffix=suffix_op)? + ; + +suffix_op : '*' | '+' | '?' ; + +// Lexer +PARTIAL_ASSIGN : '=|' | '|=' ; +ASSIGN : '=' ; +PIPE : '|' ; +LPAREN : '(' ; +RPAREN : ')' ; +AMPERSAND : '&' ; +IMG_OPEN : '' ; + +GRAPHICAL_NAME : [a-z]+ ('-' [a-z]+)* ; +TEXTUAL_NAME : [a-zA-Z_] [a-zA-Z0-9_]* ; +SINGLE_QUOTED_STRING : '\'' (~['\\] | '\\' .)* '\'' ; +DOUBLE_QUOTED_STRING : '"' ~["\r\n]* '"' ; + +COMMENT : '//' ~[\r\n]* -> skip ; +WS : [ \t]+ -> skip ; +CONTINUATION : '\r'? '\n' [ \t]+ -> skip ; +NL : '\r'? '\n' ; diff --git a/SysML2.NET.CodeGenerator.Tests/Grammar/GraphicalNotationSpecificationVisitorTestFixture.cs b/SysML2.NET.CodeGenerator.Tests/Grammar/GraphicalNotationSpecificationVisitorTestFixture.cs new file mode 100644 index 000000000..02cf4c09f --- /dev/null +++ b/SysML2.NET.CodeGenerator.Tests/Grammar/GraphicalNotationSpecificationVisitorTestFixture.cs @@ -0,0 +1,96 @@ +// ------------------------------------------------------------------------------------------------ +// +// +// Copyright (C) 2022-2026 Starion Group S.A. +// SPDX-License-Identifier: Apache-2.0 +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.CodeGenerator.Tests.Grammar +{ + using System.IO; + using System.Linq; + + using Antlr4.Runtime; + + using NUnit.Framework; + + using SysML2.NET.CodeGenerator.Grammar; + using SysML2.NET.CodeGenerator.Grammar.Model; + + [TestFixture] + public class GraphicalNotationSpecificationVisitorTestFixture + { + [Test] + public void VerifyCanParseGrammar() + { + var filePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "datamodel", "SysML-graphical-bnf.kgbnf"); + + var (specification, syntaxErrorCount) = Parse(CharStreams.fromPath(filePath)); + var rules = specification.Rules; + + using (Assert.EnterMultipleScope()) + { + Assert.That(syntaxErrorCount, Is.Zero); + Assert.That(rules, Is.Not.Empty); + Assert.That(rules.Where(rule => rule.RuleName == "compartment").Select(rule => rule.IsPartial), Is.Not.Empty.And.All.True); + } + + var element = rules.Single(rule => rule.RuleName == "element"); + + using (Assert.EnterMultipleScope()) + { + Assert.That(element.IsPartial, Is.False); + Assert.That(element.Alternatives, Has.Count.EqualTo(3)); + Assert.That(element.Alternatives[1].Elements[0], Is.TypeOf().With.Property("Name").EqualTo("general-element")); + } + + var generalCompartment = rules.Single(rule => rule.RuleName == "general-compartment").Alternatives[0].Elements; + + using (Assert.EnterMultipleScope()) + { + Assert.That(generalCompartment, Has.Count.EqualTo(2)); + Assert.That(generalCompartment[0], Is.TypeOf().With.Property("Source").EqualTo("images/general-compartment.svg")); + Assert.That(generalCompartment[1], Is.TypeOf().With.Property("IsTextualReference").False); + } + + Assert.That(rules.Single(rule => rule.RuleName == "expose-r").Alternatives[0].Elements[0], + Is.TypeOf().With.Property("Source").EqualTo("images/expose-r.svg")); + + var usageCompartmentElements = rules.Single(rule => rule.RuleName == "usage-cp").Alternatives[0].Elements; + + using (Assert.EnterMultipleScope()) + { + Assert.That(usageCompartmentElements[0], Is.TypeOf().With.Property("IsTextualReference").True); + Assert.That(usageCompartmentElements[1], Is.TypeOf().With.Property("Name").EqualTo("ValuePart")); + Assert.That(usageCompartmentElements[1].Suffix, Is.EqualTo("?")); + } + + var naryDependency = rules.Single(rule => rule.RuleName == "n-ary-dependency").Alternatives[0].Elements; + + using (Assert.EnterMultipleScope()) + { + Assert.That(naryDependency[0], Is.TypeOf().With.Property("Name").EqualTo("n-ary-association-dot")); + Assert.That(naryDependency[1], Is.TypeOf().With.Property("Suffix").EqualTo("+")); + Assert.That(((GraphicalGroupElement)naryDependency[1]).Alternatives[0].Elements[1], Is.TypeOf()); + } + + Assert.That(rules.Single(rule => rule.RuleName == "ellipsis-at-lower-left-corner").Alternatives[0].Elements[0], + Is.TypeOf().With.Property("Value").EqualTo("...")); + + (_, syntaxErrorCount) = Parse(CharStreams.fromString("broken = ( element\n")); + + Assert.That(syntaxErrorCount, Is.GreaterThan(0)); + } + + private static (GraphicalNotationSpecification Specification, int SyntaxErrorCount) Parse(ICharStream stream) + { + var parser = new kgbnfParser(new CommonTokenStream(new kgbnfLexer(stream))); + var tree = parser.specification(); + var specification = (GraphicalNotationSpecification)new GraphicalNotationSpecificationVisitor().Visit(tree); + + return (specification, parser.NumberOfSyntaxErrors); + } + } +} diff --git a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnf.interp b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnf.interp new file mode 100644 index 000000000..5edff5885 --- /dev/null +++ b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnf.interp @@ -0,0 +1,61 @@ +token literal names: +null +'*' +'+' +'?' +null +'=' +'|' +'(' +')' +'&' +'' +null +null +null +null +null +null +null +null + +token symbolic names: +null +null +null +null +PARTIAL_ASSIGN +ASSIGN +PIPE +LPAREN +RPAREN +AMPERSAND +IMG_OPEN +TAG_CLOSE +GRAPHICAL_NAME +TEXTUAL_NAME +SINGLE_QUOTED_STRING +DOUBLE_QUOTED_STRING +COMMENT +WS +CONTINUATION +NL + +rule names: +specification +rule_definition +alternatives +alternative +element +group +terminal +image +attribute +edge_end +non_terminal +suffix_op + + +atn: +[4, 1, 19, 101, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 1, 0, 5, 0, 26, 8, 0, 10, 0, 12, 0, 29, 9, 0, 1, 0, 4, 0, 32, 8, 0, 11, 0, 12, 0, 33, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 42, 8, 1, 11, 1, 12, 1, 43, 1, 2, 1, 2, 1, 2, 5, 2, 49, 8, 2, 10, 2, 12, 2, 52, 9, 2, 1, 3, 5, 3, 55, 8, 3, 10, 3, 12, 3, 58, 9, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 65, 8, 4, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 71, 8, 5, 1, 6, 1, 6, 3, 6, 75, 8, 6, 1, 7, 1, 7, 5, 7, 79, 8, 7, 10, 7, 12, 7, 82, 9, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 3, 9, 93, 8, 9, 1, 10, 1, 10, 3, 10, 97, 8, 10, 1, 11, 1, 11, 1, 11, 0, 0, 12, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 0, 3, 1, 0, 4, 5, 1, 0, 12, 13, 1, 0, 1, 3, 102, 0, 27, 1, 0, 0, 0, 2, 37, 1, 0, 0, 0, 4, 45, 1, 0, 0, 0, 6, 56, 1, 0, 0, 0, 8, 64, 1, 0, 0, 0, 10, 66, 1, 0, 0, 0, 12, 72, 1, 0, 0, 0, 14, 76, 1, 0, 0, 0, 16, 85, 1, 0, 0, 0, 18, 89, 1, 0, 0, 0, 20, 94, 1, 0, 0, 0, 22, 98, 1, 0, 0, 0, 24, 26, 5, 19, 0, 0, 25, 24, 1, 0, 0, 0, 26, 29, 1, 0, 0, 0, 27, 25, 1, 0, 0, 0, 27, 28, 1, 0, 0, 0, 28, 31, 1, 0, 0, 0, 29, 27, 1, 0, 0, 0, 30, 32, 3, 2, 1, 0, 31, 30, 1, 0, 0, 0, 32, 33, 1, 0, 0, 0, 33, 31, 1, 0, 0, 0, 33, 34, 1, 0, 0, 0, 34, 35, 1, 0, 0, 0, 35, 36, 5, 0, 0, 1, 36, 1, 1, 0, 0, 0, 37, 38, 5, 12, 0, 0, 38, 39, 7, 0, 0, 0, 39, 41, 3, 4, 2, 0, 40, 42, 5, 19, 0, 0, 41, 40, 1, 0, 0, 0, 42, 43, 1, 0, 0, 0, 43, 41, 1, 0, 0, 0, 43, 44, 1, 0, 0, 0, 44, 3, 1, 0, 0, 0, 45, 50, 3, 6, 3, 0, 46, 47, 5, 6, 0, 0, 47, 49, 3, 6, 3, 0, 48, 46, 1, 0, 0, 0, 49, 52, 1, 0, 0, 0, 50, 48, 1, 0, 0, 0, 50, 51, 1, 0, 0, 0, 51, 5, 1, 0, 0, 0, 52, 50, 1, 0, 0, 0, 53, 55, 3, 8, 4, 0, 54, 53, 1, 0, 0, 0, 55, 58, 1, 0, 0, 0, 56, 54, 1, 0, 0, 0, 56, 57, 1, 0, 0, 0, 57, 7, 1, 0, 0, 0, 58, 56, 1, 0, 0, 0, 59, 65, 3, 10, 5, 0, 60, 65, 3, 12, 6, 0, 61, 65, 3, 14, 7, 0, 62, 65, 3, 18, 9, 0, 63, 65, 3, 20, 10, 0, 64, 59, 1, 0, 0, 0, 64, 60, 1, 0, 0, 0, 64, 61, 1, 0, 0, 0, 64, 62, 1, 0, 0, 0, 64, 63, 1, 0, 0, 0, 65, 9, 1, 0, 0, 0, 66, 67, 5, 7, 0, 0, 67, 68, 3, 4, 2, 0, 68, 70, 5, 8, 0, 0, 69, 71, 3, 22, 11, 0, 70, 69, 1, 0, 0, 0, 70, 71, 1, 0, 0, 0, 71, 11, 1, 0, 0, 0, 72, 74, 5, 14, 0, 0, 73, 75, 3, 22, 11, 0, 74, 73, 1, 0, 0, 0, 74, 75, 1, 0, 0, 0, 75, 13, 1, 0, 0, 0, 76, 80, 5, 10, 0, 0, 77, 79, 3, 16, 8, 0, 78, 77, 1, 0, 0, 0, 79, 82, 1, 0, 0, 0, 80, 78, 1, 0, 0, 0, 80, 81, 1, 0, 0, 0, 81, 83, 1, 0, 0, 0, 82, 80, 1, 0, 0, 0, 83, 84, 5, 11, 0, 0, 84, 15, 1, 0, 0, 0, 85, 86, 5, 12, 0, 0, 86, 87, 5, 5, 0, 0, 87, 88, 5, 15, 0, 0, 88, 17, 1, 0, 0, 0, 89, 90, 5, 9, 0, 0, 90, 92, 5, 12, 0, 0, 91, 93, 3, 22, 11, 0, 92, 91, 1, 0, 0, 0, 92, 93, 1, 0, 0, 0, 93, 19, 1, 0, 0, 0, 94, 96, 7, 1, 0, 0, 95, 97, 3, 22, 11, 0, 96, 95, 1, 0, 0, 0, 96, 97, 1, 0, 0, 0, 97, 21, 1, 0, 0, 0, 98, 99, 7, 2, 0, 0, 99, 23, 1, 0, 0, 0, 11, 27, 33, 43, 50, 56, 64, 70, 74, 80, 92, 96] \ No newline at end of file diff --git a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnf.tokens b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnf.tokens new file mode 100644 index 000000000..96daeed64 --- /dev/null +++ b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnf.tokens @@ -0,0 +1,29 @@ +T__0=1 +T__1=2 +T__2=3 +PARTIAL_ASSIGN=4 +ASSIGN=5 +PIPE=6 +LPAREN=7 +RPAREN=8 +AMPERSAND=9 +IMG_OPEN=10 +TAG_CLOSE=11 +GRAPHICAL_NAME=12 +TEXTUAL_NAME=13 +SINGLE_QUOTED_STRING=14 +DOUBLE_QUOTED_STRING=15 +COMMENT=16 +WS=17 +CONTINUATION=18 +NL=19 +'*'=1 +'+'=2 +'?'=3 +'='=5 +'|'=6 +'('=7 +')'=8 +'&'=9 +''=11 diff --git a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfBaseListener.cs b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfBaseListener.cs new file mode 100644 index 000000000..a980b787a --- /dev/null +++ b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfBaseListener.cs @@ -0,0 +1,197 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// ANTLR Version: 4.13.2 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +// Generated from Resources/kgbnf.g4 by ANTLR 4.13.2 + +// Unreachable code detected +#pragma warning disable 0162 +// The variable '...' is assigned but its value is never used +#pragma warning disable 0219 +// Missing XML comment for publicly visible type or member '...' +#pragma warning disable 1591 +// Ambiguous reference in cref attribute +#pragma warning disable 419 + +namespace SysML2.NET.CodeGenerator.Grammar { + +using Antlr4.Runtime.Misc; +using IErrorNode = Antlr4.Runtime.Tree.IErrorNode; +using ITerminalNode = Antlr4.Runtime.Tree.ITerminalNode; +using IToken = Antlr4.Runtime.IToken; +using ParserRuleContext = Antlr4.Runtime.ParserRuleContext; + +/// +/// This class provides an empty implementation of , +/// which can be extended to create a listener which only needs to handle a subset +/// of the available methods. +/// +[System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.13.2")] +[System.Diagnostics.DebuggerNonUserCode] +[System.CLSCompliant(false)] +public partial class kgbnfBaseListener : IkgbnfListener { + /// + /// Enter a parse tree produced by . + /// The default implementation does nothing. + /// + /// The parse tree. + public virtual void EnterSpecification([NotNull] kgbnfParser.SpecificationContext context) { } + /// + /// Exit a parse tree produced by . + /// The default implementation does nothing. + /// + /// The parse tree. + public virtual void ExitSpecification([NotNull] kgbnfParser.SpecificationContext context) { } + /// + /// Enter a parse tree produced by . + /// The default implementation does nothing. + /// + /// The parse tree. + public virtual void EnterRule_definition([NotNull] kgbnfParser.Rule_definitionContext context) { } + /// + /// Exit a parse tree produced by . + /// The default implementation does nothing. + /// + /// The parse tree. + public virtual void ExitRule_definition([NotNull] kgbnfParser.Rule_definitionContext context) { } + /// + /// Enter a parse tree produced by . + /// The default implementation does nothing. + /// + /// The parse tree. + public virtual void EnterAlternatives([NotNull] kgbnfParser.AlternativesContext context) { } + /// + /// Exit a parse tree produced by . + /// The default implementation does nothing. + /// + /// The parse tree. + public virtual void ExitAlternatives([NotNull] kgbnfParser.AlternativesContext context) { } + /// + /// Enter a parse tree produced by . + /// The default implementation does nothing. + /// + /// The parse tree. + public virtual void EnterAlternative([NotNull] kgbnfParser.AlternativeContext context) { } + /// + /// Exit a parse tree produced by . + /// The default implementation does nothing. + /// + /// The parse tree. + public virtual void ExitAlternative([NotNull] kgbnfParser.AlternativeContext context) { } + /// + /// Enter a parse tree produced by . + /// The default implementation does nothing. + /// + /// The parse tree. + public virtual void EnterElement([NotNull] kgbnfParser.ElementContext context) { } + /// + /// Exit a parse tree produced by . + /// The default implementation does nothing. + /// + /// The parse tree. + public virtual void ExitElement([NotNull] kgbnfParser.ElementContext context) { } + /// + /// Enter a parse tree produced by . + /// The default implementation does nothing. + /// + /// The parse tree. + public virtual void EnterGroup([NotNull] kgbnfParser.GroupContext context) { } + /// + /// Exit a parse tree produced by . + /// The default implementation does nothing. + /// + /// The parse tree. + public virtual void ExitGroup([NotNull] kgbnfParser.GroupContext context) { } + /// + /// Enter a parse tree produced by . + /// The default implementation does nothing. + /// + /// The parse tree. + public virtual void EnterTerminal([NotNull] kgbnfParser.TerminalContext context) { } + /// + /// Exit a parse tree produced by . + /// The default implementation does nothing. + /// + /// The parse tree. + public virtual void ExitTerminal([NotNull] kgbnfParser.TerminalContext context) { } + /// + /// Enter a parse tree produced by . + /// The default implementation does nothing. + /// + /// The parse tree. + public virtual void EnterImage([NotNull] kgbnfParser.ImageContext context) { } + /// + /// Exit a parse tree produced by . + /// The default implementation does nothing. + /// + /// The parse tree. + public virtual void ExitImage([NotNull] kgbnfParser.ImageContext context) { } + /// + /// Enter a parse tree produced by . + /// The default implementation does nothing. + /// + /// The parse tree. + public virtual void EnterAttribute([NotNull] kgbnfParser.AttributeContext context) { } + /// + /// Exit a parse tree produced by . + /// The default implementation does nothing. + /// + /// The parse tree. + public virtual void ExitAttribute([NotNull] kgbnfParser.AttributeContext context) { } + /// + /// Enter a parse tree produced by . + /// The default implementation does nothing. + /// + /// The parse tree. + public virtual void EnterEdge_end([NotNull] kgbnfParser.Edge_endContext context) { } + /// + /// Exit a parse tree produced by . + /// The default implementation does nothing. + /// + /// The parse tree. + public virtual void ExitEdge_end([NotNull] kgbnfParser.Edge_endContext context) { } + /// + /// Enter a parse tree produced by . + /// The default implementation does nothing. + /// + /// The parse tree. + public virtual void EnterNon_terminal([NotNull] kgbnfParser.Non_terminalContext context) { } + /// + /// Exit a parse tree produced by . + /// The default implementation does nothing. + /// + /// The parse tree. + public virtual void ExitNon_terminal([NotNull] kgbnfParser.Non_terminalContext context) { } + /// + /// Enter a parse tree produced by . + /// The default implementation does nothing. + /// + /// The parse tree. + public virtual void EnterSuffix_op([NotNull] kgbnfParser.Suffix_opContext context) { } + /// + /// Exit a parse tree produced by . + /// The default implementation does nothing. + /// + /// The parse tree. + public virtual void ExitSuffix_op([NotNull] kgbnfParser.Suffix_opContext context) { } + + /// + /// The default implementation does nothing. + public virtual void EnterEveryRule([NotNull] ParserRuleContext context) { } + /// + /// The default implementation does nothing. + public virtual void ExitEveryRule([NotNull] ParserRuleContext context) { } + /// + /// The default implementation does nothing. + public virtual void VisitTerminal([NotNull] ITerminalNode node) { } + /// + /// The default implementation does nothing. + public virtual void VisitErrorNode([NotNull] IErrorNode node) { } +} +} // namespace SysML2.NET.CodeGenerator.Grammar diff --git a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfBaseVisitor.cs b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfBaseVisitor.cs new file mode 100644 index 000000000..d5d277c94 --- /dev/null +++ b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfBaseVisitor.cs @@ -0,0 +1,159 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// ANTLR Version: 4.13.2 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +// Generated from Resources/kgbnf.g4 by ANTLR 4.13.2 + +// Unreachable code detected +#pragma warning disable 0162 +// The variable '...' is assigned but its value is never used +#pragma warning disable 0219 +// Missing XML comment for publicly visible type or member '...' +#pragma warning disable 1591 +// Ambiguous reference in cref attribute +#pragma warning disable 419 + +namespace SysML2.NET.CodeGenerator.Grammar { +using Antlr4.Runtime.Misc; +using Antlr4.Runtime.Tree; +using IToken = Antlr4.Runtime.IToken; +using ParserRuleContext = Antlr4.Runtime.ParserRuleContext; + +/// +/// This class provides an empty implementation of , +/// which can be extended to create a visitor which only needs to handle a subset +/// of the available methods. +/// +/// The return type of the visit operation. +[System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.13.2")] +[System.Diagnostics.DebuggerNonUserCode] +[System.CLSCompliant(false)] +public partial class kgbnfBaseVisitor : AbstractParseTreeVisitor, IkgbnfVisitor { + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitSpecification([NotNull] kgbnfParser.SpecificationContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitRule_definition([NotNull] kgbnfParser.Rule_definitionContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitAlternatives([NotNull] kgbnfParser.AlternativesContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitAlternative([NotNull] kgbnfParser.AlternativeContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitElement([NotNull] kgbnfParser.ElementContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitGroup([NotNull] kgbnfParser.GroupContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitTerminal([NotNull] kgbnfParser.TerminalContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitImage([NotNull] kgbnfParser.ImageContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitAttribute([NotNull] kgbnfParser.AttributeContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitEdge_end([NotNull] kgbnfParser.Edge_endContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitNon_terminal([NotNull] kgbnfParser.Non_terminalContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitSuffix_op([NotNull] kgbnfParser.Suffix_opContext context) { return VisitChildren(context); } +} +} // namespace SysML2.NET.CodeGenerator.Grammar diff --git a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfLexer.cs b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfLexer.cs new file mode 100644 index 000000000..2661302bb --- /dev/null +++ b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfLexer.cs @@ -0,0 +1,160 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// ANTLR Version: 4.13.2 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +// Generated from Resources/kgbnf.g4 by ANTLR 4.13.2 + +// Unreachable code detected +#pragma warning disable 0162 +// The variable '...' is assigned but its value is never used +#pragma warning disable 0219 +// Missing XML comment for publicly visible type or member '...' +#pragma warning disable 1591 +// Ambiguous reference in cref attribute +#pragma warning disable 419 + +namespace SysML2.NET.CodeGenerator.Grammar { +using System; +using System.IO; +using System.Text; +using Antlr4.Runtime; +using Antlr4.Runtime.Atn; +using Antlr4.Runtime.Misc; +using DFA = Antlr4.Runtime.Dfa.DFA; + +[System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.13.2")] +[System.CLSCompliant(false)] +public partial class kgbnfLexer : Lexer { + protected static DFA[] decisionToDFA; + protected static PredictionContextCache sharedContextCache = new PredictionContextCache(); + public const int + T__0=1, T__1=2, T__2=3, PARTIAL_ASSIGN=4, ASSIGN=5, PIPE=6, LPAREN=7, + RPAREN=8, AMPERSAND=9, IMG_OPEN=10, TAG_CLOSE=11, GRAPHICAL_NAME=12, TEXTUAL_NAME=13, + SINGLE_QUOTED_STRING=14, DOUBLE_QUOTED_STRING=15, COMMENT=16, WS=17, CONTINUATION=18, + NL=19; + public static string[] channelNames = { + "DEFAULT_TOKEN_CHANNEL", "HIDDEN" + }; + + public static string[] modeNames = { + "DEFAULT_MODE" + }; + + public static readonly string[] ruleNames = { + "T__0", "T__1", "T__2", "PARTIAL_ASSIGN", "ASSIGN", "PIPE", "LPAREN", + "RPAREN", "AMPERSAND", "IMG_OPEN", "TAG_CLOSE", "GRAPHICAL_NAME", "TEXTUAL_NAME", + "SINGLE_QUOTED_STRING", "DOUBLE_QUOTED_STRING", "COMMENT", "WS", "CONTINUATION", + "NL" + }; + + + public kgbnfLexer(ICharStream input) + : this(input, Console.Out, Console.Error) { } + + public kgbnfLexer(ICharStream input, TextWriter output, TextWriter errorOutput) + : base(input, output, errorOutput) + { + Interpreter = new LexerATNSimulator(this, _ATN, decisionToDFA, sharedContextCache); + } + + private static readonly string[] _LiteralNames = { + null, "'*'", "'+'", "'?'", null, "'='", "'|'", "'('", "')'", "'&'", "''" + }; + private static readonly string[] _SymbolicNames = { + null, null, null, null, "PARTIAL_ASSIGN", "ASSIGN", "PIPE", "LPAREN", + "RPAREN", "AMPERSAND", "IMG_OPEN", "TAG_CLOSE", "GRAPHICAL_NAME", "TEXTUAL_NAME", + "SINGLE_QUOTED_STRING", "DOUBLE_QUOTED_STRING", "COMMENT", "WS", "CONTINUATION", + "NL" + }; + public static readonly IVocabulary DefaultVocabulary = new Vocabulary(_LiteralNames, _SymbolicNames); + + [NotNull] + public override IVocabulary Vocabulary + { + get + { + return DefaultVocabulary; + } + } + + public override string GrammarFileName { get { return "kgbnf.g4"; } } + + public override string[] RuleNames { get { return ruleNames; } } + + public override string[] ChannelNames { get { return channelNames; } } + + public override string[] ModeNames { get { return modeNames; } } + + public override int[] SerializedAtn { get { return _serializedATN; } } + + static kgbnfLexer() { + decisionToDFA = new DFA[_ATN.NumberOfDecisions]; + for (int i = 0; i < _ATN.NumberOfDecisions; i++) { + decisionToDFA[i] = new DFA(_ATN.GetDecisionState(i), i); + } + } + private static int[] _serializedATN = { + 4,0,19,145,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7, + 6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14, + 7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,1,0,1,0,1,1,1,1,1,2,1,2,1, + 3,1,3,1,3,1,3,3,3,50,8,3,1,4,1,4,1,5,1,5,1,6,1,6,1,7,1,7,1,8,1,8,1,9,1, + 9,1,9,1,9,1,9,1,10,1,10,1,11,4,11,70,8,11,11,11,12,11,71,1,11,1,11,4,11, + 76,8,11,11,11,12,11,77,5,11,80,8,11,10,11,12,11,83,9,11,1,12,1,12,5,12, + 87,8,12,10,12,12,12,90,9,12,1,13,1,13,1,13,1,13,5,13,96,8,13,10,13,12, + 13,99,9,13,1,13,1,13,1,14,1,14,5,14,105,8,14,10,14,12,14,108,9,14,1,14, + 1,14,1,15,1,15,1,15,1,15,5,15,116,8,15,10,15,12,15,119,9,15,1,15,1,15, + 1,16,4,16,124,8,16,11,16,12,16,125,1,16,1,16,1,17,3,17,131,8,17,1,17,1, + 17,4,17,135,8,17,11,17,12,17,136,1,17,1,17,1,18,3,18,142,8,18,1,18,1,18, + 0,0,19,1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17,9,19,10,21,11,23,12,25,13, + 27,14,29,15,31,16,33,17,35,18,37,19,1,0,7,1,0,97,122,3,0,65,90,95,95,97, + 122,4,0,48,57,65,90,95,95,97,122,2,0,39,39,92,92,3,0,10,10,13,13,34,34, + 2,0,10,10,13,13,2,0,9,9,32,32,157,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0, + 0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,15,1,0,0,0,0,17,1, + 0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,0,0,25,1,0,0,0,0,27,1,0,0,0, + 0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,0,35,1,0,0,0,0,37,1,0,0,0,1,39, + 1,0,0,0,3,41,1,0,0,0,5,43,1,0,0,0,7,49,1,0,0,0,9,51,1,0,0,0,11,53,1,0, + 0,0,13,55,1,0,0,0,15,57,1,0,0,0,17,59,1,0,0,0,19,61,1,0,0,0,21,66,1,0, + 0,0,23,69,1,0,0,0,25,84,1,0,0,0,27,91,1,0,0,0,29,102,1,0,0,0,31,111,1, + 0,0,0,33,123,1,0,0,0,35,130,1,0,0,0,37,141,1,0,0,0,39,40,5,42,0,0,40,2, + 1,0,0,0,41,42,5,43,0,0,42,4,1,0,0,0,43,44,5,63,0,0,44,6,1,0,0,0,45,46, + 5,61,0,0,46,50,5,124,0,0,47,48,5,124,0,0,48,50,5,61,0,0,49,45,1,0,0,0, + 49,47,1,0,0,0,50,8,1,0,0,0,51,52,5,61,0,0,52,10,1,0,0,0,53,54,5,124,0, + 0,54,12,1,0,0,0,55,56,5,40,0,0,56,14,1,0,0,0,57,58,5,41,0,0,58,16,1,0, + 0,0,59,60,5,38,0,0,60,18,1,0,0,0,61,62,5,60,0,0,62,63,5,105,0,0,63,64, + 5,109,0,0,64,65,5,103,0,0,65,20,1,0,0,0,66,67,5,62,0,0,67,22,1,0,0,0,68, + 70,7,0,0,0,69,68,1,0,0,0,70,71,1,0,0,0,71,69,1,0,0,0,71,72,1,0,0,0,72, + 81,1,0,0,0,73,75,5,45,0,0,74,76,7,0,0,0,75,74,1,0,0,0,76,77,1,0,0,0,77, + 75,1,0,0,0,77,78,1,0,0,0,78,80,1,0,0,0,79,73,1,0,0,0,80,83,1,0,0,0,81, + 79,1,0,0,0,81,82,1,0,0,0,82,24,1,0,0,0,83,81,1,0,0,0,84,88,7,1,0,0,85, + 87,7,2,0,0,86,85,1,0,0,0,87,90,1,0,0,0,88,86,1,0,0,0,88,89,1,0,0,0,89, + 26,1,0,0,0,90,88,1,0,0,0,91,97,5,39,0,0,92,96,8,3,0,0,93,94,5,92,0,0,94, + 96,9,0,0,0,95,92,1,0,0,0,95,93,1,0,0,0,96,99,1,0,0,0,97,95,1,0,0,0,97, + 98,1,0,0,0,98,100,1,0,0,0,99,97,1,0,0,0,100,101,5,39,0,0,101,28,1,0,0, + 0,102,106,5,34,0,0,103,105,8,4,0,0,104,103,1,0,0,0,105,108,1,0,0,0,106, + 104,1,0,0,0,106,107,1,0,0,0,107,109,1,0,0,0,108,106,1,0,0,0,109,110,5, + 34,0,0,110,30,1,0,0,0,111,112,5,47,0,0,112,113,5,47,0,0,113,117,1,0,0, + 0,114,116,8,5,0,0,115,114,1,0,0,0,116,119,1,0,0,0,117,115,1,0,0,0,117, + 118,1,0,0,0,118,120,1,0,0,0,119,117,1,0,0,0,120,121,6,15,0,0,121,32,1, + 0,0,0,122,124,7,6,0,0,123,122,1,0,0,0,124,125,1,0,0,0,125,123,1,0,0,0, + 125,126,1,0,0,0,126,127,1,0,0,0,127,128,6,16,0,0,128,34,1,0,0,0,129,131, + 5,13,0,0,130,129,1,0,0,0,130,131,1,0,0,0,131,132,1,0,0,0,132,134,5,10, + 0,0,133,135,7,6,0,0,134,133,1,0,0,0,135,136,1,0,0,0,136,134,1,0,0,0,136, + 137,1,0,0,0,137,138,1,0,0,0,138,139,6,17,0,0,139,36,1,0,0,0,140,142,5, + 13,0,0,141,140,1,0,0,0,141,142,1,0,0,0,142,143,1,0,0,0,143,144,5,10,0, + 0,144,38,1,0,0,0,14,0,49,71,77,81,88,95,97,106,117,125,130,136,141,1,6, + 0,0 + }; + + public static readonly ATN _ATN = + new ATNDeserializer().Deserialize(_serializedATN); + + +} +} // namespace SysML2.NET.CodeGenerator.Grammar diff --git a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfLexer.interp b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfLexer.interp new file mode 100644 index 000000000..2877de067 --- /dev/null +++ b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfLexer.interp @@ -0,0 +1,74 @@ +token literal names: +null +'*' +'+' +'?' +null +'=' +'|' +'(' +')' +'&' +'' +null +null +null +null +null +null +null +null + +token symbolic names: +null +null +null +null +PARTIAL_ASSIGN +ASSIGN +PIPE +LPAREN +RPAREN +AMPERSAND +IMG_OPEN +TAG_CLOSE +GRAPHICAL_NAME +TEXTUAL_NAME +SINGLE_QUOTED_STRING +DOUBLE_QUOTED_STRING +COMMENT +WS +CONTINUATION +NL + +rule names: +T__0 +T__1 +T__2 +PARTIAL_ASSIGN +ASSIGN +PIPE +LPAREN +RPAREN +AMPERSAND +IMG_OPEN +TAG_CLOSE +GRAPHICAL_NAME +TEXTUAL_NAME +SINGLE_QUOTED_STRING +DOUBLE_QUOTED_STRING +COMMENT +WS +CONTINUATION +NL + +channel names: +DEFAULT_TOKEN_CHANNEL +HIDDEN + +mode names: +DEFAULT_MODE + +atn: +[4, 0, 19, 145, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 50, 8, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 4, 11, 70, 8, 11, 11, 11, 12, 11, 71, 1, 11, 1, 11, 4, 11, 76, 8, 11, 11, 11, 12, 11, 77, 5, 11, 80, 8, 11, 10, 11, 12, 11, 83, 9, 11, 1, 12, 1, 12, 5, 12, 87, 8, 12, 10, 12, 12, 12, 90, 9, 12, 1, 13, 1, 13, 1, 13, 1, 13, 5, 13, 96, 8, 13, 10, 13, 12, 13, 99, 9, 13, 1, 13, 1, 13, 1, 14, 1, 14, 5, 14, 105, 8, 14, 10, 14, 12, 14, 108, 9, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 15, 5, 15, 116, 8, 15, 10, 15, 12, 15, 119, 9, 15, 1, 15, 1, 15, 1, 16, 4, 16, 124, 8, 16, 11, 16, 12, 16, 125, 1, 16, 1, 16, 1, 17, 3, 17, 131, 8, 17, 1, 17, 1, 17, 4, 17, 135, 8, 17, 11, 17, 12, 17, 136, 1, 17, 1, 17, 1, 18, 3, 18, 142, 8, 18, 1, 18, 1, 18, 0, 0, 19, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 1, 0, 7, 1, 0, 97, 122, 3, 0, 65, 90, 95, 95, 97, 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 2, 0, 39, 39, 92, 92, 3, 0, 10, 10, 13, 13, 34, 34, 2, 0, 10, 10, 13, 13, 2, 0, 9, 9, 32, 32, 157, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 1, 39, 1, 0, 0, 0, 3, 41, 1, 0, 0, 0, 5, 43, 1, 0, 0, 0, 7, 49, 1, 0, 0, 0, 9, 51, 1, 0, 0, 0, 11, 53, 1, 0, 0, 0, 13, 55, 1, 0, 0, 0, 15, 57, 1, 0, 0, 0, 17, 59, 1, 0, 0, 0, 19, 61, 1, 0, 0, 0, 21, 66, 1, 0, 0, 0, 23, 69, 1, 0, 0, 0, 25, 84, 1, 0, 0, 0, 27, 91, 1, 0, 0, 0, 29, 102, 1, 0, 0, 0, 31, 111, 1, 0, 0, 0, 33, 123, 1, 0, 0, 0, 35, 130, 1, 0, 0, 0, 37, 141, 1, 0, 0, 0, 39, 40, 5, 42, 0, 0, 40, 2, 1, 0, 0, 0, 41, 42, 5, 43, 0, 0, 42, 4, 1, 0, 0, 0, 43, 44, 5, 63, 0, 0, 44, 6, 1, 0, 0, 0, 45, 46, 5, 61, 0, 0, 46, 50, 5, 124, 0, 0, 47, 48, 5, 124, 0, 0, 48, 50, 5, 61, 0, 0, 49, 45, 1, 0, 0, 0, 49, 47, 1, 0, 0, 0, 50, 8, 1, 0, 0, 0, 51, 52, 5, 61, 0, 0, 52, 10, 1, 0, 0, 0, 53, 54, 5, 124, 0, 0, 54, 12, 1, 0, 0, 0, 55, 56, 5, 40, 0, 0, 56, 14, 1, 0, 0, 0, 57, 58, 5, 41, 0, 0, 58, 16, 1, 0, 0, 0, 59, 60, 5, 38, 0, 0, 60, 18, 1, 0, 0, 0, 61, 62, 5, 60, 0, 0, 62, 63, 5, 105, 0, 0, 63, 64, 5, 109, 0, 0, 64, 65, 5, 103, 0, 0, 65, 20, 1, 0, 0, 0, 66, 67, 5, 62, 0, 0, 67, 22, 1, 0, 0, 0, 68, 70, 7, 0, 0, 0, 69, 68, 1, 0, 0, 0, 70, 71, 1, 0, 0, 0, 71, 69, 1, 0, 0, 0, 71, 72, 1, 0, 0, 0, 72, 81, 1, 0, 0, 0, 73, 75, 5, 45, 0, 0, 74, 76, 7, 0, 0, 0, 75, 74, 1, 0, 0, 0, 76, 77, 1, 0, 0, 0, 77, 75, 1, 0, 0, 0, 77, 78, 1, 0, 0, 0, 78, 80, 1, 0, 0, 0, 79, 73, 1, 0, 0, 0, 80, 83, 1, 0, 0, 0, 81, 79, 1, 0, 0, 0, 81, 82, 1, 0, 0, 0, 82, 24, 1, 0, 0, 0, 83, 81, 1, 0, 0, 0, 84, 88, 7, 1, 0, 0, 85, 87, 7, 2, 0, 0, 86, 85, 1, 0, 0, 0, 87, 90, 1, 0, 0, 0, 88, 86, 1, 0, 0, 0, 88, 89, 1, 0, 0, 0, 89, 26, 1, 0, 0, 0, 90, 88, 1, 0, 0, 0, 91, 97, 5, 39, 0, 0, 92, 96, 8, 3, 0, 0, 93, 94, 5, 92, 0, 0, 94, 96, 9, 0, 0, 0, 95, 92, 1, 0, 0, 0, 95, 93, 1, 0, 0, 0, 96, 99, 1, 0, 0, 0, 97, 95, 1, 0, 0, 0, 97, 98, 1, 0, 0, 0, 98, 100, 1, 0, 0, 0, 99, 97, 1, 0, 0, 0, 100, 101, 5, 39, 0, 0, 101, 28, 1, 0, 0, 0, 102, 106, 5, 34, 0, 0, 103, 105, 8, 4, 0, 0, 104, 103, 1, 0, 0, 0, 105, 108, 1, 0, 0, 0, 106, 104, 1, 0, 0, 0, 106, 107, 1, 0, 0, 0, 107, 109, 1, 0, 0, 0, 108, 106, 1, 0, 0, 0, 109, 110, 5, 34, 0, 0, 110, 30, 1, 0, 0, 0, 111, 112, 5, 47, 0, 0, 112, 113, 5, 47, 0, 0, 113, 117, 1, 0, 0, 0, 114, 116, 8, 5, 0, 0, 115, 114, 1, 0, 0, 0, 116, 119, 1, 0, 0, 0, 117, 115, 1, 0, 0, 0, 117, 118, 1, 0, 0, 0, 118, 120, 1, 0, 0, 0, 119, 117, 1, 0, 0, 0, 120, 121, 6, 15, 0, 0, 121, 32, 1, 0, 0, 0, 122, 124, 7, 6, 0, 0, 123, 122, 1, 0, 0, 0, 124, 125, 1, 0, 0, 0, 125, 123, 1, 0, 0, 0, 125, 126, 1, 0, 0, 0, 126, 127, 1, 0, 0, 0, 127, 128, 6, 16, 0, 0, 128, 34, 1, 0, 0, 0, 129, 131, 5, 13, 0, 0, 130, 129, 1, 0, 0, 0, 130, 131, 1, 0, 0, 0, 131, 132, 1, 0, 0, 0, 132, 134, 5, 10, 0, 0, 133, 135, 7, 6, 0, 0, 134, 133, 1, 0, 0, 0, 135, 136, 1, 0, 0, 0, 136, 134, 1, 0, 0, 0, 136, 137, 1, 0, 0, 0, 137, 138, 1, 0, 0, 0, 138, 139, 6, 17, 0, 0, 139, 36, 1, 0, 0, 0, 140, 142, 5, 13, 0, 0, 141, 140, 1, 0, 0, 0, 141, 142, 1, 0, 0, 0, 142, 143, 1, 0, 0, 0, 143, 144, 5, 10, 0, 0, 144, 38, 1, 0, 0, 0, 14, 0, 49, 71, 77, 81, 88, 95, 97, 106, 117, 125, 130, 136, 141, 1, 6, 0, 0] \ No newline at end of file diff --git a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfLexer.tokens b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfLexer.tokens new file mode 100644 index 000000000..96daeed64 --- /dev/null +++ b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfLexer.tokens @@ -0,0 +1,29 @@ +T__0=1 +T__1=2 +T__2=3 +PARTIAL_ASSIGN=4 +ASSIGN=5 +PIPE=6 +LPAREN=7 +RPAREN=8 +AMPERSAND=9 +IMG_OPEN=10 +TAG_CLOSE=11 +GRAPHICAL_NAME=12 +TEXTUAL_NAME=13 +SINGLE_QUOTED_STRING=14 +DOUBLE_QUOTED_STRING=15 +COMMENT=16 +WS=17 +CONTINUATION=18 +NL=19 +'*'=1 +'+'=2 +'?'=3 +'='=5 +'|'=6 +'('=7 +')'=8 +'&'=9 +''=11 diff --git a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfListener.cs b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfListener.cs new file mode 100644 index 000000000..caf3e00d1 --- /dev/null +++ b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfListener.cs @@ -0,0 +1,155 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// ANTLR Version: 4.13.2 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +// Generated from Resources/kgbnf.g4 by ANTLR 4.13.2 + +// Unreachable code detected +#pragma warning disable 0162 +// The variable '...' is assigned but its value is never used +#pragma warning disable 0219 +// Missing XML comment for publicly visible type or member '...' +#pragma warning disable 1591 +// Ambiguous reference in cref attribute +#pragma warning disable 419 + +namespace SysML2.NET.CodeGenerator.Grammar { +using Antlr4.Runtime.Misc; +using IParseTreeListener = Antlr4.Runtime.Tree.IParseTreeListener; +using IToken = Antlr4.Runtime.IToken; + +/// +/// This interface defines a complete listener for a parse tree produced by +/// . +/// +[System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.13.2")] +[System.CLSCompliant(false)] +public interface IkgbnfListener : IParseTreeListener { + /// + /// Enter a parse tree produced by . + /// + /// The parse tree. + void EnterSpecification([NotNull] kgbnfParser.SpecificationContext context); + /// + /// Exit a parse tree produced by . + /// + /// The parse tree. + void ExitSpecification([NotNull] kgbnfParser.SpecificationContext context); + /// + /// Enter a parse tree produced by . + /// + /// The parse tree. + void EnterRule_definition([NotNull] kgbnfParser.Rule_definitionContext context); + /// + /// Exit a parse tree produced by . + /// + /// The parse tree. + void ExitRule_definition([NotNull] kgbnfParser.Rule_definitionContext context); + /// + /// Enter a parse tree produced by . + /// + /// The parse tree. + void EnterAlternatives([NotNull] kgbnfParser.AlternativesContext context); + /// + /// Exit a parse tree produced by . + /// + /// The parse tree. + void ExitAlternatives([NotNull] kgbnfParser.AlternativesContext context); + /// + /// Enter a parse tree produced by . + /// + /// The parse tree. + void EnterAlternative([NotNull] kgbnfParser.AlternativeContext context); + /// + /// Exit a parse tree produced by . + /// + /// The parse tree. + void ExitAlternative([NotNull] kgbnfParser.AlternativeContext context); + /// + /// Enter a parse tree produced by . + /// + /// The parse tree. + void EnterElement([NotNull] kgbnfParser.ElementContext context); + /// + /// Exit a parse tree produced by . + /// + /// The parse tree. + void ExitElement([NotNull] kgbnfParser.ElementContext context); + /// + /// Enter a parse tree produced by . + /// + /// The parse tree. + void EnterGroup([NotNull] kgbnfParser.GroupContext context); + /// + /// Exit a parse tree produced by . + /// + /// The parse tree. + void ExitGroup([NotNull] kgbnfParser.GroupContext context); + /// + /// Enter a parse tree produced by . + /// + /// The parse tree. + void EnterTerminal([NotNull] kgbnfParser.TerminalContext context); + /// + /// Exit a parse tree produced by . + /// + /// The parse tree. + void ExitTerminal([NotNull] kgbnfParser.TerminalContext context); + /// + /// Enter a parse tree produced by . + /// + /// The parse tree. + void EnterImage([NotNull] kgbnfParser.ImageContext context); + /// + /// Exit a parse tree produced by . + /// + /// The parse tree. + void ExitImage([NotNull] kgbnfParser.ImageContext context); + /// + /// Enter a parse tree produced by . + /// + /// The parse tree. + void EnterAttribute([NotNull] kgbnfParser.AttributeContext context); + /// + /// Exit a parse tree produced by . + /// + /// The parse tree. + void ExitAttribute([NotNull] kgbnfParser.AttributeContext context); + /// + /// Enter a parse tree produced by . + /// + /// The parse tree. + void EnterEdge_end([NotNull] kgbnfParser.Edge_endContext context); + /// + /// Exit a parse tree produced by . + /// + /// The parse tree. + void ExitEdge_end([NotNull] kgbnfParser.Edge_endContext context); + /// + /// Enter a parse tree produced by . + /// + /// The parse tree. + void EnterNon_terminal([NotNull] kgbnfParser.Non_terminalContext context); + /// + /// Exit a parse tree produced by . + /// + /// The parse tree. + void ExitNon_terminal([NotNull] kgbnfParser.Non_terminalContext context); + /// + /// Enter a parse tree produced by . + /// + /// The parse tree. + void EnterSuffix_op([NotNull] kgbnfParser.Suffix_opContext context); + /// + /// Exit a parse tree produced by . + /// + /// The parse tree. + void ExitSuffix_op([NotNull] kgbnfParser.Suffix_opContext context); +} +} // namespace SysML2.NET.CodeGenerator.Grammar diff --git a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfParser.cs b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfParser.cs new file mode 100644 index 000000000..9f281d35a --- /dev/null +++ b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfParser.cs @@ -0,0 +1,993 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// ANTLR Version: 4.13.2 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +// Generated from Resources/kgbnf.g4 by ANTLR 4.13.2 + +// Unreachable code detected +#pragma warning disable 0162 +// The variable '...' is assigned but its value is never used +#pragma warning disable 0219 +// Missing XML comment for publicly visible type or member '...' +#pragma warning disable 1591 +// Ambiguous reference in cref attribute +#pragma warning disable 419 + +namespace SysML2.NET.CodeGenerator.Grammar { +using System; +using System.IO; +using System.Text; +using System.Diagnostics; +using System.Collections.Generic; +using Antlr4.Runtime; +using Antlr4.Runtime.Atn; +using Antlr4.Runtime.Misc; +using Antlr4.Runtime.Tree; +using DFA = Antlr4.Runtime.Dfa.DFA; + +[System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.13.2")] +[System.CLSCompliant(false)] +public partial class kgbnfParser : Parser { + protected static DFA[] decisionToDFA; + protected static PredictionContextCache sharedContextCache = new PredictionContextCache(); + public const int + T__0=1, T__1=2, T__2=3, PARTIAL_ASSIGN=4, ASSIGN=5, PIPE=6, LPAREN=7, + RPAREN=8, AMPERSAND=9, IMG_OPEN=10, TAG_CLOSE=11, GRAPHICAL_NAME=12, TEXTUAL_NAME=13, + SINGLE_QUOTED_STRING=14, DOUBLE_QUOTED_STRING=15, COMMENT=16, WS=17, CONTINUATION=18, + NL=19; + public const int + RULE_specification = 0, RULE_rule_definition = 1, RULE_alternatives = 2, + RULE_alternative = 3, RULE_element = 4, RULE_group = 5, RULE_terminal = 6, + RULE_image = 7, RULE_attribute = 8, RULE_edge_end = 9, RULE_non_terminal = 10, + RULE_suffix_op = 11; + public static readonly string[] ruleNames = { + "specification", "rule_definition", "alternatives", "alternative", "element", + "group", "terminal", "image", "attribute", "edge_end", "non_terminal", + "suffix_op" + }; + + private static readonly string[] _LiteralNames = { + null, "'*'", "'+'", "'?'", null, "'='", "'|'", "'('", "')'", "'&'", "''" + }; + private static readonly string[] _SymbolicNames = { + null, null, null, null, "PARTIAL_ASSIGN", "ASSIGN", "PIPE", "LPAREN", + "RPAREN", "AMPERSAND", "IMG_OPEN", "TAG_CLOSE", "GRAPHICAL_NAME", "TEXTUAL_NAME", + "SINGLE_QUOTED_STRING", "DOUBLE_QUOTED_STRING", "COMMENT", "WS", "CONTINUATION", + "NL" + }; + public static readonly IVocabulary DefaultVocabulary = new Vocabulary(_LiteralNames, _SymbolicNames); + + [NotNull] + public override IVocabulary Vocabulary + { + get + { + return DefaultVocabulary; + } + } + + public override string GrammarFileName { get { return "kgbnf.g4"; } } + + public override string[] RuleNames { get { return ruleNames; } } + + public override int[] SerializedAtn { get { return _serializedATN; } } + + static kgbnfParser() { + decisionToDFA = new DFA[_ATN.NumberOfDecisions]; + for (int i = 0; i < _ATN.NumberOfDecisions; i++) { + decisionToDFA[i] = new DFA(_ATN.GetDecisionState(i), i); + } + } + + public kgbnfParser(ITokenStream input) : this(input, Console.Out, Console.Error) { } + + public kgbnfParser(ITokenStream input, TextWriter output, TextWriter errorOutput) + : base(input, output, errorOutput) + { + Interpreter = new ParserATNSimulator(this, _ATN, decisionToDFA, sharedContextCache); + } + + public partial class SpecificationContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode Eof() { return GetToken(kgbnfParser.Eof, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] NL() { return GetTokens(kgbnfParser.NL); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode NL(int i) { + return GetToken(kgbnfParser.NL, i); + } + [System.Diagnostics.DebuggerNonUserCode] public Rule_definitionContext[] rule_definition() { + return GetRuleContexts(); + } + [System.Diagnostics.DebuggerNonUserCode] public Rule_definitionContext rule_definition(int i) { + return GetRuleContext(i); + } + public SpecificationContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_specification; } } + [System.Diagnostics.DebuggerNonUserCode] + public override void EnterRule(IParseTreeListener listener) { + IkgbnfListener typedListener = listener as IkgbnfListener; + if (typedListener != null) typedListener.EnterSpecification(this); + } + [System.Diagnostics.DebuggerNonUserCode] + public override void ExitRule(IParseTreeListener listener) { + IkgbnfListener typedListener = listener as IkgbnfListener; + if (typedListener != null) typedListener.ExitSpecification(this); + } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IkgbnfVisitor typedVisitor = visitor as IkgbnfVisitor; + if (typedVisitor != null) return typedVisitor.VisitSpecification(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public SpecificationContext specification() { + SpecificationContext _localctx = new SpecificationContext(Context, State); + EnterRule(_localctx, 0, RULE_specification); + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 27; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + while (_la==NL) { + { + { + State = 24; + Match(NL); + } + } + State = 29; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + } + State = 31; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + do { + { + { + State = 30; + rule_definition(); + } + } + State = 33; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + } while ( _la==GRAPHICAL_NAME ); + State = 35; + Match(Eof); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Rule_definitionContext : ParserRuleContext { + public IToken name; + public IToken op; + public AlternativesContext rule_body; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode GRAPHICAL_NAME() { return GetToken(kgbnfParser.GRAPHICAL_NAME, 0); } + [System.Diagnostics.DebuggerNonUserCode] public AlternativesContext alternatives() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ASSIGN() { return GetToken(kgbnfParser.ASSIGN, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PARTIAL_ASSIGN() { return GetToken(kgbnfParser.PARTIAL_ASSIGN, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] NL() { return GetTokens(kgbnfParser.NL); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode NL(int i) { + return GetToken(kgbnfParser.NL, i); + } + public Rule_definitionContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_rule_definition; } } + [System.Diagnostics.DebuggerNonUserCode] + public override void EnterRule(IParseTreeListener listener) { + IkgbnfListener typedListener = listener as IkgbnfListener; + if (typedListener != null) typedListener.EnterRule_definition(this); + } + [System.Diagnostics.DebuggerNonUserCode] + public override void ExitRule(IParseTreeListener listener) { + IkgbnfListener typedListener = listener as IkgbnfListener; + if (typedListener != null) typedListener.ExitRule_definition(this); + } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IkgbnfVisitor typedVisitor = visitor as IkgbnfVisitor; + if (typedVisitor != null) return typedVisitor.VisitRule_definition(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Rule_definitionContext rule_definition() { + Rule_definitionContext _localctx = new Rule_definitionContext(Context, State); + EnterRule(_localctx, 2, RULE_rule_definition); + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 37; + _localctx.name = Match(GRAPHICAL_NAME); + State = 38; + _localctx.op = TokenStream.LT(1); + _la = TokenStream.LA(1); + if ( !(_la==PARTIAL_ASSIGN || _la==ASSIGN) ) { + _localctx.op = ErrorHandler.RecoverInline(this); + } + else { + ErrorHandler.ReportMatch(this); + Consume(); + } + State = 39; + _localctx.rule_body = alternatives(); + State = 41; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + do { + { + { + State = 40; + Match(NL); + } + } + State = 43; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + } while ( _la==NL ); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class AlternativesContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public AlternativeContext[] alternative() { + return GetRuleContexts(); + } + [System.Diagnostics.DebuggerNonUserCode] public AlternativeContext alternative(int i) { + return GetRuleContext(i); + } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] PIPE() { return GetTokens(kgbnfParser.PIPE); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PIPE(int i) { + return GetToken(kgbnfParser.PIPE, i); + } + public AlternativesContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_alternatives; } } + [System.Diagnostics.DebuggerNonUserCode] + public override void EnterRule(IParseTreeListener listener) { + IkgbnfListener typedListener = listener as IkgbnfListener; + if (typedListener != null) typedListener.EnterAlternatives(this); + } + [System.Diagnostics.DebuggerNonUserCode] + public override void ExitRule(IParseTreeListener listener) { + IkgbnfListener typedListener = listener as IkgbnfListener; + if (typedListener != null) typedListener.ExitAlternatives(this); + } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IkgbnfVisitor typedVisitor = visitor as IkgbnfVisitor; + if (typedVisitor != null) return typedVisitor.VisitAlternatives(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public AlternativesContext alternatives() { + AlternativesContext _localctx = new AlternativesContext(Context, State); + EnterRule(_localctx, 4, RULE_alternatives); + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 45; + alternative(); + State = 50; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + while (_la==PIPE) { + { + { + State = 46; + Match(PIPE); + State = 47; + alternative(); + } + } + State = 52; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class AlternativeContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public ElementContext[] element() { + return GetRuleContexts(); + } + [System.Diagnostics.DebuggerNonUserCode] public ElementContext element(int i) { + return GetRuleContext(i); + } + public AlternativeContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_alternative; } } + [System.Diagnostics.DebuggerNonUserCode] + public override void EnterRule(IParseTreeListener listener) { + IkgbnfListener typedListener = listener as IkgbnfListener; + if (typedListener != null) typedListener.EnterAlternative(this); + } + [System.Diagnostics.DebuggerNonUserCode] + public override void ExitRule(IParseTreeListener listener) { + IkgbnfListener typedListener = listener as IkgbnfListener; + if (typedListener != null) typedListener.ExitAlternative(this); + } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IkgbnfVisitor typedVisitor = visitor as IkgbnfVisitor; + if (typedVisitor != null) return typedVisitor.VisitAlternative(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public AlternativeContext alternative() { + AlternativeContext _localctx = new AlternativeContext(Context, State); + EnterRule(_localctx, 6, RULE_alternative); + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 56; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 30336L) != 0)) { + { + { + State = 53; + element(); + } + } + State = 58; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class ElementContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public GroupContext group() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public TerminalContext terminal() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public ImageContext image() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public Edge_endContext edge_end() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public Non_terminalContext non_terminal() { + return GetRuleContext(0); + } + public ElementContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_element; } } + [System.Diagnostics.DebuggerNonUserCode] + public override void EnterRule(IParseTreeListener listener) { + IkgbnfListener typedListener = listener as IkgbnfListener; + if (typedListener != null) typedListener.EnterElement(this); + } + [System.Diagnostics.DebuggerNonUserCode] + public override void ExitRule(IParseTreeListener listener) { + IkgbnfListener typedListener = listener as IkgbnfListener; + if (typedListener != null) typedListener.ExitElement(this); + } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IkgbnfVisitor typedVisitor = visitor as IkgbnfVisitor; + if (typedVisitor != null) return typedVisitor.VisitElement(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public ElementContext element() { + ElementContext _localctx = new ElementContext(Context, State); + EnterRule(_localctx, 8, RULE_element); + try { + State = 64; + ErrorHandler.Sync(this); + switch (TokenStream.LA(1)) { + case LPAREN: + EnterOuterAlt(_localctx, 1); + { + State = 59; + group(); + } + break; + case SINGLE_QUOTED_STRING: + EnterOuterAlt(_localctx, 2); + { + State = 60; + terminal(); + } + break; + case IMG_OPEN: + EnterOuterAlt(_localctx, 3); + { + State = 61; + image(); + } + break; + case AMPERSAND: + EnterOuterAlt(_localctx, 4); + { + State = 62; + edge_end(); + } + break; + case GRAPHICAL_NAME: + case TEXTUAL_NAME: + EnterOuterAlt(_localctx, 5); + { + State = 63; + non_terminal(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class GroupContext : ParserRuleContext { + public Suffix_opContext suffix; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LPAREN() { return GetToken(kgbnfParser.LPAREN, 0); } + [System.Diagnostics.DebuggerNonUserCode] public AlternativesContext alternatives() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode RPAREN() { return GetToken(kgbnfParser.RPAREN, 0); } + [System.Diagnostics.DebuggerNonUserCode] public Suffix_opContext suffix_op() { + return GetRuleContext(0); + } + public GroupContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_group; } } + [System.Diagnostics.DebuggerNonUserCode] + public override void EnterRule(IParseTreeListener listener) { + IkgbnfListener typedListener = listener as IkgbnfListener; + if (typedListener != null) typedListener.EnterGroup(this); + } + [System.Diagnostics.DebuggerNonUserCode] + public override void ExitRule(IParseTreeListener listener) { + IkgbnfListener typedListener = listener as IkgbnfListener; + if (typedListener != null) typedListener.ExitGroup(this); + } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IkgbnfVisitor typedVisitor = visitor as IkgbnfVisitor; + if (typedVisitor != null) return typedVisitor.VisitGroup(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public GroupContext group() { + GroupContext _localctx = new GroupContext(Context, State); + EnterRule(_localctx, 10, RULE_group); + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 66; + Match(LPAREN); + State = 67; + alternatives(); + State = 68; + Match(RPAREN); + State = 70; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 14L) != 0)) { + { + State = 69; + _localctx.suffix = suffix_op(); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class TerminalContext : ParserRuleContext { + public IToken val; + public Suffix_opContext suffix; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SINGLE_QUOTED_STRING() { return GetToken(kgbnfParser.SINGLE_QUOTED_STRING, 0); } + [System.Diagnostics.DebuggerNonUserCode] public Suffix_opContext suffix_op() { + return GetRuleContext(0); + } + public TerminalContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_terminal; } } + [System.Diagnostics.DebuggerNonUserCode] + public override void EnterRule(IParseTreeListener listener) { + IkgbnfListener typedListener = listener as IkgbnfListener; + if (typedListener != null) typedListener.EnterTerminal(this); + } + [System.Diagnostics.DebuggerNonUserCode] + public override void ExitRule(IParseTreeListener listener) { + IkgbnfListener typedListener = listener as IkgbnfListener; + if (typedListener != null) typedListener.ExitTerminal(this); + } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IkgbnfVisitor typedVisitor = visitor as IkgbnfVisitor; + if (typedVisitor != null) return typedVisitor.VisitTerminal(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public TerminalContext terminal() { + TerminalContext _localctx = new TerminalContext(Context, State); + EnterRule(_localctx, 12, RULE_terminal); + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 72; + _localctx.val = Match(SINGLE_QUOTED_STRING); + State = 74; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 14L) != 0)) { + { + State = 73; + _localctx.suffix = suffix_op(); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class ImageContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode IMG_OPEN() { return GetToken(kgbnfParser.IMG_OPEN, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode TAG_CLOSE() { return GetToken(kgbnfParser.TAG_CLOSE, 0); } + [System.Diagnostics.DebuggerNonUserCode] public AttributeContext[] attribute() { + return GetRuleContexts(); + } + [System.Diagnostics.DebuggerNonUserCode] public AttributeContext attribute(int i) { + return GetRuleContext(i); + } + public ImageContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_image; } } + [System.Diagnostics.DebuggerNonUserCode] + public override void EnterRule(IParseTreeListener listener) { + IkgbnfListener typedListener = listener as IkgbnfListener; + if (typedListener != null) typedListener.EnterImage(this); + } + [System.Diagnostics.DebuggerNonUserCode] + public override void ExitRule(IParseTreeListener listener) { + IkgbnfListener typedListener = listener as IkgbnfListener; + if (typedListener != null) typedListener.ExitImage(this); + } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IkgbnfVisitor typedVisitor = visitor as IkgbnfVisitor; + if (typedVisitor != null) return typedVisitor.VisitImage(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public ImageContext image() { + ImageContext _localctx = new ImageContext(Context, State); + EnterRule(_localctx, 14, RULE_image); + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 76; + Match(IMG_OPEN); + State = 80; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + while (_la==GRAPHICAL_NAME) { + { + { + State = 77; + attribute(); + } + } + State = 82; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + } + State = 83; + Match(TAG_CLOSE); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class AttributeContext : ParserRuleContext { + public IToken attribute_name; + public IToken attribute_value; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ASSIGN() { return GetToken(kgbnfParser.ASSIGN, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode GRAPHICAL_NAME() { return GetToken(kgbnfParser.GRAPHICAL_NAME, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode DOUBLE_QUOTED_STRING() { return GetToken(kgbnfParser.DOUBLE_QUOTED_STRING, 0); } + public AttributeContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_attribute; } } + [System.Diagnostics.DebuggerNonUserCode] + public override void EnterRule(IParseTreeListener listener) { + IkgbnfListener typedListener = listener as IkgbnfListener; + if (typedListener != null) typedListener.EnterAttribute(this); + } + [System.Diagnostics.DebuggerNonUserCode] + public override void ExitRule(IParseTreeListener listener) { + IkgbnfListener typedListener = listener as IkgbnfListener; + if (typedListener != null) typedListener.ExitAttribute(this); + } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IkgbnfVisitor typedVisitor = visitor as IkgbnfVisitor; + if (typedVisitor != null) return typedVisitor.VisitAttribute(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public AttributeContext attribute() { + AttributeContext _localctx = new AttributeContext(Context, State); + EnterRule(_localctx, 16, RULE_attribute); + try { + EnterOuterAlt(_localctx, 1); + { + State = 85; + _localctx.attribute_name = Match(GRAPHICAL_NAME); + State = 86; + Match(ASSIGN); + State = 87; + _localctx.attribute_value = Match(DOUBLE_QUOTED_STRING); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Edge_endContext : ParserRuleContext { + public IToken name; + public Suffix_opContext suffix; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode AMPERSAND() { return GetToken(kgbnfParser.AMPERSAND, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode GRAPHICAL_NAME() { return GetToken(kgbnfParser.GRAPHICAL_NAME, 0); } + [System.Diagnostics.DebuggerNonUserCode] public Suffix_opContext suffix_op() { + return GetRuleContext(0); + } + public Edge_endContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_edge_end; } } + [System.Diagnostics.DebuggerNonUserCode] + public override void EnterRule(IParseTreeListener listener) { + IkgbnfListener typedListener = listener as IkgbnfListener; + if (typedListener != null) typedListener.EnterEdge_end(this); + } + [System.Diagnostics.DebuggerNonUserCode] + public override void ExitRule(IParseTreeListener listener) { + IkgbnfListener typedListener = listener as IkgbnfListener; + if (typedListener != null) typedListener.ExitEdge_end(this); + } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IkgbnfVisitor typedVisitor = visitor as IkgbnfVisitor; + if (typedVisitor != null) return typedVisitor.VisitEdge_end(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Edge_endContext edge_end() { + Edge_endContext _localctx = new Edge_endContext(Context, State); + EnterRule(_localctx, 18, RULE_edge_end); + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 89; + Match(AMPERSAND); + State = 90; + _localctx.name = Match(GRAPHICAL_NAME); + State = 92; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 14L) != 0)) { + { + State = 91; + _localctx.suffix = suffix_op(); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Non_terminalContext : ParserRuleContext { + public IToken name; + public Suffix_opContext suffix; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode GRAPHICAL_NAME() { return GetToken(kgbnfParser.GRAPHICAL_NAME, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode TEXTUAL_NAME() { return GetToken(kgbnfParser.TEXTUAL_NAME, 0); } + [System.Diagnostics.DebuggerNonUserCode] public Suffix_opContext suffix_op() { + return GetRuleContext(0); + } + public Non_terminalContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_non_terminal; } } + [System.Diagnostics.DebuggerNonUserCode] + public override void EnterRule(IParseTreeListener listener) { + IkgbnfListener typedListener = listener as IkgbnfListener; + if (typedListener != null) typedListener.EnterNon_terminal(this); + } + [System.Diagnostics.DebuggerNonUserCode] + public override void ExitRule(IParseTreeListener listener) { + IkgbnfListener typedListener = listener as IkgbnfListener; + if (typedListener != null) typedListener.ExitNon_terminal(this); + } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IkgbnfVisitor typedVisitor = visitor as IkgbnfVisitor; + if (typedVisitor != null) return typedVisitor.VisitNon_terminal(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Non_terminalContext non_terminal() { + Non_terminalContext _localctx = new Non_terminalContext(Context, State); + EnterRule(_localctx, 20, RULE_non_terminal); + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 94; + _localctx.name = TokenStream.LT(1); + _la = TokenStream.LA(1); + if ( !(_la==GRAPHICAL_NAME || _la==TEXTUAL_NAME) ) { + _localctx.name = ErrorHandler.RecoverInline(this); + } + else { + ErrorHandler.ReportMatch(this); + Consume(); + } + State = 96; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 14L) != 0)) { + { + State = 95; + _localctx.suffix = suffix_op(); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Suffix_opContext : ParserRuleContext { + public Suffix_opContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_suffix_op; } } + [System.Diagnostics.DebuggerNonUserCode] + public override void EnterRule(IParseTreeListener listener) { + IkgbnfListener typedListener = listener as IkgbnfListener; + if (typedListener != null) typedListener.EnterSuffix_op(this); + } + [System.Diagnostics.DebuggerNonUserCode] + public override void ExitRule(IParseTreeListener listener) { + IkgbnfListener typedListener = listener as IkgbnfListener; + if (typedListener != null) typedListener.ExitSuffix_op(this); + } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IkgbnfVisitor typedVisitor = visitor as IkgbnfVisitor; + if (typedVisitor != null) return typedVisitor.VisitSuffix_op(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Suffix_opContext suffix_op() { + Suffix_opContext _localctx = new Suffix_opContext(Context, State); + EnterRule(_localctx, 22, RULE_suffix_op); + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 98; + _la = TokenStream.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 14L) != 0)) ) { + ErrorHandler.RecoverInline(this); + } + else { + ErrorHandler.ReportMatch(this); + Consume(); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + private static int[] _serializedATN = { + 4,1,19,101,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7, + 7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,1,0,5,0,26,8,0,10,0,12,0,29,9, + 0,1,0,4,0,32,8,0,11,0,12,0,33,1,0,1,0,1,1,1,1,1,1,1,1,4,1,42,8,1,11,1, + 12,1,43,1,2,1,2,1,2,5,2,49,8,2,10,2,12,2,52,9,2,1,3,5,3,55,8,3,10,3,12, + 3,58,9,3,1,4,1,4,1,4,1,4,1,4,3,4,65,8,4,1,5,1,5,1,5,1,5,3,5,71,8,5,1,6, + 1,6,3,6,75,8,6,1,7,1,7,5,7,79,8,7,10,7,12,7,82,9,7,1,7,1,7,1,8,1,8,1,8, + 1,8,1,9,1,9,1,9,3,9,93,8,9,1,10,1,10,3,10,97,8,10,1,11,1,11,1,11,0,0,12, + 0,2,4,6,8,10,12,14,16,18,20,22,0,3,1,0,4,5,1,0,12,13,1,0,1,3,102,0,27, + 1,0,0,0,2,37,1,0,0,0,4,45,1,0,0,0,6,56,1,0,0,0,8,64,1,0,0,0,10,66,1,0, + 0,0,12,72,1,0,0,0,14,76,1,0,0,0,16,85,1,0,0,0,18,89,1,0,0,0,20,94,1,0, + 0,0,22,98,1,0,0,0,24,26,5,19,0,0,25,24,1,0,0,0,26,29,1,0,0,0,27,25,1,0, + 0,0,27,28,1,0,0,0,28,31,1,0,0,0,29,27,1,0,0,0,30,32,3,2,1,0,31,30,1,0, + 0,0,32,33,1,0,0,0,33,31,1,0,0,0,33,34,1,0,0,0,34,35,1,0,0,0,35,36,5,0, + 0,1,36,1,1,0,0,0,37,38,5,12,0,0,38,39,7,0,0,0,39,41,3,4,2,0,40,42,5,19, + 0,0,41,40,1,0,0,0,42,43,1,0,0,0,43,41,1,0,0,0,43,44,1,0,0,0,44,3,1,0,0, + 0,45,50,3,6,3,0,46,47,5,6,0,0,47,49,3,6,3,0,48,46,1,0,0,0,49,52,1,0,0, + 0,50,48,1,0,0,0,50,51,1,0,0,0,51,5,1,0,0,0,52,50,1,0,0,0,53,55,3,8,4,0, + 54,53,1,0,0,0,55,58,1,0,0,0,56,54,1,0,0,0,56,57,1,0,0,0,57,7,1,0,0,0,58, + 56,1,0,0,0,59,65,3,10,5,0,60,65,3,12,6,0,61,65,3,14,7,0,62,65,3,18,9,0, + 63,65,3,20,10,0,64,59,1,0,0,0,64,60,1,0,0,0,64,61,1,0,0,0,64,62,1,0,0, + 0,64,63,1,0,0,0,65,9,1,0,0,0,66,67,5,7,0,0,67,68,3,4,2,0,68,70,5,8,0,0, + 69,71,3,22,11,0,70,69,1,0,0,0,70,71,1,0,0,0,71,11,1,0,0,0,72,74,5,14,0, + 0,73,75,3,22,11,0,74,73,1,0,0,0,74,75,1,0,0,0,75,13,1,0,0,0,76,80,5,10, + 0,0,77,79,3,16,8,0,78,77,1,0,0,0,79,82,1,0,0,0,80,78,1,0,0,0,80,81,1,0, + 0,0,81,83,1,0,0,0,82,80,1,0,0,0,83,84,5,11,0,0,84,15,1,0,0,0,85,86,5,12, + 0,0,86,87,5,5,0,0,87,88,5,15,0,0,88,17,1,0,0,0,89,90,5,9,0,0,90,92,5,12, + 0,0,91,93,3,22,11,0,92,91,1,0,0,0,92,93,1,0,0,0,93,19,1,0,0,0,94,96,7, + 1,0,0,95,97,3,22,11,0,96,95,1,0,0,0,96,97,1,0,0,0,97,21,1,0,0,0,98,99, + 7,2,0,0,99,23,1,0,0,0,11,27,33,43,50,56,64,70,74,80,92,96 + }; + + public static readonly ATN _ATN = + new ATNDeserializer().Deserialize(_serializedATN); + + +} +} // namespace SysML2.NET.CodeGenerator.Grammar diff --git a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfVisitor.cs b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfVisitor.cs new file mode 100644 index 000000000..3c3f9c84c --- /dev/null +++ b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfVisitor.cs @@ -0,0 +1,108 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// ANTLR Version: 4.13.2 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +// Generated from Resources/kgbnf.g4 by ANTLR 4.13.2 + +// Unreachable code detected +#pragma warning disable 0162 +// The variable '...' is assigned but its value is never used +#pragma warning disable 0219 +// Missing XML comment for publicly visible type or member '...' +#pragma warning disable 1591 +// Ambiguous reference in cref attribute +#pragma warning disable 419 + +namespace SysML2.NET.CodeGenerator.Grammar { +using Antlr4.Runtime.Misc; +using Antlr4.Runtime.Tree; +using IToken = Antlr4.Runtime.IToken; + +/// +/// This interface defines a complete generic visitor for a parse tree produced +/// by . +/// +/// The return type of the visit operation. +[System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.13.2")] +[System.CLSCompliant(false)] +public interface IkgbnfVisitor : IParseTreeVisitor { + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitSpecification([NotNull] kgbnfParser.SpecificationContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitRule_definition([NotNull] kgbnfParser.Rule_definitionContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitAlternatives([NotNull] kgbnfParser.AlternativesContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitAlternative([NotNull] kgbnfParser.AlternativeContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitElement([NotNull] kgbnfParser.ElementContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitGroup([NotNull] kgbnfParser.GroupContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitTerminal([NotNull] kgbnfParser.TerminalContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitImage([NotNull] kgbnfParser.ImageContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitAttribute([NotNull] kgbnfParser.AttributeContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitEdge_end([NotNull] kgbnfParser.Edge_endContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitNon_terminal([NotNull] kgbnfParser.Non_terminalContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitSuffix_op([NotNull] kgbnfParser.Suffix_opContext context); +} +} // namespace SysML2.NET.CodeGenerator.Grammar diff --git a/SysML2.NET.CodeGenerator/Grammar/GraphicalNotationSpecificationVisitor.cs b/SysML2.NET.CodeGenerator/Grammar/GraphicalNotationSpecificationVisitor.cs new file mode 100644 index 000000000..f3227008a --- /dev/null +++ b/SysML2.NET.CodeGenerator/Grammar/GraphicalNotationSpecificationVisitor.cs @@ -0,0 +1,138 @@ +// ------------------------------------------------------------------------------------------------ +// +// +// Copyright (C) 2022-2026 Starion Group S.A. +// SPDX-License-Identifier: Apache-2.0 +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.CodeGenerator.Grammar +{ + using System.Collections.Generic; + using System.Linq; + + using SysML2.NET.CodeGenerator.Grammar.Model; + + /// + /// Custom to read a + /// + public class GraphicalNotationSpecificationVisitor : kgbnfBaseVisitor + { + /// + /// Visits a parse tree produced by . + /// + /// The parse tree. + /// The visitor result, as . + public override object VisitAlternative(kgbnfParser.AlternativeContext context) + { + var alternatives = new GraphicalAlternatives(); + alternatives.Elements.AddRange(context.element().Select(element => (GraphicalRuleElement)this.Visit(element))); + return alternatives; + } + + /// + /// Visits a parse tree produced by . + /// + /// The parse tree. + /// The visitor result, as a list of . + public override object VisitAlternatives(kgbnfParser.AlternativesContext context) + => context.alternative().Select(alternative => (GraphicalAlternatives)this.Visit(alternative)).ToList(); + + /// + /// Visits a parse tree produced by . + /// + /// The parse tree. + /// The visitor result, as . + public override object VisitEdge_end(kgbnfParser.Edge_endContext context) + => new GraphicalEdgeEndElement + { + Name = context.name.Text, + Suffix = context.suffix?.GetText() + }; + + /// + /// Visits a parse tree produced by . + /// + /// The parse tree. + /// The visitor result, as . + public override object VisitGroup(kgbnfParser.GroupContext context) + { + var group = new GraphicalGroupElement + { + Suffix = context.suffix?.GetText() + }; + + group.Alternatives.AddRange((IEnumerable)this.Visit(context.alternatives())); + return group; + } + + /// + /// Visits a parse tree produced by . + /// + /// The parse tree. + /// The visitor result, as . + public override object VisitImage(kgbnfParser.ImageContext context) + => new GraphicalImageElement + { + Source = context.attribute() + .Where(attribute => attribute.attribute_name.Text == "src") + .Select(attribute => attribute.attribute_value.Text.Trim('"')) + .SingleOrDefault() + }; + + /// + /// Visits a parse tree produced by . + /// + /// The parse tree. + /// The visitor result, as . + public override object VisitNon_terminal(kgbnfParser.Non_terminalContext context) + => new GraphicalNonTerminalElement + { + Name = context.name.Text, + IsTextualReference = context.name.Type == kgbnfLexer.TEXTUAL_NAME, + Suffix = context.suffix?.GetText() + }; + + /// + /// Visits a parse tree produced by . + /// + /// The parse tree. + /// The visitor result, as . + public override object VisitRule_definition(kgbnfParser.Rule_definitionContext context) + { + var rule = new GraphicalNotationRule + { + RuleName = context.name.Text, + IsPartial = context.op.Type == kgbnfLexer.PARTIAL_ASSIGN + }; + + rule.Alternatives.AddRange((IEnumerable)this.Visit(context.rule_body)); + return rule; + } + + /// + /// Visits a parse tree produced by . + /// + /// The parse tree. + /// The visitor result, as . + public override object VisitSpecification(kgbnfParser.SpecificationContext context) + { + var specification = new GraphicalNotationSpecification(); + specification.Rules.AddRange(context.rule_definition().Select(rule => (GraphicalNotationRule)this.Visit(rule))); + return specification; + } + + /// + /// Visits a parse tree produced by . + /// + /// The parse tree. + /// The visitor result, as . + public override object VisitTerminal(kgbnfParser.TerminalContext context) + => new GraphicalTerminalElement + { + Value = context.val.Text.Trim('\''), + Suffix = context.suffix?.GetText() + }; + } +} diff --git a/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalAlternatives.cs b/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalAlternatives.cs new file mode 100644 index 000000000..f403f9b07 --- /dev/null +++ b/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalAlternatives.cs @@ -0,0 +1,24 @@ +// ------------------------------------------------------------------------------------------------ +// +// +// Copyright (C) 2022-2026 Starion Group S.A. +// SPDX-License-Identifier: Apache-2.0 +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.CodeGenerator.Grammar.Model +{ + using System.Collections.Generic; + + /// + /// Describes one alternative of a graphical production or group, as a sequence of elements + /// + public class GraphicalAlternatives + { + /// + /// Gets the s of the alternative, in sequence + /// + public List Elements { get; } = []; + } +} diff --git a/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalEdgeEndElement.cs b/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalEdgeEndElement.cs new file mode 100644 index 000000000..327a493bc --- /dev/null +++ b/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalEdgeEndElement.cs @@ -0,0 +1,22 @@ +// ------------------------------------------------------------------------------------------------ +// +// +// Copyright (C) 2022-2026 Starion Group S.A. +// SPDX-License-Identifier: Apache-2.0 +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.CodeGenerator.Grammar.Model +{ + /// + /// Describes an element connected by a graphical line, written &element (SysML 2.0 §8.2.3.1) + /// + public class GraphicalEdgeEndElement : GraphicalRuleElement + { + /// + /// Gets or sets the name of the connected production + /// + public string Name { get; set; } + } +} diff --git a/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalGroupElement.cs b/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalGroupElement.cs new file mode 100644 index 000000000..7687b421c --- /dev/null +++ b/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalGroupElement.cs @@ -0,0 +1,24 @@ +// ------------------------------------------------------------------------------------------------ +// +// +// Copyright (C) 2022-2026 Starion Group S.A. +// SPDX-License-Identifier: Apache-2.0 +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.CodeGenerator.Grammar.Model +{ + using System.Collections.Generic; + + /// + /// Describes a parenthesized group of + /// + public class GraphicalGroupElement : GraphicalRuleElement + { + /// + /// Gets the of the group + /// + public List Alternatives { get; } = []; + } +} diff --git a/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalImageElement.cs b/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalImageElement.cs new file mode 100644 index 000000000..2b5429d7e --- /dev/null +++ b/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalImageElement.cs @@ -0,0 +1,22 @@ +// ------------------------------------------------------------------------------------------------ +// +// +// Copyright (C) 2022-2026 Starion Group S.A. +// SPDX-License-Identifier: Apache-2.0 +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.CodeGenerator.Grammar.Model +{ + /// + /// Describes a graphical shape or line of a production, given as an embedded image + /// + public class GraphicalImageElement : GraphicalRuleElement + { + /// + /// Gets or sets the image path, relative to the grammar file + /// + public string Source { get; set; } + } +} diff --git a/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalNonTerminalElement.cs b/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalNonTerminalElement.cs new file mode 100644 index 000000000..6abef9fc3 --- /dev/null +++ b/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalNonTerminalElement.cs @@ -0,0 +1,28 @@ +// ------------------------------------------------------------------------------------------------ +// +// +// Copyright (C) 2022-2026 Starion Group S.A. +// SPDX-License-Identifier: Apache-2.0 +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.CodeGenerator.Grammar.Model +{ + /// + /// Describes a reference from a graphical production to another production + /// + public class GraphicalNonTerminalElement : GraphicalRuleElement + { + /// + /// Gets or sets the referenced production name + /// + public string Name { get; set; } + + /// + /// Gets or sets a value indicating whether the name contains an uppercase letter, and so references a textual + /// notation rule rather than a graphical production (SysML 2.0 §8.2.3.1) + /// + public bool IsTextualReference { get; set; } + } +} diff --git a/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalNotationRule.cs b/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalNotationRule.cs new file mode 100644 index 000000000..9d30da486 --- /dev/null +++ b/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalNotationRule.cs @@ -0,0 +1,35 @@ +// ------------------------------------------------------------------------------------------------ +// +// +// Copyright (C) 2022-2026 Starion Group S.A. +// SPDX-License-Identifier: Apache-2.0 +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.CodeGenerator.Grammar.Model +{ + using System.Collections.Generic; + + /// + /// Describes one production definition of the graphical notation + /// + public class GraphicalNotationRule + { + /// + /// Gets or sets the production name + /// + public string RuleName { get; set; } + + /// + /// Gets or sets a value indicating whether the definition is a partial production (=|) whose alternatives + /// add to other definitions of the same name (SysML 2.0 §8.2.3.1) + /// + public bool IsPartial { get; set; } + + /// + /// Gets the defined by the production + /// + public List Alternatives { get; } = []; + } +} diff --git a/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalNotationSpecification.cs b/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalNotationSpecification.cs new file mode 100644 index 000000000..ad26ab6bc --- /dev/null +++ b/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalNotationSpecification.cs @@ -0,0 +1,24 @@ +// ------------------------------------------------------------------------------------------------ +// +// +// Copyright (C) 2022-2026 Starion Group S.A. +// SPDX-License-Identifier: Apache-2.0 +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.CodeGenerator.Grammar.Model +{ + using System.Collections.Generic; + + /// + /// Provides access to all defined in the graphical notation specification + /// + public class GraphicalNotationSpecification + { + /// + /// Gets the s in declaration order, one per production definition + /// + public List Rules { get; } = []; + } +} diff --git a/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalRuleElement.cs b/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalRuleElement.cs new file mode 100644 index 000000000..43115e9d5 --- /dev/null +++ b/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalRuleElement.cs @@ -0,0 +1,22 @@ +// ------------------------------------------------------------------------------------------------ +// +// +// Copyright (C) 2022-2026 Starion Group S.A. +// SPDX-License-Identifier: Apache-2.0 +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.CodeGenerator.Grammar.Model +{ + /// + /// Base class for an element of a graphical production + /// + public abstract class GraphicalRuleElement + { + /// + /// Gets or sets the optional EBNF suffix (?, * or +) + /// + public string Suffix { get; set; } + } +} diff --git a/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalTerminalElement.cs b/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalTerminalElement.cs new file mode 100644 index 000000000..dfa11897f --- /dev/null +++ b/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalTerminalElement.cs @@ -0,0 +1,22 @@ +// ------------------------------------------------------------------------------------------------ +// +// +// Copyright (C) 2022-2026 Starion Group S.A. +// SPDX-License-Identifier: Apache-2.0 +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.CodeGenerator.Grammar.Model +{ + /// + /// Describes a literal string terminal of a graphical production + /// + public class GraphicalTerminalElement : GraphicalRuleElement + { + /// + /// Gets or sets the literal text, without its enclosing quotes + /// + public string Value { get; set; } + } +} diff --git a/SysML2.NET.CodeGenerator/SysML2.NET.CodeGenerator.csproj b/SysML2.NET.CodeGenerator/SysML2.NET.CodeGenerator.csproj index ea6d8b8de..f111ef67c 100644 --- a/SysML2.NET.CodeGenerator/SysML2.NET.CodeGenerator.csproj +++ b/SysML2.NET.CodeGenerator/SysML2.NET.CodeGenerator.csproj @@ -335,6 +335,9 @@ datamodel\kebnf.g4 + + datamodel\kgbnf.g4 + datamodel\KerML-textual-bnf.kebnf Always @@ -343,6 +346,10 @@ datamodel\ptc-25-02-30.json Always + + datamodel\SysML-graphical-bnf.kgbnf + Always + datamodel\SysML-textual-bnf.kebnf Always From 6c27be3ad5323cacba308d7a5aa30a16dd780801 Mon Sep 17 00:00:00 2001 From: antoineatsoprasteria Date: Thu, 12 Nov 2026 15:00:15 +0100 Subject: [PATCH 2/2] Fix #438: Grammar loader for kgbnf --- Resources/kgbnf.g4 | 10 +- .../GraphicalGrammarErrataTestFixture.cs | 33 +++ ...NotationSpecificationVisitorTestFixture.cs | 66 +---- .../Extensions/GraphicalGrammarErrata.cs | 99 +++++++ .../NET/CodeGenerator/Grammar/kgbnf.interp | 9 +- .../NET/CodeGenerator/Grammar/kgbnf.tokens | 20 +- .../Grammar/kgbnfBaseListener.cs | 12 - .../CodeGenerator/Grammar/kgbnfBaseVisitor.cs | 10 - .../NET/CodeGenerator/Grammar/kgbnfLexer.cs | 111 ++++---- .../CodeGenerator/Grammar/kgbnfLexer.interp | 12 +- .../CodeGenerator/Grammar/kgbnfLexer.tokens | 20 +- .../CodeGenerator/Grammar/kgbnfListener.cs | 10 - .../NET/CodeGenerator/Grammar/kgbnfParser.cs | 255 ++++++------------ .../NET/CodeGenerator/Grammar/kgbnfVisitor.cs | 6 - .../Grammar/GrammarLoader.cs | 119 ++++++++ .../GraphicalNotationSpecificationVisitor.cs | 9 +- .../Grammar/Model/GraphicalImageElement.cs | 6 +- .../Grammar/Model/GraphicalNotationRule.cs | 30 +++ .../Model/GraphicalNotationSpecification.cs | 32 +++ 19 files changed, 479 insertions(+), 390 deletions(-) create mode 100644 SysML2.NET.CodeGenerator.Tests/Extensions/GraphicalGrammarErrataTestFixture.cs create mode 100644 SysML2.NET.CodeGenerator/Extensions/GraphicalGrammarErrata.cs diff --git a/Resources/kgbnf.g4 b/Resources/kgbnf.g4 index 2cb479716..7d1ff25a8 100644 --- a/Resources/kgbnf.g4 +++ b/Resources/kgbnf.g4 @@ -33,11 +33,7 @@ terminal ; image - : IMG_OPEN attribute* TAG_CLOSE - ; - -attribute - : attribute_name=GRAPHICAL_NAME ASSIGN attribute_value=DOUBLE_QUOTED_STRING + : IMAGE ; edge_end @@ -57,13 +53,11 @@ PIPE : '|' ; LPAREN : '(' ; RPAREN : ')' ; AMPERSAND : '&' ; -IMG_OPEN : '' ; +IMAGE : ']* '>' ; GRAPHICAL_NAME : [a-z]+ ('-' [a-z]+)* ; TEXTUAL_NAME : [a-zA-Z_] [a-zA-Z0-9_]* ; SINGLE_QUOTED_STRING : '\'' (~['\\] | '\\' .)* '\'' ; -DOUBLE_QUOTED_STRING : '"' ~["\r\n]* '"' ; COMMENT : '//' ~[\r\n]* -> skip ; WS : [ \t]+ -> skip ; diff --git a/SysML2.NET.CodeGenerator.Tests/Extensions/GraphicalGrammarErrataTestFixture.cs b/SysML2.NET.CodeGenerator.Tests/Extensions/GraphicalGrammarErrataTestFixture.cs new file mode 100644 index 000000000..86012e08f --- /dev/null +++ b/SysML2.NET.CodeGenerator.Tests/Extensions/GraphicalGrammarErrataTestFixture.cs @@ -0,0 +1,33 @@ +// ------------------------------------------------------------------------------------------------ +// +// +// Copyright (C) 2022-2026 Starion Group S.A. +// SPDX-License-Identifier: Apache-2.0 +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.CodeGenerator.Tests.Extensions +{ + using System.IO; + using System.Linq; + + using NUnit.Framework; + + using SysML2.NET.CodeGenerator.Extensions; + using SysML2.NET.CodeGenerator.Grammar; + + [TestFixture] + public class GraphicalGrammarErrataTestFixture + { + [Test] + public void VerifyQueryUnappliedErrata() + { + GrammarLoader.LoadGraphicalNotationSpecification(Path.Combine(TestContext.CurrentContext.TestDirectory, "datamodel", "SysML-graphical-bnf.kgbnf")); + + var unapplied = GraphicalGrammarErrata.QueryUnappliedErrata(); + + Assert.That(unapplied, Is.Empty, $"Errata matched nothing in the graphical BNF: {string.Join(", ", unapplied.Select(erratum => erratum.RuleName))}"); + } + } +} diff --git a/SysML2.NET.CodeGenerator.Tests/Grammar/GraphicalNotationSpecificationVisitorTestFixture.cs b/SysML2.NET.CodeGenerator.Tests/Grammar/GraphicalNotationSpecificationVisitorTestFixture.cs index 02cf4c09f..1fa47ab91 100644 --- a/SysML2.NET.CodeGenerator.Tests/Grammar/GraphicalNotationSpecificationVisitorTestFixture.cs +++ b/SysML2.NET.CodeGenerator.Tests/Grammar/GraphicalNotationSpecificationVisitorTestFixture.cs @@ -10,7 +10,6 @@ namespace SysML2.NET.CodeGenerator.Tests.Grammar { using System.IO; - using System.Linq; using Antlr4.Runtime; @@ -27,70 +26,15 @@ public void VerifyCanParseGrammar() { var filePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "datamodel", "SysML-graphical-bnf.kgbnf"); - var (specification, syntaxErrorCount) = Parse(CharStreams.fromPath(filePath)); - var rules = specification.Rules; - - using (Assert.EnterMultipleScope()) - { - Assert.That(syntaxErrorCount, Is.Zero); - Assert.That(rules, Is.Not.Empty); - Assert.That(rules.Where(rule => rule.RuleName == "compartment").Select(rule => rule.IsPartial), Is.Not.Empty.And.All.True); - } - - var element = rules.Single(rule => rule.RuleName == "element"); - - using (Assert.EnterMultipleScope()) - { - Assert.That(element.IsPartial, Is.False); - Assert.That(element.Alternatives, Has.Count.EqualTo(3)); - Assert.That(element.Alternatives[1].Elements[0], Is.TypeOf().With.Property("Name").EqualTo("general-element")); - } - - var generalCompartment = rules.Single(rule => rule.RuleName == "general-compartment").Alternatives[0].Elements; - - using (Assert.EnterMultipleScope()) - { - Assert.That(generalCompartment, Has.Count.EqualTo(2)); - Assert.That(generalCompartment[0], Is.TypeOf().With.Property("Source").EqualTo("images/general-compartment.svg")); - Assert.That(generalCompartment[1], Is.TypeOf().With.Property("IsTextualReference").False); - } - - Assert.That(rules.Single(rule => rule.RuleName == "expose-r").Alternatives[0].Elements[0], - Is.TypeOf().With.Property("Source").EqualTo("images/expose-r.svg")); - - var usageCompartmentElements = rules.Single(rule => rule.RuleName == "usage-cp").Alternatives[0].Elements; - - using (Assert.EnterMultipleScope()) - { - Assert.That(usageCompartmentElements[0], Is.TypeOf().With.Property("IsTextualReference").True); - Assert.That(usageCompartmentElements[1], Is.TypeOf().With.Property("Name").EqualTo("ValuePart")); - Assert.That(usageCompartmentElements[1].Suffix, Is.EqualTo("?")); - } - - var naryDependency = rules.Single(rule => rule.RuleName == "n-ary-dependency").Alternatives[0].Elements; + var parser = new kgbnfParser(new CommonTokenStream(new kgbnfLexer(CharStreams.fromPath(filePath)))); + var tree = parser.specification(); + var specification = (GraphicalNotationSpecification)new GraphicalNotationSpecificationVisitor().Visit(tree); using (Assert.EnterMultipleScope()) { - Assert.That(naryDependency[0], Is.TypeOf().With.Property("Name").EqualTo("n-ary-association-dot")); - Assert.That(naryDependency[1], Is.TypeOf().With.Property("Suffix").EqualTo("+")); - Assert.That(((GraphicalGroupElement)naryDependency[1]).Alternatives[0].Elements[1], Is.TypeOf()); + Assert.That(parser.NumberOfSyntaxErrors, Is.Zero); + Assert.That(specification.Rules, Is.Not.Empty); } - - Assert.That(rules.Single(rule => rule.RuleName == "ellipsis-at-lower-left-corner").Alternatives[0].Elements[0], - Is.TypeOf().With.Property("Value").EqualTo("...")); - - (_, syntaxErrorCount) = Parse(CharStreams.fromString("broken = ( element\n")); - - Assert.That(syntaxErrorCount, Is.GreaterThan(0)); - } - - private static (GraphicalNotationSpecification Specification, int SyntaxErrorCount) Parse(ICharStream stream) - { - var parser = new kgbnfParser(new CommonTokenStream(new kgbnfLexer(stream))); - var tree = parser.specification(); - var specification = (GraphicalNotationSpecification)new GraphicalNotationSpecificationVisitor().Visit(tree); - - return (specification, parser.NumberOfSyntaxErrors); } } } diff --git a/SysML2.NET.CodeGenerator/Extensions/GraphicalGrammarErrata.cs b/SysML2.NET.CodeGenerator/Extensions/GraphicalGrammarErrata.cs new file mode 100644 index 000000000..0d407bdc2 --- /dev/null +++ b/SysML2.NET.CodeGenerator/Extensions/GraphicalGrammarErrata.cs @@ -0,0 +1,99 @@ +// ------------------------------------------------------------------------------------------------ +// +// +// Copyright (C) 2022-2026 Starion Group S.A. +// SPDX-License-Identifier: Apache-2.0 +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.CodeGenerator.Extensions +{ + using System; + using System.Collections.Generic; + using System.Linq; + + /// + /// Corrects known defects in the graphical BNF (Resources/SysML-graphical-bnf.kgbnf), at generation time. + /// + /// + /// The grammar is OMG source and is never edited. An entry belongs here only when a reference names no production and exactly + /// one production is evidently meant; a reference with no evident target stays unresolved and is reported by + /// GraphicalNotationSpecification.QueryUnresolvedReferences. + /// + public static class GraphicalGrammarErrata + { + /// + /// The production-text corrections applied to the grammar before it is parsed. + /// + private static readonly GrammarProductionErratum[] ProductionEntries = + [ + new("usage-cp", + "usage-cp = usageDeclaration ValuePart?", + "usage-cp = UsageDeclaration ValuePart?", + "SysML 8.2.3.6 writes 'usageDeclaration', which names no rule; every other reference in 8.2.3 writes the textual rule " + + "'UsageDeclaration' (SysML 8.2.2.6.2)."), + new("allocation-node", + "allocation-node =\n general-node\n | element-in-textual-compartment", + "allocation-node =\n general-node\n | element-inside-textual-compartment", + "SysML 8.2.3.15 references 'element-in-textual-compartment', which is never defined; the production is " + + "'element-inside-textual-compartment' (SysML 8.2.3.2)."), + new("exhibit-states-compartment-contents", + "exhibit-states-compartment-contents = exhibit-state-scompartment-element* '…'?\n\nexhibit-states-compartment-element-compartment = UsageDeclaration", + "exhibit-states-compartment-contents = exhibit-states-compartment-element* '…'?\n\nexhibit-states-compartment-element = UsageDeclaration", + "SysML 8.2.3.18 references 'exhibit-state-scompartment-element', which is never defined, and defines " + + "'exhibit-states-compartment-element-compartment', which is never referenced; every sibling compartment pairs " + + "'-compartment-contents' with '-compartment-element'."), + new("action-flow-view", + "(perform-action-swimlanes)?", + "(perform-actions-swimlanes)?", + "SysML 8.2.3.17 references 'perform-action-swimlanes', which is never defined; the production is 'perform-actions-swimlanes'.") + ]; + + /// + /// The production rule names whose corrections have matched during this generator run. + /// + private static readonly HashSet AppliedRuleNames = []; + + /// + /// Applies every known production correction to the raw text of the graphical BNF. + /// + /// The grammar text as read from disk. + /// The corrected grammar text with \n line endings, or when it is blank. + /// + /// Line endings are normalised first because every Original is written with \n. + /// + public static string ApplyProductions(string kgbnfSource) + { + if (string.IsNullOrWhiteSpace(kgbnfSource)) + { + return kgbnfSource; + } + + var normalisedSource = kgbnfSource.Replace("\r\n", "\n").Replace('\r', '\n'); + + return ProductionEntries + .Where(erratum => normalisedSource.Contains(erratum.Original, StringComparison.Ordinal)) + .Aggregate(normalisedSource, (corrected, erratum) => + { + AppliedRuleNames.Add(erratum.RuleName); + return corrected.Replace(erratum.Original, erratum.Replacement, StringComparison.Ordinal); + }); + } + + /// + /// Returns the corrections that matched nothing during this generator run. + /// + /// The stale entries, which should be pruned. + /// + /// Only meaningful once the graphical BNF has been loaded. + /// + public static IReadOnlyList<(string RuleName, string Justification)> QueryUnappliedErrata() + => + [ + ..ProductionEntries + .Where(erratum => !AppliedRuleNames.Contains(erratum.RuleName)) + .Select(erratum => (erratum.RuleName, erratum.Justification)) + ]; + } +} diff --git a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnf.interp b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnf.interp index 5edff5885..06587f432 100644 --- a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnf.interp +++ b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnf.interp @@ -9,8 +9,6 @@ null '(' ')' '&' -'' null null null @@ -31,12 +29,10 @@ PIPE LPAREN RPAREN AMPERSAND -IMG_OPEN -TAG_CLOSE +IMAGE GRAPHICAL_NAME TEXTUAL_NAME SINGLE_QUOTED_STRING -DOUBLE_QUOTED_STRING COMMENT WS CONTINUATION @@ -51,11 +47,10 @@ element group terminal image -attribute edge_end non_terminal suffix_op atn: -[4, 1, 19, 101, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 1, 0, 5, 0, 26, 8, 0, 10, 0, 12, 0, 29, 9, 0, 1, 0, 4, 0, 32, 8, 0, 11, 0, 12, 0, 33, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 42, 8, 1, 11, 1, 12, 1, 43, 1, 2, 1, 2, 1, 2, 5, 2, 49, 8, 2, 10, 2, 12, 2, 52, 9, 2, 1, 3, 5, 3, 55, 8, 3, 10, 3, 12, 3, 58, 9, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 65, 8, 4, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 71, 8, 5, 1, 6, 1, 6, 3, 6, 75, 8, 6, 1, 7, 1, 7, 5, 7, 79, 8, 7, 10, 7, 12, 7, 82, 9, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 3, 9, 93, 8, 9, 1, 10, 1, 10, 3, 10, 97, 8, 10, 1, 11, 1, 11, 1, 11, 0, 0, 12, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 0, 3, 1, 0, 4, 5, 1, 0, 12, 13, 1, 0, 1, 3, 102, 0, 27, 1, 0, 0, 0, 2, 37, 1, 0, 0, 0, 4, 45, 1, 0, 0, 0, 6, 56, 1, 0, 0, 0, 8, 64, 1, 0, 0, 0, 10, 66, 1, 0, 0, 0, 12, 72, 1, 0, 0, 0, 14, 76, 1, 0, 0, 0, 16, 85, 1, 0, 0, 0, 18, 89, 1, 0, 0, 0, 20, 94, 1, 0, 0, 0, 22, 98, 1, 0, 0, 0, 24, 26, 5, 19, 0, 0, 25, 24, 1, 0, 0, 0, 26, 29, 1, 0, 0, 0, 27, 25, 1, 0, 0, 0, 27, 28, 1, 0, 0, 0, 28, 31, 1, 0, 0, 0, 29, 27, 1, 0, 0, 0, 30, 32, 3, 2, 1, 0, 31, 30, 1, 0, 0, 0, 32, 33, 1, 0, 0, 0, 33, 31, 1, 0, 0, 0, 33, 34, 1, 0, 0, 0, 34, 35, 1, 0, 0, 0, 35, 36, 5, 0, 0, 1, 36, 1, 1, 0, 0, 0, 37, 38, 5, 12, 0, 0, 38, 39, 7, 0, 0, 0, 39, 41, 3, 4, 2, 0, 40, 42, 5, 19, 0, 0, 41, 40, 1, 0, 0, 0, 42, 43, 1, 0, 0, 0, 43, 41, 1, 0, 0, 0, 43, 44, 1, 0, 0, 0, 44, 3, 1, 0, 0, 0, 45, 50, 3, 6, 3, 0, 46, 47, 5, 6, 0, 0, 47, 49, 3, 6, 3, 0, 48, 46, 1, 0, 0, 0, 49, 52, 1, 0, 0, 0, 50, 48, 1, 0, 0, 0, 50, 51, 1, 0, 0, 0, 51, 5, 1, 0, 0, 0, 52, 50, 1, 0, 0, 0, 53, 55, 3, 8, 4, 0, 54, 53, 1, 0, 0, 0, 55, 58, 1, 0, 0, 0, 56, 54, 1, 0, 0, 0, 56, 57, 1, 0, 0, 0, 57, 7, 1, 0, 0, 0, 58, 56, 1, 0, 0, 0, 59, 65, 3, 10, 5, 0, 60, 65, 3, 12, 6, 0, 61, 65, 3, 14, 7, 0, 62, 65, 3, 18, 9, 0, 63, 65, 3, 20, 10, 0, 64, 59, 1, 0, 0, 0, 64, 60, 1, 0, 0, 0, 64, 61, 1, 0, 0, 0, 64, 62, 1, 0, 0, 0, 64, 63, 1, 0, 0, 0, 65, 9, 1, 0, 0, 0, 66, 67, 5, 7, 0, 0, 67, 68, 3, 4, 2, 0, 68, 70, 5, 8, 0, 0, 69, 71, 3, 22, 11, 0, 70, 69, 1, 0, 0, 0, 70, 71, 1, 0, 0, 0, 71, 11, 1, 0, 0, 0, 72, 74, 5, 14, 0, 0, 73, 75, 3, 22, 11, 0, 74, 73, 1, 0, 0, 0, 74, 75, 1, 0, 0, 0, 75, 13, 1, 0, 0, 0, 76, 80, 5, 10, 0, 0, 77, 79, 3, 16, 8, 0, 78, 77, 1, 0, 0, 0, 79, 82, 1, 0, 0, 0, 80, 78, 1, 0, 0, 0, 80, 81, 1, 0, 0, 0, 81, 83, 1, 0, 0, 0, 82, 80, 1, 0, 0, 0, 83, 84, 5, 11, 0, 0, 84, 15, 1, 0, 0, 0, 85, 86, 5, 12, 0, 0, 86, 87, 5, 5, 0, 0, 87, 88, 5, 15, 0, 0, 88, 17, 1, 0, 0, 0, 89, 90, 5, 9, 0, 0, 90, 92, 5, 12, 0, 0, 91, 93, 3, 22, 11, 0, 92, 91, 1, 0, 0, 0, 92, 93, 1, 0, 0, 0, 93, 19, 1, 0, 0, 0, 94, 96, 7, 1, 0, 0, 95, 97, 3, 22, 11, 0, 96, 95, 1, 0, 0, 0, 96, 97, 1, 0, 0, 0, 97, 21, 1, 0, 0, 0, 98, 99, 7, 2, 0, 0, 99, 23, 1, 0, 0, 0, 11, 27, 33, 43, 50, 56, 64, 70, 74, 80, 92, 96] \ No newline at end of file +[4, 1, 17, 88, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 1, 0, 5, 0, 24, 8, 0, 10, 0, 12, 0, 27, 9, 0, 1, 0, 4, 0, 30, 8, 0, 11, 0, 12, 0, 31, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 40, 8, 1, 11, 1, 12, 1, 41, 1, 2, 1, 2, 1, 2, 5, 2, 47, 8, 2, 10, 2, 12, 2, 50, 9, 2, 1, 3, 5, 3, 53, 8, 3, 10, 3, 12, 3, 56, 9, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 63, 8, 4, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 69, 8, 5, 1, 6, 1, 6, 3, 6, 73, 8, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 3, 8, 80, 8, 8, 1, 9, 1, 9, 3, 9, 84, 8, 9, 1, 10, 1, 10, 1, 10, 0, 0, 11, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 0, 3, 1, 0, 4, 5, 1, 0, 11, 12, 1, 0, 1, 3, 89, 0, 25, 1, 0, 0, 0, 2, 35, 1, 0, 0, 0, 4, 43, 1, 0, 0, 0, 6, 54, 1, 0, 0, 0, 8, 62, 1, 0, 0, 0, 10, 64, 1, 0, 0, 0, 12, 70, 1, 0, 0, 0, 14, 74, 1, 0, 0, 0, 16, 76, 1, 0, 0, 0, 18, 81, 1, 0, 0, 0, 20, 85, 1, 0, 0, 0, 22, 24, 5, 17, 0, 0, 23, 22, 1, 0, 0, 0, 24, 27, 1, 0, 0, 0, 25, 23, 1, 0, 0, 0, 25, 26, 1, 0, 0, 0, 26, 29, 1, 0, 0, 0, 27, 25, 1, 0, 0, 0, 28, 30, 3, 2, 1, 0, 29, 28, 1, 0, 0, 0, 30, 31, 1, 0, 0, 0, 31, 29, 1, 0, 0, 0, 31, 32, 1, 0, 0, 0, 32, 33, 1, 0, 0, 0, 33, 34, 5, 0, 0, 1, 34, 1, 1, 0, 0, 0, 35, 36, 5, 11, 0, 0, 36, 37, 7, 0, 0, 0, 37, 39, 3, 4, 2, 0, 38, 40, 5, 17, 0, 0, 39, 38, 1, 0, 0, 0, 40, 41, 1, 0, 0, 0, 41, 39, 1, 0, 0, 0, 41, 42, 1, 0, 0, 0, 42, 3, 1, 0, 0, 0, 43, 48, 3, 6, 3, 0, 44, 45, 5, 6, 0, 0, 45, 47, 3, 6, 3, 0, 46, 44, 1, 0, 0, 0, 47, 50, 1, 0, 0, 0, 48, 46, 1, 0, 0, 0, 48, 49, 1, 0, 0, 0, 49, 5, 1, 0, 0, 0, 50, 48, 1, 0, 0, 0, 51, 53, 3, 8, 4, 0, 52, 51, 1, 0, 0, 0, 53, 56, 1, 0, 0, 0, 54, 52, 1, 0, 0, 0, 54, 55, 1, 0, 0, 0, 55, 7, 1, 0, 0, 0, 56, 54, 1, 0, 0, 0, 57, 63, 3, 10, 5, 0, 58, 63, 3, 12, 6, 0, 59, 63, 3, 14, 7, 0, 60, 63, 3, 16, 8, 0, 61, 63, 3, 18, 9, 0, 62, 57, 1, 0, 0, 0, 62, 58, 1, 0, 0, 0, 62, 59, 1, 0, 0, 0, 62, 60, 1, 0, 0, 0, 62, 61, 1, 0, 0, 0, 63, 9, 1, 0, 0, 0, 64, 65, 5, 7, 0, 0, 65, 66, 3, 4, 2, 0, 66, 68, 5, 8, 0, 0, 67, 69, 3, 20, 10, 0, 68, 67, 1, 0, 0, 0, 68, 69, 1, 0, 0, 0, 69, 11, 1, 0, 0, 0, 70, 72, 5, 13, 0, 0, 71, 73, 3, 20, 10, 0, 72, 71, 1, 0, 0, 0, 72, 73, 1, 0, 0, 0, 73, 13, 1, 0, 0, 0, 74, 75, 5, 10, 0, 0, 75, 15, 1, 0, 0, 0, 76, 77, 5, 9, 0, 0, 77, 79, 5, 11, 0, 0, 78, 80, 3, 20, 10, 0, 79, 78, 1, 0, 0, 0, 79, 80, 1, 0, 0, 0, 80, 17, 1, 0, 0, 0, 81, 83, 7, 1, 0, 0, 82, 84, 3, 20, 10, 0, 83, 82, 1, 0, 0, 0, 83, 84, 1, 0, 0, 0, 84, 19, 1, 0, 0, 0, 85, 86, 7, 2, 0, 0, 86, 21, 1, 0, 0, 0, 10, 25, 31, 41, 48, 54, 62, 68, 72, 79, 83] \ No newline at end of file diff --git a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnf.tokens b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnf.tokens index 96daeed64..e8634e780 100644 --- a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnf.tokens +++ b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnf.tokens @@ -7,16 +7,14 @@ PIPE=6 LPAREN=7 RPAREN=8 AMPERSAND=9 -IMG_OPEN=10 -TAG_CLOSE=11 -GRAPHICAL_NAME=12 -TEXTUAL_NAME=13 -SINGLE_QUOTED_STRING=14 -DOUBLE_QUOTED_STRING=15 -COMMENT=16 -WS=17 -CONTINUATION=18 -NL=19 +IMAGE=10 +GRAPHICAL_NAME=11 +TEXTUAL_NAME=12 +SINGLE_QUOTED_STRING=13 +COMMENT=14 +WS=15 +CONTINUATION=16 +NL=17 '*'=1 '+'=2 '?'=3 @@ -25,5 +23,3 @@ NL=19 '('=7 ')'=8 '&'=9 -''=11 diff --git a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfBaseListener.cs b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfBaseListener.cs index a980b787a..cdb483553 100644 --- a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfBaseListener.cs +++ b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfBaseListener.cs @@ -133,18 +133,6 @@ public virtual void EnterImage([NotNull] kgbnfParser.ImageContext context) { } /// The parse tree. public virtual void ExitImage([NotNull] kgbnfParser.ImageContext context) { } /// - /// Enter a parse tree produced by . - /// The default implementation does nothing. - /// - /// The parse tree. - public virtual void EnterAttribute([NotNull] kgbnfParser.AttributeContext context) { } - /// - /// Exit a parse tree produced by . - /// The default implementation does nothing. - /// - /// The parse tree. - public virtual void ExitAttribute([NotNull] kgbnfParser.AttributeContext context) { } - /// /// Enter a parse tree produced by . /// The default implementation does nothing. /// diff --git a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfBaseVisitor.cs b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfBaseVisitor.cs index d5d277c94..f36b2729b 100644 --- a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfBaseVisitor.cs +++ b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfBaseVisitor.cs @@ -116,16 +116,6 @@ public partial class kgbnfBaseVisitor : AbstractParseTreeVisitor /// The visitor result. public virtual Result VisitImage([NotNull] kgbnfParser.ImageContext context) { return VisitChildren(context); } /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitAttribute([NotNull] kgbnfParser.AttributeContext context) { return VisitChildren(context); } - /// /// Visit a parse tree produced by . /// /// The default implementation returns the result of calling diff --git a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfLexer.cs b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfLexer.cs index 2661302bb..678adde31 100644 --- a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfLexer.cs +++ b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfLexer.cs @@ -35,9 +35,8 @@ public partial class kgbnfLexer : Lexer { protected static PredictionContextCache sharedContextCache = new PredictionContextCache(); public const int T__0=1, T__1=2, T__2=3, PARTIAL_ASSIGN=4, ASSIGN=5, PIPE=6, LPAREN=7, - RPAREN=8, AMPERSAND=9, IMG_OPEN=10, TAG_CLOSE=11, GRAPHICAL_NAME=12, TEXTUAL_NAME=13, - SINGLE_QUOTED_STRING=14, DOUBLE_QUOTED_STRING=15, COMMENT=16, WS=17, CONTINUATION=18, - NL=19; + RPAREN=8, AMPERSAND=9, IMAGE=10, GRAPHICAL_NAME=11, TEXTUAL_NAME=12, SINGLE_QUOTED_STRING=13, + COMMENT=14, WS=15, CONTINUATION=16, NL=17; public static string[] channelNames = { "DEFAULT_TOKEN_CHANNEL", "HIDDEN" }; @@ -48,9 +47,8 @@ public const int public static readonly string[] ruleNames = { "T__0", "T__1", "T__2", "PARTIAL_ASSIGN", "ASSIGN", "PIPE", "LPAREN", - "RPAREN", "AMPERSAND", "IMG_OPEN", "TAG_CLOSE", "GRAPHICAL_NAME", "TEXTUAL_NAME", - "SINGLE_QUOTED_STRING", "DOUBLE_QUOTED_STRING", "COMMENT", "WS", "CONTINUATION", - "NL" + "RPAREN", "AMPERSAND", "IMAGE", "GRAPHICAL_NAME", "TEXTUAL_NAME", "SINGLE_QUOTED_STRING", + "COMMENT", "WS", "CONTINUATION", "NL" }; @@ -64,14 +62,12 @@ public kgbnfLexer(ICharStream input, TextWriter output, TextWriter errorOutput) } private static readonly string[] _LiteralNames = { - null, "'*'", "'+'", "'?'", null, "'='", "'|'", "'('", "')'", "'&'", "''" + null, "'*'", "'+'", "'?'", null, "'='", "'|'", "'('", "')'", "'&'" }; private static readonly string[] _SymbolicNames = { null, null, null, null, "PARTIAL_ASSIGN", "ASSIGN", "PIPE", "LPAREN", - "RPAREN", "AMPERSAND", "IMG_OPEN", "TAG_CLOSE", "GRAPHICAL_NAME", "TEXTUAL_NAME", - "SINGLE_QUOTED_STRING", "DOUBLE_QUOTED_STRING", "COMMENT", "WS", "CONTINUATION", - "NL" + "RPAREN", "AMPERSAND", "IMAGE", "GRAPHICAL_NAME", "TEXTUAL_NAME", "SINGLE_QUOTED_STRING", + "COMMENT", "WS", "CONTINUATION", "NL" }; public static readonly IVocabulary DefaultVocabulary = new Vocabulary(_LiteralNames, _SymbolicNames); @@ -101,55 +97,52 @@ static kgbnfLexer() { } } private static int[] _serializedATN = { - 4,0,19,145,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7, + 4,0,17,138,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7, 6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14, - 7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,1,0,1,0,1,1,1,1,1,2,1,2,1, - 3,1,3,1,3,1,3,3,3,50,8,3,1,4,1,4,1,5,1,5,1,6,1,6,1,7,1,7,1,8,1,8,1,9,1, - 9,1,9,1,9,1,9,1,10,1,10,1,11,4,11,70,8,11,11,11,12,11,71,1,11,1,11,4,11, - 76,8,11,11,11,12,11,77,5,11,80,8,11,10,11,12,11,83,9,11,1,12,1,12,5,12, - 87,8,12,10,12,12,12,90,9,12,1,13,1,13,1,13,1,13,5,13,96,8,13,10,13,12, - 13,99,9,13,1,13,1,13,1,14,1,14,5,14,105,8,14,10,14,12,14,108,9,14,1,14, - 1,14,1,15,1,15,1,15,1,15,5,15,116,8,15,10,15,12,15,119,9,15,1,15,1,15, - 1,16,4,16,124,8,16,11,16,12,16,125,1,16,1,16,1,17,3,17,131,8,17,1,17,1, - 17,4,17,135,8,17,11,17,12,17,136,1,17,1,17,1,18,3,18,142,8,18,1,18,1,18, - 0,0,19,1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17,9,19,10,21,11,23,12,25,13, - 27,14,29,15,31,16,33,17,35,18,37,19,1,0,7,1,0,97,122,3,0,65,90,95,95,97, - 122,4,0,48,57,65,90,95,95,97,122,2,0,39,39,92,92,3,0,10,10,13,13,34,34, - 2,0,10,10,13,13,2,0,9,9,32,32,157,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0, - 0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,15,1,0,0,0,0,17,1, - 0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,0,0,25,1,0,0,0,0,27,1,0,0,0, - 0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,0,35,1,0,0,0,0,37,1,0,0,0,1,39, - 1,0,0,0,3,41,1,0,0,0,5,43,1,0,0,0,7,49,1,0,0,0,9,51,1,0,0,0,11,53,1,0, - 0,0,13,55,1,0,0,0,15,57,1,0,0,0,17,59,1,0,0,0,19,61,1,0,0,0,21,66,1,0, - 0,0,23,69,1,0,0,0,25,84,1,0,0,0,27,91,1,0,0,0,29,102,1,0,0,0,31,111,1, - 0,0,0,33,123,1,0,0,0,35,130,1,0,0,0,37,141,1,0,0,0,39,40,5,42,0,0,40,2, - 1,0,0,0,41,42,5,43,0,0,42,4,1,0,0,0,43,44,5,63,0,0,44,6,1,0,0,0,45,46, - 5,61,0,0,46,50,5,124,0,0,47,48,5,124,0,0,48,50,5,61,0,0,49,45,1,0,0,0, - 49,47,1,0,0,0,50,8,1,0,0,0,51,52,5,61,0,0,52,10,1,0,0,0,53,54,5,124,0, - 0,54,12,1,0,0,0,55,56,5,40,0,0,56,14,1,0,0,0,57,58,5,41,0,0,58,16,1,0, - 0,0,59,60,5,38,0,0,60,18,1,0,0,0,61,62,5,60,0,0,62,63,5,105,0,0,63,64, - 5,109,0,0,64,65,5,103,0,0,65,20,1,0,0,0,66,67,5,62,0,0,67,22,1,0,0,0,68, - 70,7,0,0,0,69,68,1,0,0,0,70,71,1,0,0,0,71,69,1,0,0,0,71,72,1,0,0,0,72, - 81,1,0,0,0,73,75,5,45,0,0,74,76,7,0,0,0,75,74,1,0,0,0,76,77,1,0,0,0,77, - 75,1,0,0,0,77,78,1,0,0,0,78,80,1,0,0,0,79,73,1,0,0,0,80,83,1,0,0,0,81, - 79,1,0,0,0,81,82,1,0,0,0,82,24,1,0,0,0,83,81,1,0,0,0,84,88,7,1,0,0,85, - 87,7,2,0,0,86,85,1,0,0,0,87,90,1,0,0,0,88,86,1,0,0,0,88,89,1,0,0,0,89, - 26,1,0,0,0,90,88,1,0,0,0,91,97,5,39,0,0,92,96,8,3,0,0,93,94,5,92,0,0,94, - 96,9,0,0,0,95,92,1,0,0,0,95,93,1,0,0,0,96,99,1,0,0,0,97,95,1,0,0,0,97, - 98,1,0,0,0,98,100,1,0,0,0,99,97,1,0,0,0,100,101,5,39,0,0,101,28,1,0,0, - 0,102,106,5,34,0,0,103,105,8,4,0,0,104,103,1,0,0,0,105,108,1,0,0,0,106, - 104,1,0,0,0,106,107,1,0,0,0,107,109,1,0,0,0,108,106,1,0,0,0,109,110,5, - 34,0,0,110,30,1,0,0,0,111,112,5,47,0,0,112,113,5,47,0,0,113,117,1,0,0, - 0,114,116,8,5,0,0,115,114,1,0,0,0,116,119,1,0,0,0,117,115,1,0,0,0,117, - 118,1,0,0,0,118,120,1,0,0,0,119,117,1,0,0,0,120,121,6,15,0,0,121,32,1, - 0,0,0,122,124,7,6,0,0,123,122,1,0,0,0,124,125,1,0,0,0,125,123,1,0,0,0, - 125,126,1,0,0,0,126,127,1,0,0,0,127,128,6,16,0,0,128,34,1,0,0,0,129,131, - 5,13,0,0,130,129,1,0,0,0,130,131,1,0,0,0,131,132,1,0,0,0,132,134,5,10, - 0,0,133,135,7,6,0,0,134,133,1,0,0,0,135,136,1,0,0,0,136,134,1,0,0,0,136, - 137,1,0,0,0,137,138,1,0,0,0,138,139,6,17,0,0,139,36,1,0,0,0,140,142,5, - 13,0,0,141,140,1,0,0,0,141,142,1,0,0,0,142,143,1,0,0,0,143,144,5,10,0, - 0,144,38,1,0,0,0,14,0,49,71,77,81,88,95,97,106,117,125,130,136,141,1,6, - 0,0 + 7,14,2,15,7,15,2,16,7,16,1,0,1,0,1,1,1,1,1,2,1,2,1,3,1,3,1,3,1,3,3,3,46, + 8,3,1,4,1,4,1,5,1,5,1,6,1,6,1,7,1,7,1,8,1,8,1,9,1,9,1,9,1,9,1,9,1,9,5, + 9,64,8,9,10,9,12,9,67,9,9,1,9,1,9,1,10,4,10,72,8,10,11,10,12,10,73,1,10, + 1,10,4,10,78,8,10,11,10,12,10,79,5,10,82,8,10,10,10,12,10,85,9,10,1,11, + 1,11,5,11,89,8,11,10,11,12,11,92,9,11,1,12,1,12,1,12,1,12,5,12,98,8,12, + 10,12,12,12,101,9,12,1,12,1,12,1,13,1,13,1,13,1,13,5,13,109,8,13,10,13, + 12,13,112,9,13,1,13,1,13,1,14,4,14,117,8,14,11,14,12,14,118,1,14,1,14, + 1,15,3,15,124,8,15,1,15,1,15,4,15,128,8,15,11,15,12,15,129,1,15,1,15,1, + 16,3,16,135,8,16,1,16,1,16,0,0,17,1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17, + 9,19,10,21,11,23,12,25,13,27,14,29,15,31,16,33,17,1,0,7,1,0,62,62,1,0, + 97,122,3,0,65,90,95,95,97,122,4,0,48,57,65,90,95,95,97,122,2,0,39,39,92, + 92,2,0,10,10,13,13,2,0,9,9,32,32,150,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0, + 0,0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,15,1,0,0,0,0,17, + 1,0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,0,0,25,1,0,0,0,0,27,1,0,0, + 0,0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,1,35,1,0,0,0,3,37,1,0,0,0,5,39, + 1,0,0,0,7,45,1,0,0,0,9,47,1,0,0,0,11,49,1,0,0,0,13,51,1,0,0,0,15,53,1, + 0,0,0,17,55,1,0,0,0,19,57,1,0,0,0,21,71,1,0,0,0,23,86,1,0,0,0,25,93,1, + 0,0,0,27,104,1,0,0,0,29,116,1,0,0,0,31,123,1,0,0,0,33,134,1,0,0,0,35,36, + 5,42,0,0,36,2,1,0,0,0,37,38,5,43,0,0,38,4,1,0,0,0,39,40,5,63,0,0,40,6, + 1,0,0,0,41,42,5,61,0,0,42,46,5,124,0,0,43,44,5,124,0,0,44,46,5,61,0,0, + 45,41,1,0,0,0,45,43,1,0,0,0,46,8,1,0,0,0,47,48,5,61,0,0,48,10,1,0,0,0, + 49,50,5,124,0,0,50,12,1,0,0,0,51,52,5,40,0,0,52,14,1,0,0,0,53,54,5,41, + 0,0,54,16,1,0,0,0,55,56,5,38,0,0,56,18,1,0,0,0,57,58,5,60,0,0,58,59,5, + 105,0,0,59,60,5,109,0,0,60,61,5,103,0,0,61,65,1,0,0,0,62,64,8,0,0,0,63, + 62,1,0,0,0,64,67,1,0,0,0,65,63,1,0,0,0,65,66,1,0,0,0,66,68,1,0,0,0,67, + 65,1,0,0,0,68,69,5,62,0,0,69,20,1,0,0,0,70,72,7,1,0,0,71,70,1,0,0,0,72, + 73,1,0,0,0,73,71,1,0,0,0,73,74,1,0,0,0,74,83,1,0,0,0,75,77,5,45,0,0,76, + 78,7,1,0,0,77,76,1,0,0,0,78,79,1,0,0,0,79,77,1,0,0,0,79,80,1,0,0,0,80, + 82,1,0,0,0,81,75,1,0,0,0,82,85,1,0,0,0,83,81,1,0,0,0,83,84,1,0,0,0,84, + 22,1,0,0,0,85,83,1,0,0,0,86,90,7,2,0,0,87,89,7,3,0,0,88,87,1,0,0,0,89, + 92,1,0,0,0,90,88,1,0,0,0,90,91,1,0,0,0,91,24,1,0,0,0,92,90,1,0,0,0,93, + 99,5,39,0,0,94,98,8,4,0,0,95,96,5,92,0,0,96,98,9,0,0,0,97,94,1,0,0,0,97, + 95,1,0,0,0,98,101,1,0,0,0,99,97,1,0,0,0,99,100,1,0,0,0,100,102,1,0,0,0, + 101,99,1,0,0,0,102,103,5,39,0,0,103,26,1,0,0,0,104,105,5,47,0,0,105,106, + 5,47,0,0,106,110,1,0,0,0,107,109,8,5,0,0,108,107,1,0,0,0,109,112,1,0,0, + 0,110,108,1,0,0,0,110,111,1,0,0,0,111,113,1,0,0,0,112,110,1,0,0,0,113, + 114,6,13,0,0,114,28,1,0,0,0,115,117,7,6,0,0,116,115,1,0,0,0,117,118,1, + 0,0,0,118,116,1,0,0,0,118,119,1,0,0,0,119,120,1,0,0,0,120,121,6,14,0,0, + 121,30,1,0,0,0,122,124,5,13,0,0,123,122,1,0,0,0,123,124,1,0,0,0,124,125, + 1,0,0,0,125,127,5,10,0,0,126,128,7,6,0,0,127,126,1,0,0,0,128,129,1,0,0, + 0,129,127,1,0,0,0,129,130,1,0,0,0,130,131,1,0,0,0,131,132,6,15,0,0,132, + 32,1,0,0,0,133,135,5,13,0,0,134,133,1,0,0,0,134,135,1,0,0,0,135,136,1, + 0,0,0,136,137,5,10,0,0,137,34,1,0,0,0,14,0,45,65,73,79,83,90,97,99,110, + 118,123,129,134,1,6,0,0 }; public static readonly ATN _ATN = diff --git a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfLexer.interp b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfLexer.interp index 2877de067..1da0be937 100644 --- a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfLexer.interp +++ b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfLexer.interp @@ -9,8 +9,6 @@ null '(' ')' '&' -'' null null null @@ -31,12 +29,10 @@ PIPE LPAREN RPAREN AMPERSAND -IMG_OPEN -TAG_CLOSE +IMAGE GRAPHICAL_NAME TEXTUAL_NAME SINGLE_QUOTED_STRING -DOUBLE_QUOTED_STRING COMMENT WS CONTINUATION @@ -52,12 +48,10 @@ PIPE LPAREN RPAREN AMPERSAND -IMG_OPEN -TAG_CLOSE +IMAGE GRAPHICAL_NAME TEXTUAL_NAME SINGLE_QUOTED_STRING -DOUBLE_QUOTED_STRING COMMENT WS CONTINUATION @@ -71,4 +65,4 @@ mode names: DEFAULT_MODE atn: -[4, 0, 19, 145, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 50, 8, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 4, 11, 70, 8, 11, 11, 11, 12, 11, 71, 1, 11, 1, 11, 4, 11, 76, 8, 11, 11, 11, 12, 11, 77, 5, 11, 80, 8, 11, 10, 11, 12, 11, 83, 9, 11, 1, 12, 1, 12, 5, 12, 87, 8, 12, 10, 12, 12, 12, 90, 9, 12, 1, 13, 1, 13, 1, 13, 1, 13, 5, 13, 96, 8, 13, 10, 13, 12, 13, 99, 9, 13, 1, 13, 1, 13, 1, 14, 1, 14, 5, 14, 105, 8, 14, 10, 14, 12, 14, 108, 9, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 15, 5, 15, 116, 8, 15, 10, 15, 12, 15, 119, 9, 15, 1, 15, 1, 15, 1, 16, 4, 16, 124, 8, 16, 11, 16, 12, 16, 125, 1, 16, 1, 16, 1, 17, 3, 17, 131, 8, 17, 1, 17, 1, 17, 4, 17, 135, 8, 17, 11, 17, 12, 17, 136, 1, 17, 1, 17, 1, 18, 3, 18, 142, 8, 18, 1, 18, 1, 18, 0, 0, 19, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 1, 0, 7, 1, 0, 97, 122, 3, 0, 65, 90, 95, 95, 97, 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 2, 0, 39, 39, 92, 92, 3, 0, 10, 10, 13, 13, 34, 34, 2, 0, 10, 10, 13, 13, 2, 0, 9, 9, 32, 32, 157, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 1, 39, 1, 0, 0, 0, 3, 41, 1, 0, 0, 0, 5, 43, 1, 0, 0, 0, 7, 49, 1, 0, 0, 0, 9, 51, 1, 0, 0, 0, 11, 53, 1, 0, 0, 0, 13, 55, 1, 0, 0, 0, 15, 57, 1, 0, 0, 0, 17, 59, 1, 0, 0, 0, 19, 61, 1, 0, 0, 0, 21, 66, 1, 0, 0, 0, 23, 69, 1, 0, 0, 0, 25, 84, 1, 0, 0, 0, 27, 91, 1, 0, 0, 0, 29, 102, 1, 0, 0, 0, 31, 111, 1, 0, 0, 0, 33, 123, 1, 0, 0, 0, 35, 130, 1, 0, 0, 0, 37, 141, 1, 0, 0, 0, 39, 40, 5, 42, 0, 0, 40, 2, 1, 0, 0, 0, 41, 42, 5, 43, 0, 0, 42, 4, 1, 0, 0, 0, 43, 44, 5, 63, 0, 0, 44, 6, 1, 0, 0, 0, 45, 46, 5, 61, 0, 0, 46, 50, 5, 124, 0, 0, 47, 48, 5, 124, 0, 0, 48, 50, 5, 61, 0, 0, 49, 45, 1, 0, 0, 0, 49, 47, 1, 0, 0, 0, 50, 8, 1, 0, 0, 0, 51, 52, 5, 61, 0, 0, 52, 10, 1, 0, 0, 0, 53, 54, 5, 124, 0, 0, 54, 12, 1, 0, 0, 0, 55, 56, 5, 40, 0, 0, 56, 14, 1, 0, 0, 0, 57, 58, 5, 41, 0, 0, 58, 16, 1, 0, 0, 0, 59, 60, 5, 38, 0, 0, 60, 18, 1, 0, 0, 0, 61, 62, 5, 60, 0, 0, 62, 63, 5, 105, 0, 0, 63, 64, 5, 109, 0, 0, 64, 65, 5, 103, 0, 0, 65, 20, 1, 0, 0, 0, 66, 67, 5, 62, 0, 0, 67, 22, 1, 0, 0, 0, 68, 70, 7, 0, 0, 0, 69, 68, 1, 0, 0, 0, 70, 71, 1, 0, 0, 0, 71, 69, 1, 0, 0, 0, 71, 72, 1, 0, 0, 0, 72, 81, 1, 0, 0, 0, 73, 75, 5, 45, 0, 0, 74, 76, 7, 0, 0, 0, 75, 74, 1, 0, 0, 0, 76, 77, 1, 0, 0, 0, 77, 75, 1, 0, 0, 0, 77, 78, 1, 0, 0, 0, 78, 80, 1, 0, 0, 0, 79, 73, 1, 0, 0, 0, 80, 83, 1, 0, 0, 0, 81, 79, 1, 0, 0, 0, 81, 82, 1, 0, 0, 0, 82, 24, 1, 0, 0, 0, 83, 81, 1, 0, 0, 0, 84, 88, 7, 1, 0, 0, 85, 87, 7, 2, 0, 0, 86, 85, 1, 0, 0, 0, 87, 90, 1, 0, 0, 0, 88, 86, 1, 0, 0, 0, 88, 89, 1, 0, 0, 0, 89, 26, 1, 0, 0, 0, 90, 88, 1, 0, 0, 0, 91, 97, 5, 39, 0, 0, 92, 96, 8, 3, 0, 0, 93, 94, 5, 92, 0, 0, 94, 96, 9, 0, 0, 0, 95, 92, 1, 0, 0, 0, 95, 93, 1, 0, 0, 0, 96, 99, 1, 0, 0, 0, 97, 95, 1, 0, 0, 0, 97, 98, 1, 0, 0, 0, 98, 100, 1, 0, 0, 0, 99, 97, 1, 0, 0, 0, 100, 101, 5, 39, 0, 0, 101, 28, 1, 0, 0, 0, 102, 106, 5, 34, 0, 0, 103, 105, 8, 4, 0, 0, 104, 103, 1, 0, 0, 0, 105, 108, 1, 0, 0, 0, 106, 104, 1, 0, 0, 0, 106, 107, 1, 0, 0, 0, 107, 109, 1, 0, 0, 0, 108, 106, 1, 0, 0, 0, 109, 110, 5, 34, 0, 0, 110, 30, 1, 0, 0, 0, 111, 112, 5, 47, 0, 0, 112, 113, 5, 47, 0, 0, 113, 117, 1, 0, 0, 0, 114, 116, 8, 5, 0, 0, 115, 114, 1, 0, 0, 0, 116, 119, 1, 0, 0, 0, 117, 115, 1, 0, 0, 0, 117, 118, 1, 0, 0, 0, 118, 120, 1, 0, 0, 0, 119, 117, 1, 0, 0, 0, 120, 121, 6, 15, 0, 0, 121, 32, 1, 0, 0, 0, 122, 124, 7, 6, 0, 0, 123, 122, 1, 0, 0, 0, 124, 125, 1, 0, 0, 0, 125, 123, 1, 0, 0, 0, 125, 126, 1, 0, 0, 0, 126, 127, 1, 0, 0, 0, 127, 128, 6, 16, 0, 0, 128, 34, 1, 0, 0, 0, 129, 131, 5, 13, 0, 0, 130, 129, 1, 0, 0, 0, 130, 131, 1, 0, 0, 0, 131, 132, 1, 0, 0, 0, 132, 134, 5, 10, 0, 0, 133, 135, 7, 6, 0, 0, 134, 133, 1, 0, 0, 0, 135, 136, 1, 0, 0, 0, 136, 134, 1, 0, 0, 0, 136, 137, 1, 0, 0, 0, 137, 138, 1, 0, 0, 0, 138, 139, 6, 17, 0, 0, 139, 36, 1, 0, 0, 0, 140, 142, 5, 13, 0, 0, 141, 140, 1, 0, 0, 0, 141, 142, 1, 0, 0, 0, 142, 143, 1, 0, 0, 0, 143, 144, 5, 10, 0, 0, 144, 38, 1, 0, 0, 0, 14, 0, 49, 71, 77, 81, 88, 95, 97, 106, 117, 125, 130, 136, 141, 1, 6, 0, 0] \ No newline at end of file +[4, 0, 17, 138, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 46, 8, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 5, 9, 64, 8, 9, 10, 9, 12, 9, 67, 9, 9, 1, 9, 1, 9, 1, 10, 4, 10, 72, 8, 10, 11, 10, 12, 10, 73, 1, 10, 1, 10, 4, 10, 78, 8, 10, 11, 10, 12, 10, 79, 5, 10, 82, 8, 10, 10, 10, 12, 10, 85, 9, 10, 1, 11, 1, 11, 5, 11, 89, 8, 11, 10, 11, 12, 11, 92, 9, 11, 1, 12, 1, 12, 1, 12, 1, 12, 5, 12, 98, 8, 12, 10, 12, 12, 12, 101, 9, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 5, 13, 109, 8, 13, 10, 13, 12, 13, 112, 9, 13, 1, 13, 1, 13, 1, 14, 4, 14, 117, 8, 14, 11, 14, 12, 14, 118, 1, 14, 1, 14, 1, 15, 3, 15, 124, 8, 15, 1, 15, 1, 15, 4, 15, 128, 8, 15, 11, 15, 12, 15, 129, 1, 15, 1, 15, 1, 16, 3, 16, 135, 8, 16, 1, 16, 1, 16, 0, 0, 17, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 1, 0, 7, 1, 0, 62, 62, 1, 0, 97, 122, 3, 0, 65, 90, 95, 95, 97, 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 2, 0, 39, 39, 92, 92, 2, 0, 10, 10, 13, 13, 2, 0, 9, 9, 32, 32, 150, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 1, 35, 1, 0, 0, 0, 3, 37, 1, 0, 0, 0, 5, 39, 1, 0, 0, 0, 7, 45, 1, 0, 0, 0, 9, 47, 1, 0, 0, 0, 11, 49, 1, 0, 0, 0, 13, 51, 1, 0, 0, 0, 15, 53, 1, 0, 0, 0, 17, 55, 1, 0, 0, 0, 19, 57, 1, 0, 0, 0, 21, 71, 1, 0, 0, 0, 23, 86, 1, 0, 0, 0, 25, 93, 1, 0, 0, 0, 27, 104, 1, 0, 0, 0, 29, 116, 1, 0, 0, 0, 31, 123, 1, 0, 0, 0, 33, 134, 1, 0, 0, 0, 35, 36, 5, 42, 0, 0, 36, 2, 1, 0, 0, 0, 37, 38, 5, 43, 0, 0, 38, 4, 1, 0, 0, 0, 39, 40, 5, 63, 0, 0, 40, 6, 1, 0, 0, 0, 41, 42, 5, 61, 0, 0, 42, 46, 5, 124, 0, 0, 43, 44, 5, 124, 0, 0, 44, 46, 5, 61, 0, 0, 45, 41, 1, 0, 0, 0, 45, 43, 1, 0, 0, 0, 46, 8, 1, 0, 0, 0, 47, 48, 5, 61, 0, 0, 48, 10, 1, 0, 0, 0, 49, 50, 5, 124, 0, 0, 50, 12, 1, 0, 0, 0, 51, 52, 5, 40, 0, 0, 52, 14, 1, 0, 0, 0, 53, 54, 5, 41, 0, 0, 54, 16, 1, 0, 0, 0, 55, 56, 5, 38, 0, 0, 56, 18, 1, 0, 0, 0, 57, 58, 5, 60, 0, 0, 58, 59, 5, 105, 0, 0, 59, 60, 5, 109, 0, 0, 60, 61, 5, 103, 0, 0, 61, 65, 1, 0, 0, 0, 62, 64, 8, 0, 0, 0, 63, 62, 1, 0, 0, 0, 64, 67, 1, 0, 0, 0, 65, 63, 1, 0, 0, 0, 65, 66, 1, 0, 0, 0, 66, 68, 1, 0, 0, 0, 67, 65, 1, 0, 0, 0, 68, 69, 5, 62, 0, 0, 69, 20, 1, 0, 0, 0, 70, 72, 7, 1, 0, 0, 71, 70, 1, 0, 0, 0, 72, 73, 1, 0, 0, 0, 73, 71, 1, 0, 0, 0, 73, 74, 1, 0, 0, 0, 74, 83, 1, 0, 0, 0, 75, 77, 5, 45, 0, 0, 76, 78, 7, 1, 0, 0, 77, 76, 1, 0, 0, 0, 78, 79, 1, 0, 0, 0, 79, 77, 1, 0, 0, 0, 79, 80, 1, 0, 0, 0, 80, 82, 1, 0, 0, 0, 81, 75, 1, 0, 0, 0, 82, 85, 1, 0, 0, 0, 83, 81, 1, 0, 0, 0, 83, 84, 1, 0, 0, 0, 84, 22, 1, 0, 0, 0, 85, 83, 1, 0, 0, 0, 86, 90, 7, 2, 0, 0, 87, 89, 7, 3, 0, 0, 88, 87, 1, 0, 0, 0, 89, 92, 1, 0, 0, 0, 90, 88, 1, 0, 0, 0, 90, 91, 1, 0, 0, 0, 91, 24, 1, 0, 0, 0, 92, 90, 1, 0, 0, 0, 93, 99, 5, 39, 0, 0, 94, 98, 8, 4, 0, 0, 95, 96, 5, 92, 0, 0, 96, 98, 9, 0, 0, 0, 97, 94, 1, 0, 0, 0, 97, 95, 1, 0, 0, 0, 98, 101, 1, 0, 0, 0, 99, 97, 1, 0, 0, 0, 99, 100, 1, 0, 0, 0, 100, 102, 1, 0, 0, 0, 101, 99, 1, 0, 0, 0, 102, 103, 5, 39, 0, 0, 103, 26, 1, 0, 0, 0, 104, 105, 5, 47, 0, 0, 105, 106, 5, 47, 0, 0, 106, 110, 1, 0, 0, 0, 107, 109, 8, 5, 0, 0, 108, 107, 1, 0, 0, 0, 109, 112, 1, 0, 0, 0, 110, 108, 1, 0, 0, 0, 110, 111, 1, 0, 0, 0, 111, 113, 1, 0, 0, 0, 112, 110, 1, 0, 0, 0, 113, 114, 6, 13, 0, 0, 114, 28, 1, 0, 0, 0, 115, 117, 7, 6, 0, 0, 116, 115, 1, 0, 0, 0, 117, 118, 1, 0, 0, 0, 118, 116, 1, 0, 0, 0, 118, 119, 1, 0, 0, 0, 119, 120, 1, 0, 0, 0, 120, 121, 6, 14, 0, 0, 121, 30, 1, 0, 0, 0, 122, 124, 5, 13, 0, 0, 123, 122, 1, 0, 0, 0, 123, 124, 1, 0, 0, 0, 124, 125, 1, 0, 0, 0, 125, 127, 5, 10, 0, 0, 126, 128, 7, 6, 0, 0, 127, 126, 1, 0, 0, 0, 128, 129, 1, 0, 0, 0, 129, 127, 1, 0, 0, 0, 129, 130, 1, 0, 0, 0, 130, 131, 1, 0, 0, 0, 131, 132, 6, 15, 0, 0, 132, 32, 1, 0, 0, 0, 133, 135, 5, 13, 0, 0, 134, 133, 1, 0, 0, 0, 134, 135, 1, 0, 0, 0, 135, 136, 1, 0, 0, 0, 136, 137, 5, 10, 0, 0, 137, 34, 1, 0, 0, 0, 14, 0, 45, 65, 73, 79, 83, 90, 97, 99, 110, 118, 123, 129, 134, 1, 6, 0, 0] \ No newline at end of file diff --git a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfLexer.tokens b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfLexer.tokens index 96daeed64..e8634e780 100644 --- a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfLexer.tokens +++ b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfLexer.tokens @@ -7,16 +7,14 @@ PIPE=6 LPAREN=7 RPAREN=8 AMPERSAND=9 -IMG_OPEN=10 -TAG_CLOSE=11 -GRAPHICAL_NAME=12 -TEXTUAL_NAME=13 -SINGLE_QUOTED_STRING=14 -DOUBLE_QUOTED_STRING=15 -COMMENT=16 -WS=17 -CONTINUATION=18 -NL=19 +IMAGE=10 +GRAPHICAL_NAME=11 +TEXTUAL_NAME=12 +SINGLE_QUOTED_STRING=13 +COMMENT=14 +WS=15 +CONTINUATION=16 +NL=17 '*'=1 '+'=2 '?'=3 @@ -25,5 +23,3 @@ NL=19 '('=7 ')'=8 '&'=9 -''=11 diff --git a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfListener.cs b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfListener.cs index caf3e00d1..ac4ee4877 100644 --- a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfListener.cs +++ b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfListener.cs @@ -112,16 +112,6 @@ public interface IkgbnfListener : IParseTreeListener { /// The parse tree. void ExitImage([NotNull] kgbnfParser.ImageContext context); /// - /// Enter a parse tree produced by . - /// - /// The parse tree. - void EnterAttribute([NotNull] kgbnfParser.AttributeContext context); - /// - /// Exit a parse tree produced by . - /// - /// The parse tree. - void ExitAttribute([NotNull] kgbnfParser.AttributeContext context); - /// /// Enter a parse tree produced by . /// /// The parse tree. diff --git a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfParser.cs b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfParser.cs index 9f281d35a..a2b56f9e5 100644 --- a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfParser.cs +++ b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfParser.cs @@ -38,29 +38,24 @@ public partial class kgbnfParser : Parser { protected static PredictionContextCache sharedContextCache = new PredictionContextCache(); public const int T__0=1, T__1=2, T__2=3, PARTIAL_ASSIGN=4, ASSIGN=5, PIPE=6, LPAREN=7, - RPAREN=8, AMPERSAND=9, IMG_OPEN=10, TAG_CLOSE=11, GRAPHICAL_NAME=12, TEXTUAL_NAME=13, - SINGLE_QUOTED_STRING=14, DOUBLE_QUOTED_STRING=15, COMMENT=16, WS=17, CONTINUATION=18, - NL=19; + RPAREN=8, AMPERSAND=9, IMAGE=10, GRAPHICAL_NAME=11, TEXTUAL_NAME=12, SINGLE_QUOTED_STRING=13, + COMMENT=14, WS=15, CONTINUATION=16, NL=17; public const int RULE_specification = 0, RULE_rule_definition = 1, RULE_alternatives = 2, RULE_alternative = 3, RULE_element = 4, RULE_group = 5, RULE_terminal = 6, - RULE_image = 7, RULE_attribute = 8, RULE_edge_end = 9, RULE_non_terminal = 10, - RULE_suffix_op = 11; + RULE_image = 7, RULE_edge_end = 8, RULE_non_terminal = 9, RULE_suffix_op = 10; public static readonly string[] ruleNames = { "specification", "rule_definition", "alternatives", "alternative", "element", - "group", "terminal", "image", "attribute", "edge_end", "non_terminal", - "suffix_op" + "group", "terminal", "image", "edge_end", "non_terminal", "suffix_op" }; private static readonly string[] _LiteralNames = { - null, "'*'", "'+'", "'?'", null, "'='", "'|'", "'('", "')'", "'&'", "''" + null, "'*'", "'+'", "'?'", null, "'='", "'|'", "'('", "')'", "'&'" }; private static readonly string[] _SymbolicNames = { null, null, null, null, "PARTIAL_ASSIGN", "ASSIGN", "PIPE", "LPAREN", - "RPAREN", "AMPERSAND", "IMG_OPEN", "TAG_CLOSE", "GRAPHICAL_NAME", "TEXTUAL_NAME", - "SINGLE_QUOTED_STRING", "DOUBLE_QUOTED_STRING", "COMMENT", "WS", "CONTINUATION", - "NL" + "RPAREN", "AMPERSAND", "IMAGE", "GRAPHICAL_NAME", "TEXTUAL_NAME", "SINGLE_QUOTED_STRING", + "COMMENT", "WS", "CONTINUATION", "NL" }; public static readonly IVocabulary DefaultVocabulary = new Vocabulary(_LiteralNames, _SymbolicNames); @@ -137,35 +132,35 @@ public SpecificationContext specification() { try { EnterOuterAlt(_localctx, 1); { - State = 27; + State = 25; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (_la==NL) { { { - State = 24; + State = 22; Match(NL); } } - State = 29; + State = 27; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } - State = 31; + State = 29; ErrorHandler.Sync(this); _la = TokenStream.LA(1); do { { { - State = 30; + State = 28; rule_definition(); } } - State = 33; + State = 31; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } while ( _la==GRAPHICAL_NAME ); - State = 35; + State = 33; Match(Eof); } } @@ -225,9 +220,9 @@ public Rule_definitionContext rule_definition() { try { EnterOuterAlt(_localctx, 1); { - State = 37; + State = 35; _localctx.name = Match(GRAPHICAL_NAME); - State = 38; + State = 36; _localctx.op = TokenStream.LT(1); _la = TokenStream.LA(1); if ( !(_la==PARTIAL_ASSIGN || _la==ASSIGN) ) { @@ -237,19 +232,19 @@ public Rule_definitionContext rule_definition() { ErrorHandler.ReportMatch(this); Consume(); } - State = 39; + State = 37; _localctx.rule_body = alternatives(); - State = 41; + State = 39; ErrorHandler.Sync(this); _la = TokenStream.LA(1); do { { { - State = 40; + State = 38; Match(NL); } } - State = 43; + State = 41; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } while ( _la==NL ); @@ -308,21 +303,21 @@ public AlternativesContext alternatives() { try { EnterOuterAlt(_localctx, 1); { - State = 45; + State = 43; alternative(); - State = 50; + State = 48; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (_la==PIPE) { { { - State = 46; + State = 44; Match(PIPE); - State = 47; + State = 45; alternative(); } } - State = 52; + State = 50; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } @@ -377,17 +372,17 @@ public AlternativeContext alternative() { try { EnterOuterAlt(_localctx, 1); { - State = 56; + State = 54; ErrorHandler.Sync(this); _la = TokenStream.LA(1); - while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 30336L) != 0)) { + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 16000L) != 0)) { { { - State = 53; + State = 51; element(); } } - State = 58; + State = 56; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } @@ -448,34 +443,34 @@ public ElementContext element() { ElementContext _localctx = new ElementContext(Context, State); EnterRule(_localctx, 8, RULE_element); try { - State = 64; + State = 62; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case LPAREN: EnterOuterAlt(_localctx, 1); { - State = 59; + State = 57; group(); } break; case SINGLE_QUOTED_STRING: EnterOuterAlt(_localctx, 2); { - State = 60; + State = 58; terminal(); } break; - case IMG_OPEN: + case IMAGE: EnterOuterAlt(_localctx, 3); { - State = 61; + State = 59; image(); } break; case AMPERSAND: EnterOuterAlt(_localctx, 4); { - State = 62; + State = 60; edge_end(); } break; @@ -483,7 +478,7 @@ public ElementContext element() { case TEXTUAL_NAME: EnterOuterAlt(_localctx, 5); { - State = 63; + State = 61; non_terminal(); } break; @@ -543,18 +538,18 @@ public GroupContext group() { try { EnterOuterAlt(_localctx, 1); { - State = 66; + State = 64; Match(LPAREN); - State = 67; + State = 65; alternatives(); - State = 68; + State = 66; Match(RPAREN); - State = 70; + State = 68; ErrorHandler.Sync(this); _la = TokenStream.LA(1); if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 14L) != 0)) { { - State = 69; + State = 67; _localctx.suffix = suffix_op(); } } @@ -610,14 +605,14 @@ public TerminalContext terminal() { try { EnterOuterAlt(_localctx, 1); { - State = 72; + State = 70; _localctx.val = Match(SINGLE_QUOTED_STRING); - State = 74; + State = 72; ErrorHandler.Sync(this); _la = TokenStream.LA(1); if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 14L) != 0)) { { - State = 73; + State = 71; _localctx.suffix = suffix_op(); } } @@ -636,14 +631,7 @@ public TerminalContext terminal() { } public partial class ImageContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode IMG_OPEN() { return GetToken(kgbnfParser.IMG_OPEN, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode TAG_CLOSE() { return GetToken(kgbnfParser.TAG_CLOSE, 0); } - [System.Diagnostics.DebuggerNonUserCode] public AttributeContext[] attribute() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public AttributeContext attribute(int i) { - return GetRuleContext(i); - } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode IMAGE() { return GetToken(kgbnfParser.IMAGE, 0); } public ImageContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { @@ -671,83 +659,11 @@ public override TResult Accept(IParseTreeVisitor visitor) { public ImageContext image() { ImageContext _localctx = new ImageContext(Context, State); EnterRule(_localctx, 14, RULE_image); - int _la; try { EnterOuterAlt(_localctx, 1); { - State = 76; - Match(IMG_OPEN); - State = 80; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - while (_la==GRAPHICAL_NAME) { - { - { - State = 77; - attribute(); - } - } - State = 82; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - } - State = 83; - Match(TAG_CLOSE); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class AttributeContext : ParserRuleContext { - public IToken attribute_name; - public IToken attribute_value; - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ASSIGN() { return GetToken(kgbnfParser.ASSIGN, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode GRAPHICAL_NAME() { return GetToken(kgbnfParser.GRAPHICAL_NAME, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode DOUBLE_QUOTED_STRING() { return GetToken(kgbnfParser.DOUBLE_QUOTED_STRING, 0); } - public AttributeContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_attribute; } } - [System.Diagnostics.DebuggerNonUserCode] - public override void EnterRule(IParseTreeListener listener) { - IkgbnfListener typedListener = listener as IkgbnfListener; - if (typedListener != null) typedListener.EnterAttribute(this); - } - [System.Diagnostics.DebuggerNonUserCode] - public override void ExitRule(IParseTreeListener listener) { - IkgbnfListener typedListener = listener as IkgbnfListener; - if (typedListener != null) typedListener.ExitAttribute(this); - } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IkgbnfVisitor typedVisitor = visitor as IkgbnfVisitor; - if (typedVisitor != null) return typedVisitor.VisitAttribute(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public AttributeContext attribute() { - AttributeContext _localctx = new AttributeContext(Context, State); - EnterRule(_localctx, 16, RULE_attribute); - try { - EnterOuterAlt(_localctx, 1); - { - State = 85; - _localctx.attribute_name = Match(GRAPHICAL_NAME); - State = 86; - Match(ASSIGN); - State = 87; - _localctx.attribute_value = Match(DOUBLE_QUOTED_STRING); + State = 74; + Match(IMAGE); } } catch (RecognitionException re) { @@ -795,21 +711,21 @@ public override TResult Accept(IParseTreeVisitor visitor) { [RuleVersion(0)] public Edge_endContext edge_end() { Edge_endContext _localctx = new Edge_endContext(Context, State); - EnterRule(_localctx, 18, RULE_edge_end); + EnterRule(_localctx, 16, RULE_edge_end); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 89; + State = 76; Match(AMPERSAND); - State = 90; + State = 77; _localctx.name = Match(GRAPHICAL_NAME); - State = 92; + State = 79; ErrorHandler.Sync(this); _la = TokenStream.LA(1); if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 14L) != 0)) { { - State = 91; + State = 78; _localctx.suffix = suffix_op(); } } @@ -861,12 +777,12 @@ public override TResult Accept(IParseTreeVisitor visitor) { [RuleVersion(0)] public Non_terminalContext non_terminal() { Non_terminalContext _localctx = new Non_terminalContext(Context, State); - EnterRule(_localctx, 20, RULE_non_terminal); + EnterRule(_localctx, 18, RULE_non_terminal); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 94; + State = 81; _localctx.name = TokenStream.LT(1); _la = TokenStream.LA(1); if ( !(_la==GRAPHICAL_NAME || _la==TEXTUAL_NAME) ) { @@ -876,12 +792,12 @@ public Non_terminalContext non_terminal() { ErrorHandler.ReportMatch(this); Consume(); } - State = 96; + State = 83; ErrorHandler.Sync(this); _la = TokenStream.LA(1); if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 14L) != 0)) { { - State = 95; + State = 82; _localctx.suffix = suffix_op(); } } @@ -926,12 +842,12 @@ public override TResult Accept(IParseTreeVisitor visitor) { [RuleVersion(0)] public Suffix_opContext suffix_op() { Suffix_opContext _localctx = new Suffix_opContext(Context, State); - EnterRule(_localctx, 22, RULE_suffix_op); + EnterRule(_localctx, 20, RULE_suffix_op); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 98; + State = 85; _la = TokenStream.LA(1); if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 14L) != 0)) ) { ErrorHandler.RecoverInline(this); @@ -954,35 +870,32 @@ public Suffix_opContext suffix_op() { } private static int[] _serializedATN = { - 4,1,19,101,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7, - 7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,1,0,5,0,26,8,0,10,0,12,0,29,9, - 0,1,0,4,0,32,8,0,11,0,12,0,33,1,0,1,0,1,1,1,1,1,1,1,1,4,1,42,8,1,11,1, - 12,1,43,1,2,1,2,1,2,5,2,49,8,2,10,2,12,2,52,9,2,1,3,5,3,55,8,3,10,3,12, - 3,58,9,3,1,4,1,4,1,4,1,4,1,4,3,4,65,8,4,1,5,1,5,1,5,1,5,3,5,71,8,5,1,6, - 1,6,3,6,75,8,6,1,7,1,7,5,7,79,8,7,10,7,12,7,82,9,7,1,7,1,7,1,8,1,8,1,8, - 1,8,1,9,1,9,1,9,3,9,93,8,9,1,10,1,10,3,10,97,8,10,1,11,1,11,1,11,0,0,12, - 0,2,4,6,8,10,12,14,16,18,20,22,0,3,1,0,4,5,1,0,12,13,1,0,1,3,102,0,27, - 1,0,0,0,2,37,1,0,0,0,4,45,1,0,0,0,6,56,1,0,0,0,8,64,1,0,0,0,10,66,1,0, - 0,0,12,72,1,0,0,0,14,76,1,0,0,0,16,85,1,0,0,0,18,89,1,0,0,0,20,94,1,0, - 0,0,22,98,1,0,0,0,24,26,5,19,0,0,25,24,1,0,0,0,26,29,1,0,0,0,27,25,1,0, - 0,0,27,28,1,0,0,0,28,31,1,0,0,0,29,27,1,0,0,0,30,32,3,2,1,0,31,30,1,0, - 0,0,32,33,1,0,0,0,33,31,1,0,0,0,33,34,1,0,0,0,34,35,1,0,0,0,35,36,5,0, - 0,1,36,1,1,0,0,0,37,38,5,12,0,0,38,39,7,0,0,0,39,41,3,4,2,0,40,42,5,19, - 0,0,41,40,1,0,0,0,42,43,1,0,0,0,43,41,1,0,0,0,43,44,1,0,0,0,44,3,1,0,0, - 0,45,50,3,6,3,0,46,47,5,6,0,0,47,49,3,6,3,0,48,46,1,0,0,0,49,52,1,0,0, - 0,50,48,1,0,0,0,50,51,1,0,0,0,51,5,1,0,0,0,52,50,1,0,0,0,53,55,3,8,4,0, - 54,53,1,0,0,0,55,58,1,0,0,0,56,54,1,0,0,0,56,57,1,0,0,0,57,7,1,0,0,0,58, - 56,1,0,0,0,59,65,3,10,5,0,60,65,3,12,6,0,61,65,3,14,7,0,62,65,3,18,9,0, - 63,65,3,20,10,0,64,59,1,0,0,0,64,60,1,0,0,0,64,61,1,0,0,0,64,62,1,0,0, - 0,64,63,1,0,0,0,65,9,1,0,0,0,66,67,5,7,0,0,67,68,3,4,2,0,68,70,5,8,0,0, - 69,71,3,22,11,0,70,69,1,0,0,0,70,71,1,0,0,0,71,11,1,0,0,0,72,74,5,14,0, - 0,73,75,3,22,11,0,74,73,1,0,0,0,74,75,1,0,0,0,75,13,1,0,0,0,76,80,5,10, - 0,0,77,79,3,16,8,0,78,77,1,0,0,0,79,82,1,0,0,0,80,78,1,0,0,0,80,81,1,0, - 0,0,81,83,1,0,0,0,82,80,1,0,0,0,83,84,5,11,0,0,84,15,1,0,0,0,85,86,5,12, - 0,0,86,87,5,5,0,0,87,88,5,15,0,0,88,17,1,0,0,0,89,90,5,9,0,0,90,92,5,12, - 0,0,91,93,3,22,11,0,92,91,1,0,0,0,92,93,1,0,0,0,93,19,1,0,0,0,94,96,7, - 1,0,0,95,97,3,22,11,0,96,95,1,0,0,0,96,97,1,0,0,0,97,21,1,0,0,0,98,99, - 7,2,0,0,99,23,1,0,0,0,11,27,33,43,50,56,64,70,74,80,92,96 + 4,1,17,88,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7, + 7,7,2,8,7,8,2,9,7,9,2,10,7,10,1,0,5,0,24,8,0,10,0,12,0,27,9,0,1,0,4,0, + 30,8,0,11,0,12,0,31,1,0,1,0,1,1,1,1,1,1,1,1,4,1,40,8,1,11,1,12,1,41,1, + 2,1,2,1,2,5,2,47,8,2,10,2,12,2,50,9,2,1,3,5,3,53,8,3,10,3,12,3,56,9,3, + 1,4,1,4,1,4,1,4,1,4,3,4,63,8,4,1,5,1,5,1,5,1,5,3,5,69,8,5,1,6,1,6,3,6, + 73,8,6,1,7,1,7,1,8,1,8,1,8,3,8,80,8,8,1,9,1,9,3,9,84,8,9,1,10,1,10,1,10, + 0,0,11,0,2,4,6,8,10,12,14,16,18,20,0,3,1,0,4,5,1,0,11,12,1,0,1,3,89,0, + 25,1,0,0,0,2,35,1,0,0,0,4,43,1,0,0,0,6,54,1,0,0,0,8,62,1,0,0,0,10,64,1, + 0,0,0,12,70,1,0,0,0,14,74,1,0,0,0,16,76,1,0,0,0,18,81,1,0,0,0,20,85,1, + 0,0,0,22,24,5,17,0,0,23,22,1,0,0,0,24,27,1,0,0,0,25,23,1,0,0,0,25,26,1, + 0,0,0,26,29,1,0,0,0,27,25,1,0,0,0,28,30,3,2,1,0,29,28,1,0,0,0,30,31,1, + 0,0,0,31,29,1,0,0,0,31,32,1,0,0,0,32,33,1,0,0,0,33,34,5,0,0,1,34,1,1,0, + 0,0,35,36,5,11,0,0,36,37,7,0,0,0,37,39,3,4,2,0,38,40,5,17,0,0,39,38,1, + 0,0,0,40,41,1,0,0,0,41,39,1,0,0,0,41,42,1,0,0,0,42,3,1,0,0,0,43,48,3,6, + 3,0,44,45,5,6,0,0,45,47,3,6,3,0,46,44,1,0,0,0,47,50,1,0,0,0,48,46,1,0, + 0,0,48,49,1,0,0,0,49,5,1,0,0,0,50,48,1,0,0,0,51,53,3,8,4,0,52,51,1,0,0, + 0,53,56,1,0,0,0,54,52,1,0,0,0,54,55,1,0,0,0,55,7,1,0,0,0,56,54,1,0,0,0, + 57,63,3,10,5,0,58,63,3,12,6,0,59,63,3,14,7,0,60,63,3,16,8,0,61,63,3,18, + 9,0,62,57,1,0,0,0,62,58,1,0,0,0,62,59,1,0,0,0,62,60,1,0,0,0,62,61,1,0, + 0,0,63,9,1,0,0,0,64,65,5,7,0,0,65,66,3,4,2,0,66,68,5,8,0,0,67,69,3,20, + 10,0,68,67,1,0,0,0,68,69,1,0,0,0,69,11,1,0,0,0,70,72,5,13,0,0,71,73,3, + 20,10,0,72,71,1,0,0,0,72,73,1,0,0,0,73,13,1,0,0,0,74,75,5,10,0,0,75,15, + 1,0,0,0,76,77,5,9,0,0,77,79,5,11,0,0,78,80,3,20,10,0,79,78,1,0,0,0,79, + 80,1,0,0,0,80,17,1,0,0,0,81,83,7,1,0,0,82,84,3,20,10,0,83,82,1,0,0,0,83, + 84,1,0,0,0,84,19,1,0,0,0,85,86,7,2,0,0,86,21,1,0,0,0,10,25,31,41,48,54, + 62,68,72,79,83 }; public static readonly ATN _ATN = diff --git a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfVisitor.cs b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfVisitor.cs index 3c3f9c84c..9609d9251 100644 --- a/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfVisitor.cs +++ b/SysML2.NET.CodeGenerator/Grammar/AutoGenGrammar/SysML2/NET/CodeGenerator/Grammar/kgbnfVisitor.cs @@ -81,12 +81,6 @@ public interface IkgbnfVisitor : IParseTreeVisitor { /// The visitor result. Result VisitImage([NotNull] kgbnfParser.ImageContext context); /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitAttribute([NotNull] kgbnfParser.AttributeContext context); - /// /// Visit a parse tree produced by . /// /// The parse tree. diff --git a/SysML2.NET.CodeGenerator/Grammar/GrammarLoader.cs b/SysML2.NET.CodeGenerator/Grammar/GrammarLoader.cs index ec6e1d6a5..c9259afc8 100644 --- a/SysML2.NET.CodeGenerator/Grammar/GrammarLoader.cs +++ b/SysML2.NET.CodeGenerator/Grammar/GrammarLoader.cs @@ -9,7 +9,9 @@ namespace SysML2.NET.CodeGenerator.Grammar { + using System.Collections.Generic; using System.IO; + using System.Linq; using Antlr4.Runtime; @@ -45,5 +47,122 @@ public static TextualNotationSpecification LoadTextualNotationSpecification(stri var explorer = new TextualNotationSpecificationVisitor(); return (TextualNotationSpecification)explorer.Visit(tree); } + + /// + /// Loads the , with each production's definitions merged + /// + /// The string uri that locates the KGBNF file to load + /// The loaded , holding one per production name + /// If does not locate an existing + /// If the grammar is not valid graphical notation + public static GraphicalNotationSpecification LoadGraphicalNotationSpecification(string fileUri) + { + if (!File.Exists(fileUri)) + { + throw new FileNotFoundException("File not found", fileUri); + } + + var syntaxErrors = new SyntaxErrorCollector(); + var tree = CreateGraphicalParser(GraphicalGrammarErrata.ApplyProductions(File.ReadAllText(fileUri)), syntaxErrors).specification(); + syntaxErrors.ThrowIfAny(fileUri); + + return MergeProductions((GraphicalNotationSpecification)new GraphicalNotationSpecificationVisitor().Visit(tree)); + } + + /// + /// Creates a over graphical notation text that reports every lexer and parser error to a collector + /// + /// The graphical notation text + /// The receiving the errors + /// The + private static kgbnfParser CreateGraphicalParser(string source, SyntaxErrorCollector syntaxErrors) + { + var lexer = new kgbnfLexer(CharStreams.fromString(source)); + lexer.RemoveErrorListeners(); + lexer.AddErrorListener(syntaxErrors); + + var parser = new kgbnfParser(new CommonTokenStream(lexer)); + parser.RemoveErrorListeners(); + parser.AddErrorListener(syntaxErrors); + + return parser; + } + + /// + /// Merges every definition of a production name into one , in declaration order + /// + /// The holding one rule per definition + /// The holding one rule per production name + /// + /// Partial productions (=|) distribute their alternatives across definitions (SysML 2.0 §8.2.3.1). + /// + private static GraphicalNotationSpecification MergeProductions(GraphicalNotationSpecification specification) + { + var merged = new GraphicalNotationSpecification(); + + merged.Rules.AddRange(specification.Rules.GroupBy(rule => rule.RuleName).Select(definitions => + { + var production = new GraphicalNotationRule + { + RuleName = definitions.Key, + IsPartial = definitions.Any(definition => definition.IsPartial) + }; + + production.Alternatives.AddRange(definitions.SelectMany(definition => definition.Alternatives)); + return production; + })); + + return merged; + } + + /// + /// Collects the lexer and parser errors raised while reading graphical notation + /// + private sealed class SyntaxErrorCollector : IAntlrErrorListener, IAntlrErrorListener + { + /// + /// Gets the collected error messages, each prefixed with its line and column + /// + private List Messages { get; } = []; + + /// + /// Records a lexer error + /// + /// The output the error would be written to + /// The lexer + /// The offending character + /// The line of the error + /// The column of the error + /// The error message + /// The recognition exception, if any + public void SyntaxError(TextWriter output, IRecognizer recognizer, int offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e) + => this.Messages.Add($"{line}:{charPositionInLine} {msg}"); + + /// + /// Records a parser error + /// + /// The output the error would be written to + /// The parser + /// The offending token + /// The line of the error + /// The column of the error + /// The error message + /// The recognition exception, if any + public void SyntaxError(TextWriter output, IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e) + => this.Messages.Add($"{line}:{charPositionInLine} {msg}"); + + /// + /// Rejects text that could not be read in full + /// + /// The name of the read source, reported in the exception + /// If any error was collected + public void ThrowIfAny(string source) + { + if (this.Messages.Count > 0) + { + throw new InvalidDataException($"'{source}' is not valid graphical notation: {string.Join("; ", this.Messages)}"); + } + } + } } } diff --git a/SysML2.NET.CodeGenerator/Grammar/GraphicalNotationSpecificationVisitor.cs b/SysML2.NET.CodeGenerator/Grammar/GraphicalNotationSpecificationVisitor.cs index f3227008a..d46ff525a 100644 --- a/SysML2.NET.CodeGenerator/Grammar/GraphicalNotationSpecificationVisitor.cs +++ b/SysML2.NET.CodeGenerator/Grammar/GraphicalNotationSpecificationVisitor.cs @@ -72,14 +72,7 @@ public override object VisitGroup(kgbnfParser.GroupContext context) /// /// The parse tree. /// The visitor result, as . - public override object VisitImage(kgbnfParser.ImageContext context) - => new GraphicalImageElement - { - Source = context.attribute() - .Where(attribute => attribute.attribute_name.Text == "src") - .Select(attribute => attribute.attribute_value.Text.Trim('"')) - .SingleOrDefault() - }; + public override object VisitImage(kgbnfParser.ImageContext context) => new GraphicalImageElement(); /// /// Visits a parse tree produced by . diff --git a/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalImageElement.cs b/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalImageElement.cs index 2b5429d7e..fd7436993 100644 --- a/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalImageElement.cs +++ b/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalImageElement.cs @@ -10,13 +10,9 @@ namespace SysML2.NET.CodeGenerator.Grammar.Model { /// - /// Describes a graphical shape or line of a production, given as an embedded image + /// Marks the position of a graphical shape or line that the production gives as an embedded image, whose content is not read /// public class GraphicalImageElement : GraphicalRuleElement { - /// - /// Gets or sets the image path, relative to the grammar file - /// - public string Source { get; set; } } } diff --git a/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalNotationRule.cs b/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalNotationRule.cs index 9d30da486..52f839e90 100644 --- a/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalNotationRule.cs +++ b/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalNotationRule.cs @@ -10,6 +10,7 @@ namespace SysML2.NET.CodeGenerator.Grammar.Model { using System.Collections.Generic; + using System.Linq; /// /// Describes one production definition of the graphical notation @@ -31,5 +32,34 @@ public class GraphicalNotationRule /// Gets the defined by the production /// public List Alternatives { get; } = []; + + /// + /// Queries every element of the production, including those nested in groups + /// + /// The s, each before the elements it contains + public IEnumerable QueryAllElements() => QueryAllElements(this.Alternatives); + + /// + /// Queries every element of the given alternatives, recursively + /// + /// The to walk + /// The s, each before the elements it contains + private static IEnumerable QueryAllElements(IEnumerable alternatives) + { + foreach (var element in alternatives.SelectMany(alternative => alternative.Elements)) + { + yield return element; + + if (element is not GraphicalGroupElement group) + { + continue; + } + + foreach (var nestedElement in QueryAllElements(group.Alternatives)) + { + yield return nestedElement; + } + } + } } } diff --git a/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalNotationSpecification.cs b/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalNotationSpecification.cs index ad26ab6bc..29b3b649f 100644 --- a/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalNotationSpecification.cs +++ b/SysML2.NET.CodeGenerator/Grammar/Model/GraphicalNotationSpecification.cs @@ -9,7 +9,9 @@ namespace SysML2.NET.CodeGenerator.Grammar.Model { + using System; using System.Collections.Generic; + using System.Linq; /// /// Provides access to all defined in the graphical notation specification @@ -20,5 +22,35 @@ public class GraphicalNotationSpecification /// Gets the s in declaration order, one per production definition /// public List Rules { get; } = []; + + /// + /// Queries the references that name no rule: textual names against the textual notation rules, graphical names against + /// + /// + /// The names of the textual notation rules + /// The distinct unresolved references, with the production that holds each + /// If is null + public IReadOnlyList<(string RuleName, string ReferenceName)> QueryUnresolvedReferences(IReadOnlySet textualRuleNames) + { + ArgumentNullException.ThrowIfNull(textualRuleNames); + + var productionNames = this.Rules.Select(rule => rule.RuleName).ToHashSet(); + + return + [ + ..this.Rules + .SelectMany(rule => rule.QueryAllElements().Select(element => (rule.RuleName, ReferenceName: element switch + { + GraphicalNonTerminalElement { IsTextualReference: true } textualReference + when !textualRuleNames.Contains(textualReference.Name) => textualReference.Name, + GraphicalNonTerminalElement { IsTextualReference: false } graphicalReference + when !productionNames.Contains(graphicalReference.Name) => graphicalReference.Name, + GraphicalEdgeEndElement edgeEnd when !productionNames.Contains(edgeEnd.Name) => edgeEnd.Name, + _ => null + }))) + .Where(reference => reference.ReferenceName != null) + .Distinct() + ]; + } } }