Skip to content

Commit 4b3f99c

Browse files
v4.1.4
1 parent e6c6a9a commit 4b3f99c

File tree

112 files changed

+949
-741
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+949
-741
lines changed

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
1616
* - also set the value standalone according to your setup
1717
*/
1818
group = "com.github.tukcps"
19-
version = "4.1.3" // must be number.number.number
19+
version = "4.1.4" // must be number.number.number
2020
val aaddVersion = "0.1.11"
2121
val sysmlapiVersion = "3.9.5"
2222
val useMavenAADD = true
@@ -36,7 +36,7 @@ plugins {
3636
id("com.github.ben-manes.versions") version "0.52.0"
3737
id("idea")
3838
kotlin("jvm") version "2.2.0"
39-
kotlin("plugin.serialization") version "2.2.0"
39+
kotlin("plugin.serialization") version "2.2.10"
4040
id("org.springframework.boot") version "3.5.4"
4141
id("io.spring.dependency-management") version "1.1.7"
4242
alias(libs.plugins.jetbrainsCompose) apply true

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
kotlin = "2.2.0"
2+
kotlin = "2.2.10"
33
compose-plugin = "1.8.2"
44

55
[plugins]

src/main/kotlin/com/github/tukcps/sysmd/compiler/KerML.kt

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ import com.github.tukcps.sysmd.compiler.semantics.ActionsContext
1313
import com.github.tukcps.sysmd.exceptions.Issue
1414
import com.github.tukcps.sysmd.exceptions.SyntaxError
1515
import com.github.tukcps.sysmd.exceptions.SysMDException
16+
import com.github.tukcps.sysmd.model.kerml.UnresolvedElement
17+
import com.github.tukcps.sysmd.model.kerml.UnresolvedFeature
18+
import com.github.tukcps.sysmd.model.kerml.UnresolvedFeatureChain
19+
import com.github.tukcps.sysmd.model.kerml.UnresolvedNamespace
20+
import com.github.tukcps.sysmd.model.kerml.UnresolvedType
1621
import com.github.tukcps.sysmd.model.util.QualifiedName
1722
import com.github.tukcps.sysmd.quantities.Quantity
1823
import com.github.tukcps.sysmd.services.session.Session
@@ -168,8 +173,8 @@ open class KerML(
168173
(token.kind != SEMICOLON || nested > 0)
169174
&& token.kind != EOF
170175
&& (token.kind != RCURBRACE || nested <= 0)) {
171-
if (token.kind == LCURBRACE) nested = nested+1
172-
if (token.kind == RCURBRACE) nested = nested-1
176+
if (token.kind == LCURBRACE) nested += 1
177+
if (token.kind == RCURBRACE) nested -= 1
173178
consume()
174179
}
175180
// If parser skips right curly brace, we need to also pop one from the owner stack.
@@ -189,8 +194,8 @@ open class KerML(
189194
&& token.kind != EOF
190195
&& (token.kind != RCURBRACE || nested <= 0)
191196
) {
192-
if (token.kind == LCURBRACE) nested = nested+1
193-
if (token.kind == RCURBRACE) nested = nested-1
197+
if (token.kind == LCURBRACE) nested += 1
198+
if (token.kind == RCURBRACE) nested -= 1
194199
consume()
195200
}
196201
// If parser skips right curly brace, we need to also pop one from the owner stack.
@@ -213,4 +218,34 @@ open class KerML(
213218
this@KerML.rule()
214219
}
215220
}
221+
222+
fun unresolvedFeature(relativeName: String): UnresolvedFeature =
223+
UnresolvedFeature(relativeName = relativeName).also {
224+
it.input = input
225+
it.indices = indices
226+
}
227+
228+
fun unresolvedFeatureChain(relativeName: String): UnresolvedFeatureChain =
229+
UnresolvedFeatureChain(relativeName = relativeName).also {
230+
it.input = input
231+
it.indices = indices
232+
}
233+
234+
fun unresolvedType(relativeName: String): UnresolvedType =
235+
UnresolvedType(relativeName = relativeName).also {
236+
it.input = input
237+
it.indices = indices
238+
}
239+
240+
fun unresolvedElement(relativeName: String): UnresolvedElement =
241+
UnresolvedElement(relativeName = relativeName).also {
242+
it.input = input
243+
it.indices = indices
244+
}
245+
246+
fun unresolvedNamespace(relativeName: String): UnresolvedNamespace =
247+
UnresolvedNamespace(relativeName = relativeName).also {
248+
it.input = input
249+
it.indices = indices
250+
}
216251
}

