Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions org.osate.contract.help/markdown/ContractAnnex.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,53 @@ val threadsAndProcesses = self.allSubcomponents
.filter { (subcomponent, name, category) -> subcomponent.isThread || subcomponent.isProcess };
```

### Optional Member Calls

The optional member call operator (`?.`) is used on optional types such as `ComponentInstance?` or `FeatureInstance?` to
call a member on the optional's base type if the optional has a value. Optional member calls take the following form:

```
<expression>?.<function_name>
```

The resulting type of an optional member call is always an optional type. If the expression to the left of the operator
has a value, then the member call is executed and the return value is wrapped in an optional. If the expression to the
left of the operator does not have a value, then the result of the operation is an empty optional.

This is an example of an optional member call:

```
val minimum = self#Compute_Execution_Time?.minimum;
```

An optional member call is syntactic sugar for calling `map` on an optional type. The above example is equivalent to the
following example:

```
val minimum = self#Compute_Execution_Time.map { property ->
property.minimum
};
```

If an optional member call calls a member that itself returns an optional, then the optional member call is syntactic
sugar for calling `flatMap` instead of `map` on the optional. This is an example of calling a member that returns an
optional:

```
val cet_delta = self#Compute_Execution_Time?.getDelta;
```

The query `cet_delta` has the type `LongWithUnits<AADL_Project::Time_Units>?`. It does not have the type
`LongWithUnits<AADL_Project::Time_Units>??`.

The above example is equivalent to the following example:

```
val cet_delta = self#Compute_Execution_Time.flatMap { property ->
property.getDelta
};
```

### Types

The query language is statically typed with type inference. Every val statement and lambda parameter has a type which is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ private static void init(ImmutableMap.Builder<AbstractElement, String> builder,
builder.put(grammarAccess.getSignedRealAccess().getAlternatives_0(), "rule__SignedReal__Alternatives_0");
builder.put(grammarAccess.getNumAltAccess().getAlternatives(), "rule__NumAlt__Alternatives");
builder.put(grammarAccess.getLanguageAccess().getAlternatives(), "rule__Language__Alternatives");
builder.put(grammarAccess.getMemberCallOperatorAccess().getAlternatives(), "rule__MemberCallOperator__Alternatives");
builder.put(grammarAccess.getPredefinedAccess().getAlternatives(), "rule__Predefined__Alternatives");
builder.put(grammarAccess.getContractLibraryAccess().getGroup(), "rule__ContractLibrary__Group__0");
builder.put(grammarAccess.getContractAccess().getGroup(), "rule__Contract__Group__0");
Expand Down Expand Up @@ -245,6 +246,7 @@ private static void init(ImmutableMap.Builder<AbstractElement, String> builder,
builder.put(grammarAccess.getExpressionAccess().getRightAssignment_1_2(), "rule__Expression__RightAssignment_1_2");
builder.put(grammarAccess.getAndExpressionAccess().getRightAssignment_1_2(), "rule__AndExpression__RightAssignment_1_2");
builder.put(grammarAccess.getNotExpressionAccess().getOperandAssignment_1_2(), "rule__NotExpression__OperandAssignment_1_2");
builder.put(grammarAccess.getCallExpressionAccess().getOperatorAssignment_1_0_1(), "rule__CallExpression__OperatorAssignment_1_0_1");
builder.put(grammarAccess.getCallExpressionAccess().getRightAssignment_1_0_2(), "rule__CallExpression__RightAssignment_1_0_2");
builder.put(grammarAccess.getCallExpressionAccess().getTypeArgumentAssignment_1_0_3_1(), "rule__CallExpression__TypeArgumentAssignment_1_0_3_1");
builder.put(grammarAccess.getCallExpressionAccess().getArgumentAssignment_1_0_4_1(), "rule__CallExpression__ArgumentAssignment_1_0_4_1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1907,6 +1907,22 @@ finally {
restoreStackSize(stackSize);
}

// Rule MemberCallOperator
ruleMemberCallOperator
@init {
int stackSize = keepStackSize();
}
:
(
{ before(grammarAccess.getMemberCallOperatorAccess().getAlternatives()); }
(rule__MemberCallOperator__Alternatives)
{ after(grammarAccess.getMemberCallOperatorAccess().getAlternatives()); }
)
;
finally {
restoreStackSize(stackSize);
}

// Rule Predefined
rulePredefined
@init {
Expand Down Expand Up @@ -2532,6 +2548,27 @@ finally {
restoreStackSize(stackSize);
}

rule__MemberCallOperator__Alternatives
@init {
int stackSize = keepStackSize();
}
:
(
{ before(grammarAccess.getMemberCallOperatorAccess().getNORMALEnumLiteralDeclaration_0()); }
('.')
{ after(grammarAccess.getMemberCallOperatorAccess().getNORMALEnumLiteralDeclaration_0()); }
)
|
(
{ before(grammarAccess.getMemberCallOperatorAccess().getOPTIONALEnumLiteralDeclaration_1()); }
('?.')
{ after(grammarAccess.getMemberCallOperatorAccess().getOPTIONALEnumLiteralDeclaration_1()); }
)
;
finally {
restoreStackSize(stackSize);
}

rule__Predefined__Alternatives
@init {
int stackSize = keepStackSize();
Expand Down Expand Up @@ -6952,9 +6989,9 @@ rule__CallExpression__Group_1_0__1__Impl
}
:
(
{ before(grammarAccess.getCallExpressionAccess().getFullStopKeyword_1_0_1()); }
'.'
{ after(grammarAccess.getCallExpressionAccess().getFullStopKeyword_1_0_1()); }
{ before(grammarAccess.getCallExpressionAccess().getOperatorAssignment_1_0_1()); }
(rule__CallExpression__OperatorAssignment_1_0_1)
{ after(grammarAccess.getCallExpressionAccess().getOperatorAssignment_1_0_1()); }
)
;
finally {
Expand Down Expand Up @@ -12126,6 +12163,21 @@ finally {
restoreStackSize(stackSize);
}

rule__CallExpression__OperatorAssignment_1_0_1
@init {
int stackSize = keepStackSize();
}
:
(
{ before(grammarAccess.getCallExpressionAccess().getOperatorMemberCallOperatorEnumRuleCall_1_0_1_0()); }
ruleMemberCallOperator
{ after(grammarAccess.getCallExpressionAccess().getOperatorMemberCallOperatorEnumRuleCall_1_0_1_0()); }
)
;
finally {
restoreStackSize(stackSize);
}

rule__CallExpression__RightAssignment_1_0_2
@init {
int stackSize = keepStackSize();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,71 +1,72 @@
'!'=62
'#'=66
'&&'=61
'('=47
')'=48
'!'=64
'#'=67
'&&'=63
'('=49
')'=50
'*'=21
'+'=26
'+=>'=86
','=49
'+=>'=87
','=51
'-'=27
'->'=67
'.'=63
'..'=78
':'=55
'::'=72
';'=41
'<'=64
'<=>'=85
'='=59
'->'=68
'.'=31
'..'=79
':'=57
'::'=73
';'=43
'<'=65
'<=>'=86
'='=61
'=>'=24
'>'=65
'['=74
']'=75
'>'=66
'?.'=32
'['=75
']'=76
'analysis'=23
'and'=46
'applies'=80
'argument'=42
'assumptions'=39
'binding'=83
'claims'=56
'classifier'=77
'component'=54
'compute'=76
'constant'=87
'contract'=33
'contracts'=57
'declarations'=45
'delta'=79
'domain'=44
'domains'=36
'error0'=31
'and'=48
'applies'=81
'argument'=44
'assumptions'=41
'binding'=84
'claims'=58
'classifier'=78
'component'=56
'compute'=77
'constant'=88
'contract'=35
'contracts'=59
'declarations'=47
'delta'=80
'domain'=46
'domains'=38
'error0'=33
'false'=25
'guarantee'=40
'implementation'=43
'in'=82
'info0'=32
'input'=38
'guarantee'=42
'implementation'=45
'in'=83
'info0'=34
'input'=40
'invocation'=22
'java'=29
'modes'=84
'not'=51
'or'=50
'plan'=53
'modes'=85
'not'=53
'or'=52
'plan'=55
'python'=28
'queries'=37
'reference'=73
'root'=69
'self'=68
'queries'=39
'reference'=74
'root'=70
'self'=69
'smt'=30
'to'=81
'true'=88
'use'=70
'val'=58
'verification'=52
'verify'=71
'{'=34
'||'=60
'}'=35
'to'=82
'true'=89
'use'=71
'val'=60
'verification'=54
'verify'=72
'{'=36
'||'=62
'}'=37
RULE_BASED_INTEGER=18
RULE_DIGIT=15
RULE_EXPONENT=16
Expand Down Expand Up @@ -151,3 +152,4 @@ T__85=85
T__86=86
T__87=87
T__88=88
T__89=89
Loading