@oml/language 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -0
- package/out/oml/generated/ast.d.ts +2109 -0
- package/out/oml/generated/ast.js +1807 -0
- package/out/oml/generated/ast.js.map +1 -0
- package/out/oml/generated/grammar.d.ts +6 -0
- package/out/oml/generated/grammar.js +6885 -0
- package/out/oml/generated/grammar.js.map +1 -0
- package/out/oml/generated/module.d.ts +13 -0
- package/out/oml/generated/module.js +21 -0
- package/out/oml/generated/module.js.map +1 -0
- package/out/oml/index.d.ts +17 -0
- package/out/oml/index.js +19 -0
- package/out/oml/index.js.map +1 -0
- package/out/oml/oml-candidates.d.ts +27 -0
- package/out/oml/oml-candidates.js +146 -0
- package/out/oml/oml-candidates.js.map +1 -0
- package/out/oml/oml-code-actions.d.ts +6 -0
- package/out/oml/oml-code-actions.js +79 -0
- package/out/oml/oml-code-actions.js.map +1 -0
- package/out/oml/oml-completion.d.ts +50 -0
- package/out/oml/oml-completion.js +188 -0
- package/out/oml/oml-completion.js.map +1 -0
- package/out/oml/oml-converter.d.ts +10 -0
- package/out/oml/oml-converter.js +62 -0
- package/out/oml/oml-converter.js.map +1 -0
- package/out/oml/oml-document-validator.d.ts +10 -0
- package/out/oml/oml-document-validator.js +31 -0
- package/out/oml/oml-document-validator.js.map +1 -0
- package/out/oml/oml-document.d.ts +9 -0
- package/out/oml/oml-document.js +18 -0
- package/out/oml/oml-document.js.map +1 -0
- package/out/oml/oml-edit.d.ts +72 -0
- package/out/oml/oml-edit.js +1155 -0
- package/out/oml/oml-edit.js.map +1 -0
- package/out/oml/oml-formatter.d.ts +22 -0
- package/out/oml/oml-formatter.js +357 -0
- package/out/oml/oml-formatter.js.map +1 -0
- package/out/oml/oml-hover.d.ts +13 -0
- package/out/oml/oml-hover.js +71 -0
- package/out/oml/oml-hover.js.map +1 -0
- package/out/oml/oml-index-manager.d.ts +10 -0
- package/out/oml/oml-index-manager.js +48 -0
- package/out/oml/oml-index-manager.js.map +1 -0
- package/out/oml/oml-index.d.ts +20 -0
- package/out/oml/oml-index.js +133 -0
- package/out/oml/oml-index.js.map +1 -0
- package/out/oml/oml-module.d.ts +42 -0
- package/out/oml/oml-module.js +76 -0
- package/out/oml/oml-module.js.map +1 -0
- package/out/oml/oml-rename.d.ts +14 -0
- package/out/oml/oml-rename.js +114 -0
- package/out/oml/oml-rename.js.map +1 -0
- package/out/oml/oml-scope.d.ts +30 -0
- package/out/oml/oml-scope.js +225 -0
- package/out/oml/oml-scope.js.map +1 -0
- package/out/oml/oml-serializer.d.ts +2 -0
- package/out/oml/oml-serializer.js +883 -0
- package/out/oml/oml-serializer.js.map +1 -0
- package/out/oml/oml-utils.d.ts +53 -0
- package/out/oml/oml-utils.js +241 -0
- package/out/oml/oml-utils.js.map +1 -0
- package/out/oml/oml-validator.d.ts +49 -0
- package/out/oml/oml-validator.js +668 -0
- package/out/oml/oml-validator.js.map +1 -0
- package/out/oml/oml-workspace.d.ts +23 -0
- package/out/oml/oml-workspace.js +68 -0
- package/out/oml/oml-workspace.js.map +1 -0
- package/package.json +50 -0
- package/src/oml/generated/ast.ts +2641 -0
- package/src/oml/generated/grammar.ts +6887 -0
- package/src/oml/generated/module.ts +25 -0
- package/src/oml/index.ts +19 -0
- package/src/oml/oml-candidates.ts +176 -0
- package/src/oml/oml-code-actions.ts +120 -0
- package/src/oml/oml-completion.ts +222 -0
- package/src/oml/oml-converter.ts +66 -0
- package/src/oml/oml-document-validator.ts +39 -0
- package/src/oml/oml-document.ts +24 -0
- package/src/oml/oml-edit.ts +1292 -0
- package/src/oml/oml-formatter.ts +390 -0
- package/src/oml/oml-hover.ts +93 -0
- package/src/oml/oml-index-manager.ts +56 -0
- package/src/oml/oml-index.ts +145 -0
- package/src/oml/oml-module.ts +105 -0
- package/src/oml/oml-rename.ts +140 -0
- package/src/oml/oml-scope.ts +279 -0
- package/src/oml/oml-serializer.ts +1080 -0
- package/src/oml/oml-utils.ts +294 -0
- package/src/oml/oml-validator.ts +725 -0
- package/src/oml/oml-workspace.ts +81 -0
- package/src/oml/oml.langium +594 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// Copyright (c) 2026 Modelware. All rights reserved.
|
|
2
|
+
|
|
3
|
+
import { URI, type LangiumSharedCoreServices } from 'langium';
|
|
4
|
+
import { DefaultWorkspaceManager } from 'langium';
|
|
5
|
+
import type { Connection } from 'vscode-languageserver';
|
|
6
|
+
|
|
7
|
+
// LSP request name — must match the handler registered in node-client.ts
|
|
8
|
+
const GET_WORKSPACE_FOLDERS_REQUEST = 'oml/fs/getWorkspaceFolders';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Custom workspace manager that:
|
|
12
|
+
* 1. Resolves the actual workspace folder URIs from the VS Code client (fixing Live Share's
|
|
13
|
+
* vsls:/ root, which maps to host's / instead of the shared workspace folder).
|
|
14
|
+
* 2. Filters out OS system directories during traversal to avoid permission errors.
|
|
15
|
+
*/
|
|
16
|
+
export class OmlWorkspaceManager extends DefaultWorkspaceManager {
|
|
17
|
+
private readonly connection: Connection | undefined;
|
|
18
|
+
|
|
19
|
+
constructor(services: LangiumSharedCoreServices) {
|
|
20
|
+
super(services);
|
|
21
|
+
this.connection = (services as { lsp?: { Connection?: Connection } }).lsp?.Connection;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Override to replace LSP-reported workspace folders with the ones from the VS Code client.
|
|
26
|
+
* This corrects the Live Share bug where the LSP initialize params contain `vsls:/` (scheme-only)
|
|
27
|
+
* but vscode.workspace.workspaceFolders on the client has the real path (e.g., vsls://server/path).
|
|
28
|
+
*/
|
|
29
|
+
override async initializeWorkspace(folders: any[], cancelToken?: any): Promise<void> {
|
|
30
|
+
let resolvedFolders = folders;
|
|
31
|
+
|
|
32
|
+
if (this.connection) {
|
|
33
|
+
try {
|
|
34
|
+
const uris = await this.connection.sendRequest<string[]>(GET_WORKSPACE_FOLDERS_REQUEST, {});
|
|
35
|
+
if (uris && uris.length > 0) {
|
|
36
|
+
resolvedFolders = uris.map((uri, i) => ({
|
|
37
|
+
uri,
|
|
38
|
+
name: folders[i]?.name ?? uri.split('/').filter(Boolean).pop() ?? 'workspace'
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
} catch {
|
|
42
|
+
// Client doesn't support this request (e.g. CLI mode) — use folders as-is
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
(this as unknown as { folders?: any[] }).folders = resolvedFolders;
|
|
47
|
+
await super.initializeWorkspace(resolvedFolders, cancelToken);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function canonicalizeWorkspaceDocumentUri(
|
|
52
|
+
workspaceManager: { workspaceFolders?: ReadonlyArray<{ uri: string }> } | undefined,
|
|
53
|
+
uri: URI
|
|
54
|
+
): URI {
|
|
55
|
+
for (const folder of workspaceManager?.workspaceFolders ?? []) {
|
|
56
|
+
const workspaceUri = URI.parse(folder.uri);
|
|
57
|
+
if (!isUriPathWithinWorkspace(uri, workspaceUri)) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (uri.scheme === workspaceUri.scheme && (uri.authority ?? '') === (workspaceUri.authority ?? '')) {
|
|
61
|
+
return uri.with({ query: '', fragment: '' });
|
|
62
|
+
}
|
|
63
|
+
return workspaceUri.with({
|
|
64
|
+
path: uri.path,
|
|
65
|
+
query: '',
|
|
66
|
+
fragment: '',
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return uri;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function isUriPathWithinWorkspace(candidate: URI, workspace: URI): boolean {
|
|
73
|
+
const candidatePath = normalizeUriPath(candidate.path);
|
|
74
|
+
const workspacePath = normalizeUriPath(workspace.path);
|
|
75
|
+
return candidatePath === workspacePath || candidatePath.startsWith(`${workspacePath}/`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function normalizeUriPath(path: string): string {
|
|
79
|
+
const normalized = path.replace(/\/+$/, '');
|
|
80
|
+
return normalized || '/';
|
|
81
|
+
}
|
|
@@ -0,0 +1,594 @@
|
|
|
1
|
+
// Copyright (c) 2026 Modelware. All rights reserved.
|
|
2
|
+
|
|
3
|
+
grammar Oml
|
|
4
|
+
|
|
5
|
+
////////////////////////////////////////
|
|
6
|
+
// Root
|
|
7
|
+
////////////////////////////////////////
|
|
8
|
+
|
|
9
|
+
Element:
|
|
10
|
+
Import |
|
|
11
|
+
IdentifiedElement |
|
|
12
|
+
Axiom |
|
|
13
|
+
Predicate |
|
|
14
|
+
Argument |
|
|
15
|
+
Instance |
|
|
16
|
+
Assertion |
|
|
17
|
+
Annotation |
|
|
18
|
+
Literal;
|
|
19
|
+
|
|
20
|
+
////////////////////////////////////////
|
|
21
|
+
// Elements
|
|
22
|
+
////////////////////////////////////////
|
|
23
|
+
|
|
24
|
+
Import:
|
|
25
|
+
kind=ImportKind imported=[Ontology:NAMESPACE] ('as' prefix=ID)?;
|
|
26
|
+
|
|
27
|
+
IdentifiedElement:
|
|
28
|
+
Ontology |
|
|
29
|
+
Member;
|
|
30
|
+
|
|
31
|
+
Axiom:
|
|
32
|
+
EntityEquivalenceAxiom |
|
|
33
|
+
InstanceEnumerationAxiom |
|
|
34
|
+
KeyAxiom |
|
|
35
|
+
LiteralEnumerationAxiom |
|
|
36
|
+
PropertyEquivalenceAxiom |
|
|
37
|
+
PropertyRestrictionAxiom |
|
|
38
|
+
ScalarEquivalenceAxiom |
|
|
39
|
+
SpecializationAxiom;
|
|
40
|
+
|
|
41
|
+
Predicate:
|
|
42
|
+
UnaryPredicate |
|
|
43
|
+
BinaryPredicate |
|
|
44
|
+
BuiltInPredicate;
|
|
45
|
+
|
|
46
|
+
Argument:
|
|
47
|
+
variable=ID | literal=Literal | instance=[NamedInstance:CrossRef];
|
|
48
|
+
|
|
49
|
+
Instance:
|
|
50
|
+
NamedInstance |
|
|
51
|
+
AnonymousInstance;
|
|
52
|
+
|
|
53
|
+
Assertion:
|
|
54
|
+
PropertyValueAssertion |
|
|
55
|
+
TypeAssertion;
|
|
56
|
+
|
|
57
|
+
Annotation:
|
|
58
|
+
'@' property=[AnnotationProperty:Ref] (AnnotationValue ("," AnnotationValue)*)?;
|
|
59
|
+
|
|
60
|
+
fragment AnnotationValue:
|
|
61
|
+
literalValues+=Literal | referencedValues+=[Member:Ref];
|
|
62
|
+
|
|
63
|
+
Literal:
|
|
64
|
+
IntegerLiteral |
|
|
65
|
+
DecimalLiteral |
|
|
66
|
+
DoubleLiteral |
|
|
67
|
+
BooleanLiteral |
|
|
68
|
+
QuotedLiteral;
|
|
69
|
+
|
|
70
|
+
////////////////////////////////////////
|
|
71
|
+
// Identified Elements
|
|
72
|
+
////////////////////////////////////////
|
|
73
|
+
|
|
74
|
+
entry Ontology:
|
|
75
|
+
VocabularyBox |
|
|
76
|
+
DescriptionBox;
|
|
77
|
+
|
|
78
|
+
Member:
|
|
79
|
+
Statement |
|
|
80
|
+
VocabularyMember |
|
|
81
|
+
DescriptionMember;
|
|
82
|
+
|
|
83
|
+
////////////////////////////////////////
|
|
84
|
+
// Ontologies
|
|
85
|
+
////////////////////////////////////////
|
|
86
|
+
|
|
87
|
+
VocabularyBox:
|
|
88
|
+
Vocabulary |
|
|
89
|
+
VocabularyBundle;
|
|
90
|
+
|
|
91
|
+
DescriptionBox:
|
|
92
|
+
Description |
|
|
93
|
+
DescriptionBundle;
|
|
94
|
+
|
|
95
|
+
////////////////////////////////////////
|
|
96
|
+
// Vocabulary Boxes
|
|
97
|
+
////////////////////////////////////////
|
|
98
|
+
|
|
99
|
+
Vocabulary:
|
|
100
|
+
ownedAnnotations+=Annotation*
|
|
101
|
+
'vocabulary' namespace=NAMESPACE 'as' prefix=ID '{'
|
|
102
|
+
ownedImports+=Import*
|
|
103
|
+
ownedStatements+=VocabularyStatement*
|
|
104
|
+
'}';
|
|
105
|
+
|
|
106
|
+
VocabularyBundle:
|
|
107
|
+
ownedAnnotations+=Annotation*
|
|
108
|
+
'vocabulary' 'bundle' namespace=NAMESPACE 'as' prefix=ID '{'
|
|
109
|
+
ownedImports+=Import*
|
|
110
|
+
'}';
|
|
111
|
+
|
|
112
|
+
////////////////////////////////////////
|
|
113
|
+
// Description Boxes
|
|
114
|
+
////////////////////////////////////////
|
|
115
|
+
|
|
116
|
+
Description:
|
|
117
|
+
ownedAnnotations+=Annotation*
|
|
118
|
+
'description' namespace=NAMESPACE 'as' prefix=ID '{'
|
|
119
|
+
ownedImports+=Import*
|
|
120
|
+
ownedStatements+=DescriptionStatement*
|
|
121
|
+
'}';
|
|
122
|
+
|
|
123
|
+
DescriptionBundle:
|
|
124
|
+
ownedAnnotations+=Annotation*
|
|
125
|
+
'description' 'bundle' namespace=NAMESPACE 'as' prefix=ID '{'
|
|
126
|
+
ownedImports+=Import*
|
|
127
|
+
'}';
|
|
128
|
+
|
|
129
|
+
////////////////////////////////////////
|
|
130
|
+
// Members
|
|
131
|
+
////////////////////////////////////////
|
|
132
|
+
|
|
133
|
+
Statement:
|
|
134
|
+
VocabularyStatement |
|
|
135
|
+
DescriptionStatement;
|
|
136
|
+
|
|
137
|
+
VocabularyMember:
|
|
138
|
+
Term |
|
|
139
|
+
VocabularyStatement;
|
|
140
|
+
|
|
141
|
+
DescriptionMember:
|
|
142
|
+
DescriptionStatement;
|
|
143
|
+
|
|
144
|
+
////////////////////////////////////////
|
|
145
|
+
// Statements
|
|
146
|
+
////////////////////////////////////////
|
|
147
|
+
|
|
148
|
+
VocabularyStatement:
|
|
149
|
+
Rule |
|
|
150
|
+
BuiltIn |
|
|
151
|
+
SpecializableTerm;
|
|
152
|
+
|
|
153
|
+
DescriptionStatement:
|
|
154
|
+
NamedInstance;
|
|
155
|
+
|
|
156
|
+
////////////////////////////////////////
|
|
157
|
+
// Vocabulary Members and Statements
|
|
158
|
+
////////////////////////////////////////
|
|
159
|
+
|
|
160
|
+
Term:
|
|
161
|
+
SpecializableTerm |
|
|
162
|
+
RelationBase |
|
|
163
|
+
Property;
|
|
164
|
+
|
|
165
|
+
Rule:
|
|
166
|
+
ownedAnnotations+=Annotation*
|
|
167
|
+
('rule' name=ID | 'ref' 'rule' ref=[Rule:Ref]) ('['
|
|
168
|
+
(antecedent+=Predicate ('&' antecedent+=Predicate)* '->' consequent+=Predicate ('&' consequent+=Predicate)*)?
|
|
169
|
+
']')?;
|
|
170
|
+
|
|
171
|
+
BuiltIn:
|
|
172
|
+
ownedAnnotations+=Annotation*
|
|
173
|
+
('builtin' name=ID | 'ref' 'builtin' ref=[BuiltIn:Ref]);
|
|
174
|
+
|
|
175
|
+
////////////////////////////////////////
|
|
176
|
+
// Terms
|
|
177
|
+
////////////////////////////////////////
|
|
178
|
+
|
|
179
|
+
SpecializableTerm:
|
|
180
|
+
Type |
|
|
181
|
+
SpecializableProperty;
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
Property:
|
|
185
|
+
SpecializableProperty |
|
|
186
|
+
SemanticProperty;
|
|
187
|
+
|
|
188
|
+
////////////////////////////////////////
|
|
189
|
+
// Specializable Terms
|
|
190
|
+
////////////////////////////////////////
|
|
191
|
+
|
|
192
|
+
Type:
|
|
193
|
+
Scalar |
|
|
194
|
+
Entity;
|
|
195
|
+
|
|
196
|
+
RelationBase:
|
|
197
|
+
RelationEntity |
|
|
198
|
+
UnreifiedRelation;
|
|
199
|
+
|
|
200
|
+
SpecializableProperty:
|
|
201
|
+
AnnotationProperty |
|
|
202
|
+
ScalarProperty |
|
|
203
|
+
UnreifiedRelation;
|
|
204
|
+
|
|
205
|
+
////////////////////////////////////////
|
|
206
|
+
// Types
|
|
207
|
+
////////////////////////////////////////
|
|
208
|
+
|
|
209
|
+
Scalar:
|
|
210
|
+
ownedAnnotations+=Annotation*
|
|
211
|
+
('scalar' name=ID | 'ref' 'scalar' ref=[Scalar:Ref]) ('['
|
|
212
|
+
ownedEnumeration=LiteralEnumerationAxiom
|
|
213
|
+
']')? (ScalarSpecialization)? (ScalarEquivalence)?;
|
|
214
|
+
|
|
215
|
+
fragment ScalarSpecialization:
|
|
216
|
+
'<' ownedSpecializations+=SpecializationAxiom (',' ownedSpecializations+=SpecializationAxiom)*;
|
|
217
|
+
|
|
218
|
+
fragment ScalarEquivalence:
|
|
219
|
+
'=' ownedEquivalences+=ScalarEquivalenceAxiom (',' ownedEquivalences+=ScalarEquivalenceAxiom)*;
|
|
220
|
+
|
|
221
|
+
Entity:
|
|
222
|
+
Aspect |
|
|
223
|
+
Concept |
|
|
224
|
+
RelationEntity;
|
|
225
|
+
|
|
226
|
+
////////////////////////////////////////
|
|
227
|
+
// Entities
|
|
228
|
+
////////////////////////////////////////
|
|
229
|
+
|
|
230
|
+
Aspect:
|
|
231
|
+
ownedAnnotations+=Annotation*
|
|
232
|
+
('aspect' name=ID | 'ref' 'aspect' ref=[Aspect:Ref]) ('['
|
|
233
|
+
(ownedKeys+=KeyAxiom)*
|
|
234
|
+
']')? (EntitySpecialization)? (EntityEquivalence)?;
|
|
235
|
+
|
|
236
|
+
Concept:
|
|
237
|
+
ownedAnnotations+=Annotation*
|
|
238
|
+
('concept' name=ID | 'ref' 'concept' ref=[Concept:Ref]) ('['
|
|
239
|
+
(ownedEnumeration=InstanceEnumerationAxiom)?
|
|
240
|
+
(ownedKeys+=KeyAxiom)*
|
|
241
|
+
']')? (EntitySpecialization)? (EntityEquivalence)?;
|
|
242
|
+
|
|
243
|
+
RelationEntity:
|
|
244
|
+
ownedAnnotations+=Annotation*
|
|
245
|
+
('relation' 'entity' name=ID | 'ref' 'relation' 'entity' ref=[RelationEntity:Ref]) ('['
|
|
246
|
+
('from' sources+=[Entity:Ref] (',' sources+=[Entity:Ref])*)?
|
|
247
|
+
('to' targets+=[Entity:Ref] (',' targets+=[Entity:Ref])*)?
|
|
248
|
+
(forwardRelation=ForwardRelation)?
|
|
249
|
+
(reverseRelation=ReverseRelation)?
|
|
250
|
+
((functional?='functional') &
|
|
251
|
+
(inverseFunctional?='inverse' 'functional') &
|
|
252
|
+
(symmetric?='symmetric') &
|
|
253
|
+
(asymmetric?='asymmetric') &
|
|
254
|
+
(reflexive?='reflexive') &
|
|
255
|
+
(irreflexive?='irreflexive') &
|
|
256
|
+
(transitive?='transitive'))
|
|
257
|
+
(ownedKeys+=KeyAxiom)*
|
|
258
|
+
']')? (EntitySpecialization)? (EntityEquivalence)?;
|
|
259
|
+
|
|
260
|
+
fragment EntitySpecialization:
|
|
261
|
+
'<'
|
|
262
|
+
(
|
|
263
|
+
// At least one specialization, optional restriction block
|
|
264
|
+
ownedSpecializations+=SpecializationAxiom (',' ownedSpecializations+=SpecializationAxiom)* ('['
|
|
265
|
+
ownedPropertyRestrictions+=PropertyRestrictionAxiom*
|
|
266
|
+
']')?
|
|
267
|
+
|
|
|
268
|
+
// Or restriction block without specializations
|
|
269
|
+
'[' ownedPropertyRestrictions+=PropertyRestrictionAxiom* ']'
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
fragment EntityEquivalence:
|
|
273
|
+
'=' ownedEquivalences+=EntityEquivalenceAxiom (',' ownedEquivalences+=EntityEquivalenceAxiom)*;
|
|
274
|
+
|
|
275
|
+
////////////////////////////////////////
|
|
276
|
+
// Properties
|
|
277
|
+
////////////////////////////////////////
|
|
278
|
+
|
|
279
|
+
AnnotationProperty:
|
|
280
|
+
ownedAnnotations+=Annotation*
|
|
281
|
+
(('annotation' 'property' name=ID) | ('ref' 'annotation' 'property' ref=[AnnotationProperty:Ref]))
|
|
282
|
+
(PropertySpecialization)? (PropertyEquivalence)?;
|
|
283
|
+
|
|
284
|
+
SemanticProperty:
|
|
285
|
+
ScalarProperty |
|
|
286
|
+
Relation;
|
|
287
|
+
|
|
288
|
+
fragment PropertySpecialization:
|
|
289
|
+
'<' ownedSpecializations+=SpecializationAxiom (',' ownedSpecializations+=SpecializationAxiom)*;
|
|
290
|
+
|
|
291
|
+
fragment PropertyEquivalence:
|
|
292
|
+
'=' ownedEquivalences+=PropertyEquivalenceAxiom (',' ownedEquivalences+=PropertyEquivalenceAxiom)*;
|
|
293
|
+
|
|
294
|
+
////////////////////////////////////////
|
|
295
|
+
// Semantic Properties
|
|
296
|
+
////////////////////////////////////////
|
|
297
|
+
|
|
298
|
+
ScalarProperty:
|
|
299
|
+
ownedAnnotations+=Annotation*
|
|
300
|
+
('scalar' 'property' name=ID | 'ref' 'scalar' 'property' ref=[ScalarProperty:Ref]) ('['
|
|
301
|
+
('domain' domains+=[Entity:Ref] (',' domains+=[Entity:Ref])*)?
|
|
302
|
+
('range' ranges+=[Scalar:Ref] (',' ranges+=[Scalar:Ref])*)?
|
|
303
|
+
(functional?='functional')?
|
|
304
|
+
']')? (PropertySpecialization)? (PropertyEquivalence)?;
|
|
305
|
+
|
|
306
|
+
Relation:
|
|
307
|
+
ForwardRelation |
|
|
308
|
+
ReverseRelation |
|
|
309
|
+
UnreifiedRelation;
|
|
310
|
+
|
|
311
|
+
////////////////////////////////////////
|
|
312
|
+
// Relations
|
|
313
|
+
////////////////////////////////////////
|
|
314
|
+
|
|
315
|
+
ForwardRelation:
|
|
316
|
+
ownedAnnotations+=Annotation*
|
|
317
|
+
'forward' name=ID;
|
|
318
|
+
|
|
319
|
+
ReverseRelation:
|
|
320
|
+
ownedAnnotations+=Annotation*
|
|
321
|
+
'reverse' name=ID;
|
|
322
|
+
|
|
323
|
+
UnreifiedRelation:
|
|
324
|
+
ownedAnnotations+=Annotation*
|
|
325
|
+
('relation' name=ID | 'ref' 'relation' ref=[Relation:Ref]) ('['
|
|
326
|
+
('from' sources+=[Entity:Ref] (',' sources+=[Entity:Ref])*)?
|
|
327
|
+
('to' targets+=[Entity:Ref] (',' targets+=[Entity:Ref])*)?
|
|
328
|
+
(reverseRelation=ReverseRelation)?
|
|
329
|
+
((functional?='functional') &
|
|
330
|
+
(inverseFunctional?='inverse' 'functional') &
|
|
331
|
+
(symmetric?='symmetric') &
|
|
332
|
+
(asymmetric?='asymmetric') &
|
|
333
|
+
(reflexive?='reflexive') &
|
|
334
|
+
(irreflexive?='irreflexive') &
|
|
335
|
+
(transitive?='transitive'))
|
|
336
|
+
']')? (PropertySpecialization)? (PropertyEquivalence)?;
|
|
337
|
+
|
|
338
|
+
////////////////////////////////////////
|
|
339
|
+
// Description Members and Instances
|
|
340
|
+
////////////////////////////////////////
|
|
341
|
+
|
|
342
|
+
NamedInstance:
|
|
343
|
+
ConceptInstance |
|
|
344
|
+
RelationInstance;
|
|
345
|
+
|
|
346
|
+
AnonymousInstance:
|
|
347
|
+
AnonymousConceptInstance |
|
|
348
|
+
AnonymousRelationInstance;
|
|
349
|
+
|
|
350
|
+
////////////////////////////////////////
|
|
351
|
+
// Named Instances
|
|
352
|
+
////////////////////////////////////////
|
|
353
|
+
|
|
354
|
+
ConceptInstance:
|
|
355
|
+
ownedAnnotations+=Annotation*
|
|
356
|
+
('instance' name=ID | 'ref' 'instance' ref=[ConceptInstance:Ref]) (':' ownedTypes+=TypeAssertion (',' ownedTypes+=TypeAssertion)*)? ('['
|
|
357
|
+
ownedPropertyValues+=PropertyValueAssertion*
|
|
358
|
+
']')?;
|
|
359
|
+
|
|
360
|
+
RelationInstance:
|
|
361
|
+
ownedAnnotations+=Annotation*
|
|
362
|
+
('relation' 'instance' name=ID | 'ref' 'relation' 'instance' ref=[RelationInstance:Ref]) (':' ownedTypes+=TypeAssertion (',' ownedTypes+=TypeAssertion)*)? ('['
|
|
363
|
+
('from' sources+=[NamedInstance:Ref] (',' sources+=[NamedInstance:Ref])*)?
|
|
364
|
+
('to' targets+=[NamedInstance:Ref] (',' targets+=[NamedInstance:Ref])*)?
|
|
365
|
+
ownedPropertyValues+=PropertyValueAssertion*
|
|
366
|
+
']')?;
|
|
367
|
+
|
|
368
|
+
////////////////////////////////////////
|
|
369
|
+
// Anonymous Instances
|
|
370
|
+
////////////////////////////////////////
|
|
371
|
+
|
|
372
|
+
AnonymousConceptInstance:
|
|
373
|
+
{infer AnonymousConceptInstance} (':' type=[Concept:Ref])? '['
|
|
374
|
+
ownedPropertyValues+=PropertyValueAssertion*
|
|
375
|
+
']';
|
|
376
|
+
|
|
377
|
+
AnonymousRelationInstance:
|
|
378
|
+
target=[NamedInstance:Ref] '['
|
|
379
|
+
ownedPropertyValues+=PropertyValueAssertion*
|
|
380
|
+
']';
|
|
381
|
+
|
|
382
|
+
////////////////////////////////////////
|
|
383
|
+
// Axioms
|
|
384
|
+
////////////////////////////////////////
|
|
385
|
+
|
|
386
|
+
KeyAxiom:
|
|
387
|
+
'key' properties+=[Property:Ref] (',' properties+=[Property:Ref])*;
|
|
388
|
+
|
|
389
|
+
SpecializationAxiom:
|
|
390
|
+
superTerm=[Term:Ref];
|
|
391
|
+
|
|
392
|
+
EquivalenceAxiom:
|
|
393
|
+
EntityEquivalenceAxiom |
|
|
394
|
+
ScalarEquivalenceAxiom |
|
|
395
|
+
PropertyEquivalenceAxiom;
|
|
396
|
+
|
|
397
|
+
EntityEquivalenceAxiom:
|
|
398
|
+
(superTerms+=[Entity:Ref] ('&' superTerms+=[Entity:Ref])*) |
|
|
399
|
+
((superTerms+=[Entity:Ref] ('&' superTerms+=[Entity:Ref])*)? '['
|
|
400
|
+
ownedPropertyRestrictions+=PropertyRestrictionAxiom*
|
|
401
|
+
']');
|
|
402
|
+
|
|
403
|
+
ScalarEquivalenceAxiom:
|
|
404
|
+
superTerms+=[Scalar:Ref] ('['
|
|
405
|
+
(('length' length+=UnsignedInteger) |
|
|
406
|
+
('minLength' minLength+=UnsignedInteger) |
|
|
407
|
+
('maxLength' maxLength+=UnsignedInteger) |
|
|
408
|
+
('pattern' pattern+=STRING) |
|
|
409
|
+
('language' language+=ID) |
|
|
410
|
+
('minInclusive' minInclusive+=Literal) |
|
|
411
|
+
('minExclusive' minExclusive+=Literal) |
|
|
412
|
+
('maxInclusive' maxInclusive+=Literal) |
|
|
413
|
+
('maxExclusive' maxExclusive+=Literal))*
|
|
414
|
+
']')?;
|
|
415
|
+
|
|
416
|
+
PropertyEquivalenceAxiom:
|
|
417
|
+
superTerms+=[Property:Ref];
|
|
418
|
+
|
|
419
|
+
InstanceEnumerationAxiom:
|
|
420
|
+
'oneOf' instances+=[ConceptInstance:Ref] (',' instances+=[ConceptInstance:Ref])*;
|
|
421
|
+
|
|
422
|
+
LiteralEnumerationAxiom:
|
|
423
|
+
'oneOf' literals+=Literal (',' literals+=Literal)*;
|
|
424
|
+
|
|
425
|
+
PropertyRestrictionAxiom:
|
|
426
|
+
PropertySelfRestrictionAxiom |
|
|
427
|
+
PropertyRangeRestrictionAxiom |
|
|
428
|
+
PropertyCardinalityRestrictionAxiom |
|
|
429
|
+
PropertyValueRestrictionAxiom;
|
|
430
|
+
|
|
431
|
+
////////////////////////////////////////
|
|
432
|
+
// Property Restriction Axioms
|
|
433
|
+
////////////////////////////////////////
|
|
434
|
+
|
|
435
|
+
PropertyRangeRestrictionAxiom:
|
|
436
|
+
'restricts' kind=RangeRestrictionKind property=[SemanticProperty:Ref] 'to' range=[Type:Ref];
|
|
437
|
+
|
|
438
|
+
PropertyCardinalityRestrictionAxiom:
|
|
439
|
+
'restricts' property=[SemanticProperty:Ref] 'to' kind=CardinalityRestrictionKind cardinality=UnsignedInteger (range=[Type:Ref])?;
|
|
440
|
+
|
|
441
|
+
PropertyValueRestrictionAxiom:
|
|
442
|
+
'restricts' property=[SemanticProperty:Ref] 'to' (literalValue=Literal | containedValue=AnonymousInstance | referencedValue=[NamedInstance:Ref]);
|
|
443
|
+
|
|
444
|
+
PropertySelfRestrictionAxiom:
|
|
445
|
+
'restricts' property=[SemanticProperty:Ref] 'to' 'self';
|
|
446
|
+
|
|
447
|
+
////////////////////////////////////////
|
|
448
|
+
// Assertions
|
|
449
|
+
////////////////////////////////////////
|
|
450
|
+
|
|
451
|
+
TypeAssertion:
|
|
452
|
+
type=[Entity:Ref];
|
|
453
|
+
|
|
454
|
+
PropertyValueAssertion:
|
|
455
|
+
property=[SemanticProperty:Ref] PropertyValue ("," PropertyValue)*;
|
|
456
|
+
|
|
457
|
+
fragment PropertyValue:
|
|
458
|
+
(literalValues+=Literal | containedValues+=AnonymousInstance | referencedValues+=[NamedInstance:Ref]);
|
|
459
|
+
|
|
460
|
+
////////////////////////////////////////
|
|
461
|
+
// Predicates
|
|
462
|
+
////////////////////////////////////////
|
|
463
|
+
|
|
464
|
+
UnaryPredicate:
|
|
465
|
+
TypePredicate |
|
|
466
|
+
RelationEntityPredicate;
|
|
467
|
+
|
|
468
|
+
BinaryPredicate:
|
|
469
|
+
PropertyPredicate |
|
|
470
|
+
SameAsPredicate |
|
|
471
|
+
DifferentFromPredicate;
|
|
472
|
+
|
|
473
|
+
BuiltInPredicate:
|
|
474
|
+
'builtIn' '(' builtIn=[BuiltIn:Ref] ',' arguments+=Argument (',' arguments+=Argument)* ')';
|
|
475
|
+
|
|
476
|
+
////////////////////////////////////////
|
|
477
|
+
// Unary Predicates
|
|
478
|
+
////////////////////////////////////////
|
|
479
|
+
|
|
480
|
+
TypePredicate:
|
|
481
|
+
type=[Type:Ref] '(' argument=Argument ')';
|
|
482
|
+
|
|
483
|
+
RelationEntityPredicate:
|
|
484
|
+
type=[RelationEntity:Ref] '(' argument1=Argument ',' argument=Argument ',' argument2=Argument ')';
|
|
485
|
+
|
|
486
|
+
////////////////////////////////////////
|
|
487
|
+
// Binary Predicates
|
|
488
|
+
////////////////////////////////////////
|
|
489
|
+
|
|
490
|
+
PropertyPredicate:
|
|
491
|
+
property=[Property:Ref] '(' argument1=Argument ',' argument2=Argument ')';
|
|
492
|
+
|
|
493
|
+
SameAsPredicate:
|
|
494
|
+
'sameAs' '(' argument1=Argument ',' argument2=Argument ')';
|
|
495
|
+
|
|
496
|
+
DifferentFromPredicate:
|
|
497
|
+
'differentFrom' '(' argument1=Argument ',' argument2=Argument ')';
|
|
498
|
+
|
|
499
|
+
////////////////////////////////////////
|
|
500
|
+
// Literals
|
|
501
|
+
////////////////////////////////////////
|
|
502
|
+
|
|
503
|
+
IntegerLiteral:
|
|
504
|
+
value=Integer;
|
|
505
|
+
|
|
506
|
+
DecimalLiteral:
|
|
507
|
+
value=Decimal;
|
|
508
|
+
|
|
509
|
+
DoubleLiteral:
|
|
510
|
+
value=Double;
|
|
511
|
+
|
|
512
|
+
BooleanLiteral:
|
|
513
|
+
value=Boolean;
|
|
514
|
+
|
|
515
|
+
QuotedLiteral:
|
|
516
|
+
value=STRING (('^^' type=[Scalar:Ref]) | ('$' langTag=ID))?;
|
|
517
|
+
|
|
518
|
+
////////////////////////////////////////
|
|
519
|
+
// Enumerations
|
|
520
|
+
////////////////////////////////////////
|
|
521
|
+
|
|
522
|
+
RangeRestrictionKind returns string:
|
|
523
|
+
'all' |
|
|
524
|
+
'some' ;
|
|
525
|
+
|
|
526
|
+
CardinalityRestrictionKind returns string:
|
|
527
|
+
'exactly' |
|
|
528
|
+
'min' |
|
|
529
|
+
'max';
|
|
530
|
+
|
|
531
|
+
ImportKind returns string:
|
|
532
|
+
'extends' |
|
|
533
|
+
'uses' |
|
|
534
|
+
'includes';
|
|
535
|
+
|
|
536
|
+
////////////////////////////////////////
|
|
537
|
+
// Primitive Types
|
|
538
|
+
////////////////////////////////////////
|
|
539
|
+
|
|
540
|
+
Ref returns string: QNAME | ID | IRI;
|
|
541
|
+
|
|
542
|
+
CrossRef returns string: QNAME | IRI;
|
|
543
|
+
|
|
544
|
+
Boolean returns boolean: BOOLEAN;
|
|
545
|
+
|
|
546
|
+
UnsignedInteger returns number: UNSIGNED_INTEGER;
|
|
547
|
+
|
|
548
|
+
Integer returns number: UNSIGNED_INTEGER | INTEGER;
|
|
549
|
+
|
|
550
|
+
Decimal returns number: DECIMAL;
|
|
551
|
+
|
|
552
|
+
Double returns number: DOUBLE;
|
|
553
|
+
|
|
554
|
+
////////////////////////////////////////
|
|
555
|
+
// Terminals
|
|
556
|
+
////////////////////////////////////////
|
|
557
|
+
|
|
558
|
+
hidden terminal ML_COMMENT: /\/\*[\s\S]*?\*\//;
|
|
559
|
+
|
|
560
|
+
hidden terminal SL_COMMENT: /\/\/[^\n\r]*/;
|
|
561
|
+
|
|
562
|
+
hidden terminal WS: /\s+/;
|
|
563
|
+
|
|
564
|
+
//----------------------------
|
|
565
|
+
|
|
566
|
+
terminal BOOLEAN: /(false|true)/;
|
|
567
|
+
|
|
568
|
+
terminal DOUBLE: (('+'|'-')? (NUMERIC+('.'NUMERIC*)? | ('.'NUMERIC+)) ('e'|'E') ('+'|'-')? NUMERIC+) (?!(ALPHA|SPECIAL));
|
|
569
|
+
|
|
570
|
+
terminal DECIMAL: (('+'|'-')? (NUMERIC+('.'NUMERIC*)) | ('.'NUMERIC+)) (?!(ALPHA|SPECIAL));
|
|
571
|
+
|
|
572
|
+
terminal INTEGER: (('+'|'-') NUMERIC+) (?!(ALPHA|SPECIAL));
|
|
573
|
+
|
|
574
|
+
terminal UNSIGNED_INTEGER: (NUMERIC+) (?!(ALPHA|SPECIAL));
|
|
575
|
+
|
|
576
|
+
terminal STRING: ('"""' -> '"""') | ("'''" -> "'''") | ("'" -> "'") | ('"' -> '"');
|
|
577
|
+
|
|
578
|
+
terminal NAMESPACE: /<[^#>\s]*[#/]>/;
|
|
579
|
+
|
|
580
|
+
terminal IRI: /<[^>\s]*>/;
|
|
581
|
+
|
|
582
|
+
terminal QNAME: IDFRAG ':' IDFRAG;
|
|
583
|
+
|
|
584
|
+
terminal ID: '^'? IDFRAG;
|
|
585
|
+
|
|
586
|
+
//----------------------------
|
|
587
|
+
|
|
588
|
+
terminal fragment IDFRAG: (ALPHA|NUMERIC|SPECIAL) (ALPHA|NUMERIC|SPECIAL|'$')*;
|
|
589
|
+
|
|
590
|
+
terminal fragment ALPHA: /[a-zA-Z]/;
|
|
591
|
+
|
|
592
|
+
terminal fragment NUMERIC: /[0-9]/;
|
|
593
|
+
|
|
594
|
+
terminal fragment SPECIAL: /[-_.~%]/;
|