src/main/kotlin/com/github/tukcps/sysmd/compiler/parser/kerml/KerMLCore.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ fun KerML.SpecificType() =
244244

245245
fun KerML.GeneralType(): Feature =
246246
when(nextToken.kind) {
247-
DOT -> FeatureChain().let { return UnresolvedFeatureChain(it) }
248-
else -> QualifiedName().let { return UnresolvedFeature(it) }
247+
DOT -> FeatureChain().let { return unresolvedFeatureChain(it) }
248+
else -> QualifiedName().let { return unresolvedFeature(it) }
249249
}
250250

251251
/**
@@ -279,9 +279,9 @@ fun KerML.Conjugation() {
279279
Identification().also { conjugation.create(it) }
280280
} else conjugation.create(null)
281281
CONJUGATE.consume()
282-
QualifiedName().also { conjugation.created.conjugatedType = UnresolvedType(it) }
282+
QualifiedName().also { conjugation.created.conjugatedType = unresolvedType(it) }
283283
CONJUGATES.consume()
284-
QualifiedName().also { conjugation.created.originalType = UnresolvedType(it) }
284+
QualifiedName().also { conjugation.created.originalType = unresolvedType(it) }
285285
RelationshipBody()
286286
}
287287

src/main/kotlin/com/github/tukcps/sysmd/compiler/parser/kerml/KerMLExpression.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fun KerML.BooleanExpression(): AstNode {
3939
/**
4040
* conditionalExpression :- IF expression ? expression ELSE expression
4141
*/
42-
fun KerML.ConditionalExpression(): AstNode? {
42+
fun KerML.ConditionalExpression(): AstNode {
4343
val action = ConditionalExpressionActions(semantics)
4444
IF.consume()
4545
Expression().also { action.condExpr = it }

src/main/kotlin/com/github/tukcps/sysmd/compiler/parser/kerml/KerMLRoot.kt

Lines changed: 59 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import com.github.tukcps.sysmd.compiler.scanner.Token.Kind.*
88
import com.github.tukcps.sysmd.compiler.semantics.Identification
99
import com.github.tukcps.sysmd.compiler.semantics.kerml.*
1010
import com.github.tukcps.sysmd.model.kerml.Dependency
11-
import com.github.tukcps.sysmd.model.kerml.UnresolvedElement
11+
import com.github.tukcps.sysmd.model.kerml.Import
1212
import com.github.tukcps.sysmd.model.kerml.implementation.*
1313

1414
/**
@@ -76,9 +76,9 @@ fun KerML.Dependency() {
7676
FROM.consume()
7777
} else
7878
dependency.create(Identification(null, null))
79-
QualifiedNameList().forEach { dependency.created.source.add(UnresolvedElement(it)) }
79+
QualifiedNameList().forEach { dependency.created.source.add(unresolvedElement(it)) }
8080
TO.consume()
81-
QualifiedNameList().forEach { dependency.created.target.add(UnresolvedElement(it)) }
81+
QualifiedNameList().forEach { dependency.created.target.add(unresolvedElement(it)) }
8282
RelationshipBody()
8383
}
8484

@@ -116,13 +116,13 @@ fun KerML.OwnedRelatedElement() {
116116
*/
117117
fun KerML.MemberPrefix() {
118118
alternatives {
119-
PUBLIC starts { PUBLIC.consume(); semantics.visibilityKind = PUBLIC }
120-
PRIVATE starts { PRIVATE.consume(); semantics.visibilityKind = PRIVATE }
121-
PROTECTED starts { PROTECTED.consume(); semantics.visibilityKind = PROTECTED }
119+
PUBLIC starts { PUBLIC.consume(); semantics.visibility = Import.VisibilityKind.Public }
120+
PRIVATE starts { PRIVATE.consume(); semantics.visibility = Import.VisibilityKind.Private }
121+
PROTECTED starts { PROTECTED.consume(); semantics.visibility = Import.VisibilityKind.Protected }
122122
others { }
123123
}
124124
ABSTRACT.optional { semantics.prefixes.add(ABSTRACT) }
125-
INDIVIDUAL.optional { semantics.prefixes.add(INDIVIDUAL) }
125+
// INDIVIDUAL.optional { semantics.prefixes.add(INDIVIDUAL) }
126126
}
127127

128128
/**
@@ -164,18 +164,17 @@ fun KerML.NamespaceBodyElement() {
164164
* ( 'locale' STRING_VALUE )?
165165
* REGULAR_COMMENT
166166
*/
167-
internal fun KerML.Comment() {
168-
val comment = CommentActions(semantics, ::CommentImplementation)
169-
comment.create()
167+
internal fun KerML.Comment() = CommentActions(semantics, ::CommentImplementation).parse {
168+
create()
170169
COMMENT.optional {
171170
optional(NAME_LIT) {
172-
Identification().also { comment.setIdentification(it) }
171+
Identification().also { setIdentification(it) }
173172
}
174173
ABOUT.optional {
175-
QualifiedNameList().also { comment.addAbout(it) }
174+
QualifiedNameList().also { (this as CommentActions).addAbout(it) }
176175
}
177176
}
178-
REGULAR_COMMENT.consume().also { comment.created.body = consumedToken.string.trimIndent().trim() }
177+
REGULAR_COMMENT.consume().also { created.body = consumedToken.string.trimIndent().trim() }
179178
}
180179

181180
/**
@@ -184,11 +183,10 @@ internal fun KerML.Comment() {
184183
* ( 'locale' STRING_VALUE )?
185184
* REGULAR_COMMENT
186185
*/
187-
internal fun KerML.Documentation() {
188-
val doc = DocumentationActions(semantics)
186+
internal fun KerML.Documentation() = DocumentationActions(semantics).parse {
189187
DOC.consume()
190-
Identification().also { doc.create(it) }
191-
REGULAR_COMMENT.consume().also { doc.created.body = consumedToken.string.trim() }
188+
Identification().also { create(it) }
189+
REGULAR_COMMENT.consume().also { created.body = consumedToken.string.trim() }
192190
}
193191

194192
/**
@@ -197,16 +195,15 @@ internal fun KerML.Documentation() {
197195
* 'language' STRING_VALUE
198196
* REGULAR_COMMENT
199197
*/
200-
internal fun KerML.TextualRepresentation() {
201-
val rep = AnnotatingElementActions(semantics, ::TextualRepresentationImplementation)
202-
rep.create()
198+
internal fun KerML.TextualRepresentation() = AnnotatingElementActions(semantics, ::TextualRepresentationImplementation).parse {
199+
create()
203200
optional(REP) {
204201
REP.consume()
205-
Identification().also { rep.setIdentification(it) }
202+
Identification().also { setIdentification(it) }
206203
}
207204
LANGUAGE.consume()
208-
NAME_LIT.consume().also { rep.created.language = consumedToken.string }
209-
REGULAR_COMMENT.consume().also { rep.created.body = consumedToken.string.trim(' ') }
205+
NAME_LIT.consume().also { created.language = consumedToken.string }
206+
REGULAR_COMMENT.consume().also { created.body = consumedToken.string.trim(' ') }
210207
}
211208

212209
/**
@@ -244,33 +241,52 @@ internal fun KerML.NamespaceBody() {
244241
*
245242
* Import = ( VisibilityIndicator )?
246243
* 'import' 'all'? ImportDeclaration RelationshipBody
247-
*
244+
*/
245+
internal fun KerML.Import() = ImportActions(semantics).parseImport {
246+
IMPORT.consume()
247+
ALL.optional { isImportAll = true }
248+
ImportDeclaration(this)
249+
RelationshipBody()
250+
}
251+
252+
/**
248253
* ImportDeclaration = MembershipImport | NamespaceImport
249-
*
250-
* MembershipImport = [QualifiedName] ( '::' '**'? )?
251-
*
252-
* NamespaceImport = [QualifiedName] '::' '*' ( '::' '**'? )?
254+
*/
255+
internal fun KerML.ImportDeclaration(actions: ImportActions) {
256+
QualifiedName().also { actions.importQualifiedName = it }
257+
alternatives {
258+
DPDP then TIMES starts { NamespaceImport(actions) }
259+
others { MembershipImport(actions) }
260+
}
261+
}
262+
263+
/**
264+
* MembershipImport = [QualifiedName] ('::' '**'?)?
265+
*/
266+
internal fun KerML.MembershipImport(actions: ImportActions) {
267+
DPDP.optional {
268+
STARSTAR.optional().also { actions.isRecursive = true }
269+
}
270+
actions.createMembershipImport()
271+
}
272+
273+
/**
274+
* NamespaceImport = [QualifiedName] '::' '*' ('::' '**'?)?
253275
* | FilterPackage
254276
*
255-
* FilterPackage =
256-
* ImportDeclaration ( FilterPackageMember )+
277+
* FilterPackage = ImportDeclaration ( FilterPackageMember )+
257278
*
258279
* FilterPackageMember = '[' OwnedExpression ']'
259280
*/
260-
internal fun KerML.Import() {
261-
val import = ImportActions(semantics)
262-
IMPORT.consume().also { import.create() }
263-
ALL.optional { import.all = true }
264-
265-
QualifiedName().also { import.setImportedNamespace(it) }
266-
optional(DPDP, consume = true) {
267-
alternatives {
268-
STARSTAR starts { import.isRecursive = true; STARSTAR.consume() }
269-
TIMES starts { TIMES.consume() }
281+
internal fun KerML.NamespaceImport(actions: ImportActions) {
282+
DPDP.consume()
283+
TIMES.optional {
284+
DPDP.optional {
285+
actions.isRecursive = true
286+
STARSTAR.consume()
270287
}
271288
}
272-
RelationshipBody()
273-
import.finish()
289+
actions.createNamespaceImport()
274290
}
275291

276292
/**
@@ -288,7 +304,7 @@ internal fun KerML.AliasMember() {
288304
aliasMember.created.membershipOwningNamespace = semantics.element()
289305
}
290306
FOR.consume()
291-
QualifiedName().also { aliasMember.created.target = mutableListOf(UnresolvedElement(it)) }
307+
QualifiedName().also { aliasMember.created.target = mutableListOf(unresolvedElement(it)) }
292308
RelationshipBody()
293309
}
294310

src/main/kotlin/com/github/tukcps/sysmd/compiler/parser/sysmlv2/Attribute.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import com.github.tukcps.sysmd.model.sysml.implementation.AttributeDefinitionImp
1515
*
1616
* AttributeDefinition = DefinitionPrefix 'attribute' 'def' Definition
1717
*/
18-
fun SysMLv2.AttributeDefinition() = AttributeDefinitionActions<AttributeDefinition>(this.semantics, ::AttributeDefinitionImplementation).parse {
18+
fun SysMLv2.AttributeDefinition() = AttributeDefinitionActions(this.semantics, ::AttributeDefinitionImplementation).parse {
1919
ATTRIBUTE.consume()
2020
DEF.consume()
2121
DefinitionDeclaration()

src/main/kotlin/com/github/tukcps/sysmd/compiler/parser/sysmlv2/Occurrence.kt

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
package com.github.tukcps.sysmd.compiler.parser.sysmlv2
44

55
import com.github.tukcps.sysmd.compiler.SysMLv2
6+
import com.github.tukcps.sysmd.compiler.parser.kerml.FeatureSpecializationPart
7+
import com.github.tukcps.sysmd.compiler.parser.kerml.OwnedReferenceSubsetting
68
import com.github.tukcps.sysmd.compiler.scanner.Token.Kind.*
79
import com.github.tukcps.sysmd.compiler.semantics.kerml.FeatureActions
810
import com.github.tukcps.sysmd.compiler.semantics.sysmlv2.OccurrenceDefinitionActions
@@ -18,16 +20,25 @@ import com.github.tukcps.sysmd.model.kerml.implementation.FeatureImplementation
1820
* 8.2.2.9.1 Occurrence Definitions
1921
*
2022
* OccurrenceDefinitionPrefix = BasicDefinitionPrefix? ( 'individual' )? DefinitionExtensionKeyword*
23+
* OccurrenceDefinition = OccurrenceDefinitionPrefix 'occurrence' 'def' Definition
2124
*
22-
* OccurrenceDefinition = OccurrenceDefinitionPrefix 'occurrence' 'def' Definition
23-
*
24-
* IndividualDefinition = BasicDefinitionPrefix? 'individual' DefinitionExtensionKeyword* 'def' Definition
2525
*/
2626
fun SysMLv2.OccurrenceDefinition() = OccurrenceDefinitionActions(semantics).parse {
27+
INDIVIDUAL.optional()
28+
// DefinitionExtensionKeyword
2729
OCCURRENCE.consume()
2830
DEF.consume()
29-
DefinitionDeclaration()
30-
DefinitionBody()
31+
Definition()
32+
}
33+
34+
/**
35+
* IndividualDefinition = BasicDefinitionPrefix? 'individual' DefinitionExtensionKeyword* 'def' Definition
36+
*/
37+
fun SysMLv2.IndividualDefinition() = OccurrenceDefinitionActions(semantics).parse {
38+
INDIVIDUAL.consume()
39+
// DefinitionExtensionKeyword
40+
DEF.consume()
41+
Definition()
3142
}
3243

3344

@@ -64,9 +75,10 @@ fun SysMLv2.OccurrenceUsage() = OccurrenceUsageActions(semantics).parse {
6475
*/
6576
fun SysMLv2.PortionUsage() = FeatureActions<Feature>(semantics, defaultType = "Occurrences::Occurrence", creator = ::FeatureImplementation).parse {
6677
INDIVIDUAL.optional()
67-
alternatives { // PortionKind
68-
SNAPSHOT starts { consume(); }
69-
TIMESLICE starts { consume(); }
78+
when(token.kind) { // PortionKind
79+
SNAPSHOT -> { consume(); }
80+
TIMESLICE -> { consume(); }
81+
else -> { handleSyntaxError("Expected a portion kind (snapshot, timeslice)")}
7082
}
7183
UsageExtensionKeyword()
7284
Usage()
@@ -81,13 +93,16 @@ fun SysMLv2.PortionUsage() = FeatureActions<Feature>(semantics, defaultType = "O
8193
*/
8294
fun SysMLv2.EventOccurrenceUsage() = FeatureActions<Feature>(semantics, ::FeatureImplementation, "Occurrences::Occurrence").parse {
8395
EVENT.consume()
84-
alternatives {
85-
OCCURRENCE starts {
96+
when(token.kind) {
97+
OCCURRENCE -> {
8698
OCCURRENCE.consume().also { semantics.prefixes.add(OUT) }
8799
UsageDeclaration()
88100
}
89-
// OwnedReferenceSubsetting()
90-
// FeatureSpecializationPart(eventOccurrenceUsage)
101+
NAME_LIT -> {
102+
OwnedReferenceSubsetting()
103+
FeatureSpecializationPart()
104+
}
105+
else -> { handleSyntaxError("Expected occurrence, reference subsetting, or feature specification")}
91106
}
92107
UsageCompletion()
93108
}

0 commit comments

Comments
 (0)