Skip to content

Commit cc9ff30

Browse files
committed
Manages unary operators
1 parent a9f461c commit cc9ff30

14 files changed

Lines changed: 163 additions & 58 deletions

src/FAST-Python-Model-Generator/FASTPythonMetamodelGenerator.class.st

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ Class {
136136
'tExpression',
137137
'expression',
138138
'tBinaryExpression',
139-
'operator'
139+
'operator',
140+
'tUnaryOperator'
140141
],
141142
#category : 'FAST-Python-Model-Generator',
142143
#package : 'FAST-Python-Model-Generator'
@@ -280,7 +281,7 @@ FASTPythonMetamodelGenerator >> defineClasses [
280281
typeParameter := builder ensureClassNamed: #TypeParameter."Todo"
281282
typedDefaultParameter := builder ensureClassNamed: #TypedDefaultParameter."Todo"
282283
typedParameter := builder ensureClassNamed: #TypedParameter."Todo"
283-
unaryOperator := builder ensureClassNamed: #UnaryOperator."Todo"
284+
unaryOperator := builder ensureClassNamed: #UnaryOperator.
284285
unionPattern := builder ensureClassNamed: #UnionPattern."Todo"
285286
unionType := builder ensureClassNamed: #UnionType."Todo"
286287
whileStatement := builder ensureClassNamed: #WhileStatement."Todo"
@@ -338,11 +339,15 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
338339
module --|> #THasImmediateSource.
339340

340341
notOperator --|> operator.
342+
notOperator --|> tUnaryOperator.
341343

342344
operator --|> expression.
343345

344346
string --|> literal.
345-
string --|> tStringLiteral
347+
string --|> tStringLiteral.
348+
349+
unaryOperator --|> operator.
350+
unaryOperator --|> tUnaryOperator
346351
]
347352

348353
{ #category : 'definition' }
@@ -352,7 +357,9 @@ FASTPythonMetamodelGenerator >> defineProperties [
352357

353358
(comparisonOperator property: #operators type: #String)
354359
multivalued: true;
355-
comment: 'The comparators applied in order. Possible operators: <, <=, ==, !=, >=, >, <>, in, not in, is, is not'
360+
comment: 'The comparators applied in order. Possible operators: <, <=, ==, !=, >=, >, <>, in, not in, is, is not'.
361+
362+
unaryOperator property: #operator type: #String
356363
]
357364

358365
{ #category : 'definition' }
@@ -366,9 +373,9 @@ FASTPythonMetamodelGenerator >> defineRelations [
366373
'List of the operands of the comparison operands. For example if we have `a == b != c`, it will be a, b and c.')
367374
<>-* ((tExpression property: #parentComparisonOperator) comment: 'Parent comparison expression of which I am.').
368375

369-
((notOperator property: #argument) comment:
370-
'Expression to negate.')
371-
<>- ((tExpression property: #parentNotOperator) comment: 'Parent not operator in which I am.').
376+
((tUnaryOperator property: #argument) comment:
377+
'Expression influanced by the unary operator..')
378+
<>- ((tExpression property: #parentUnaryOperator) comment: 'Parent unary operator in which I am.').
372379

373380
]
374381

@@ -379,6 +386,9 @@ FASTPythonMetamodelGenerator >> defineTraits [
379386

380387
"From FAST"
381388
tEntity := self remoteTrait: #TEntity withPrefix: #FAST.
389+
390+
391+
tUnaryOperator := builder newTraitNamed: #TUnaryOperator.
382392

383393
tBinaryExpression := self remoteTrait: #TBinaryExpression withPrefix: #FAST.
384394
tBooleanLiteral := self remoteTrait: #TBooleanLiteral withPrefix: #FAST.

src/FAST-Python-Model/FASTPyBinaryOperator.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
| `parentExpression` | `FASTTExpression` | `expression` | `FASTTUnaryExpression` | Parent (unary) expression|
1414
| `parentExpressionLeft` | `FASTTExpression` | `leftOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am left side|
1515
| `parentExpressionRight` | `FASTTExpression` | `rightOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am right side|
16-
| `parentNotOperator` | `FASTTExpression` | `argument` | `FASTPyNotOperator` | Parent not operator in which I am.|
16+
| `parentUnaryOperator` | `FASTTExpression` | `argument` | `FASTPyTUnaryOperator` | Parent unary operator in which I am.|
1717
| `returnOwner` | `FASTTExpression` | `expression` | `FASTTReturnStatement` | The return statement that own the expression (if it's the case)|
1818
1919
### Children

src/FAST-Python-Model/FASTPyBoolean.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
| `parentExpression` | `FASTTExpression` | `expression` | `FASTTUnaryExpression` | Parent (unary) expression|
1414
| `parentExpressionLeft` | `FASTTExpression` | `leftOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am left side|
1515
| `parentExpressionRight` | `FASTTExpression` | `rightOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am right side|
16-
| `parentNotOperator` | `FASTTExpression` | `argument` | `FASTPyNotOperator` | Parent not operator in which I am.|
16+
| `parentUnaryOperator` | `FASTTExpression` | `argument` | `FASTPyTUnaryOperator` | Parent unary operator in which I am.|
1717
| `returnOwner` | `FASTTExpression` | `expression` | `FASTTReturnStatement` | The return statement that own the expression (if it's the case)|
1818
1919

src/FAST-Python-Model/FASTPyBooleanOperator.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
| `parentExpression` | `FASTTExpression` | `expression` | `FASTTUnaryExpression` | Parent (unary) expression|
1414
| `parentExpressionLeft` | `FASTTExpression` | `leftOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am left side|
1515
| `parentExpressionRight` | `FASTTExpression` | `rightOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am right side|
16-
| `parentNotOperator` | `FASTTExpression` | `argument` | `FASTPyNotOperator` | Parent not operator in which I am.|
16+
| `parentUnaryOperator` | `FASTTExpression` | `argument` | `FASTPyTUnaryOperator` | Parent unary operator in which I am.|
1717
| `returnOwner` | `FASTTExpression` | `expression` | `FASTTReturnStatement` | The return statement that own the expression (if it's the case)|
1818
1919
### Children

src/FAST-Python-Model/FASTPyEntity.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
| `parentExpression` | `FASTTExpression` | `expression` | `FASTTUnaryExpression` | Parent (unary) expression|
1515
| `parentExpressionLeft` | `FASTTExpression` | `leftOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am left side|
1616
| `parentExpressionRight` | `FASTTExpression` | `rightOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am right side|
17-
| `parentNotOperator` | `FASTTExpression` | `argument` | `FASTPyNotOperator` | Parent not operator in which I am.|
17+
| `parentUnaryOperator` | `FASTTExpression` | `argument` | `FASTPyTUnaryOperator` | Parent unary operator in which I am.|
1818
| `returnOwner` | `FASTTExpression` | `expression` | `FASTTReturnStatement` | The return statement that own the expression (if it's the case)|
1919
2020
### Children

src/FAST-Python-Model/FASTPyExpression.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
| `parentExpression` | `FASTTExpression` | `expression` | `FASTTUnaryExpression` | Parent (unary) expression|
1414
| `parentExpressionLeft` | `FASTTExpression` | `leftOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am left side|
1515
| `parentExpressionRight` | `FASTTExpression` | `rightOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am right side|
16-
| `parentNotOperator` | `FASTTExpression` | `argument` | `FASTPyNotOperator` | Parent not operator in which I am.|
16+
| `parentUnaryOperator` | `FASTTExpression` | `argument` | `FASTPyTUnaryOperator` | Parent unary operator in which I am.|
1717
| `returnOwner` | `FASTTExpression` | `expression` | `FASTTReturnStatement` | The return statement that own the expression (if it's the case)|
1818
1919

src/FAST-Python-Model/FASTPyLiteral.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
| `parentExpression` | `FASTTExpression` | `expression` | `FASTTUnaryExpression` | Parent (unary) expression|
1414
| `parentExpressionLeft` | `FASTTExpression` | `leftOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am left side|
1515
| `parentExpressionRight` | `FASTTExpression` | `rightOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am right side|
16-
| `parentNotOperator` | `FASTTExpression` | `argument` | `FASTPyNotOperator` | Parent not operator in which I am.|
16+
| `parentUnaryOperator` | `FASTTExpression` | `argument` | `FASTPyTUnaryOperator` | Parent unary operator in which I am.|
1717
| `returnOwner` | `FASTTExpression` | `expression` | `FASTTReturnStatement` | The return statement that own the expression (if it's the case)|
1818
1919

src/FAST-Python-Model/FASTPyNotOperator.class.st

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
### Children
66
| Relation | Origin | Opposite | Type | Comment |
77
|---|
8-
| `argument` | `FASTPyNotOperator` | `parentNotOperator` | `FASTTExpression` | Expression to negate.|
8+
| `argument` | `FASTPyTUnaryOperator` | `parentUnaryOperator` | `FASTTExpression` | Expression influanced by the unary operator..|
99
1010
1111
1212
"
1313
Class {
1414
#name : 'FASTPyNotOperator',
1515
#superclass : 'FASTPyOperator',
16+
#traits : 'FASTPyTUnaryOperator',
17+
#classTraits : 'FASTPyTUnaryOperator classTrait',
1618
#category : 'FAST-Python-Model-Entities',
1719
#package : 'FAST-Python-Model',
1820
#tag : 'Entities'
@@ -26,34 +28,3 @@ FASTPyNotOperator class >> annotation [
2628
<generated>
2729
^ self
2830
]
29-
30-
{ #category : 'accessing' }
31-
FASTPyNotOperator >> argument [
32-
"Relation named: #argument type: #FASTTExpression opposite: #parentNotOperator"
33-
34-
<generated>
35-
<FMComment: 'Expression to negate.'>
36-
<FMProperty: #argument type: #FASTTExpression opposite: #parentNotOperator>
37-
^ self attributeAt: #argument ifAbsent: [ nil ]
38-
]
39-
40-
{ #category : 'accessing' }
41-
FASTPyNotOperator >> argument: anObject [
42-
43-
<generated>
44-
(self attributeAt: #argument ifAbsentPut: [nil]) == anObject ifTrue: [ ^ anObject ].
45-
anObject ifNil: [ | otherSide |
46-
otherSide := self argument.
47-
self attributeAt: #argument put: anObject.
48-
otherSide parentNotOperator: nil ]
49-
ifNotNil: [
50-
self attributeAt: #argument put: anObject.
51-
anObject parentNotOperator: self ]
52-
]
53-
54-
{ #category : 'navigation' }
55-
FASTPyNotOperator >> argumentGroup [
56-
<generated>
57-
<navigation: 'Argument'>
58-
^ MooseSpecializedGroup with: self argument
59-
]

src/FAST-Python-Model/FASTPyString.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
| `parentExpression` | `FASTTExpression` | `expression` | `FASTTUnaryExpression` | Parent (unary) expression|
1414
| `parentExpressionLeft` | `FASTTExpression` | `leftOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am left side|
1515
| `parentExpressionRight` | `FASTTExpression` | `rightOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am right side|
16-
| `parentNotOperator` | `FASTTExpression` | `argument` | `FASTPyNotOperator` | Parent not operator in which I am.|
16+
| `parentUnaryOperator` | `FASTTExpression` | `argument` | `FASTPyTUnaryOperator` | Parent unary operator in which I am.|
1717
| `returnOwner` | `FASTTExpression` | `expression` | `FASTTReturnStatement` | The return statement that own the expression (if it's the case)|
1818
1919
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
"
2+
## Relations
3+
======================
4+
5+
### Children
6+
| Relation | Origin | Opposite | Type | Comment |
7+
|---|
8+
| `argument` | `FASTPyTUnaryOperator` | `parentUnaryOperator` | `FASTTExpression` | Expression influanced by the unary operator..|
9+
10+
11+
12+
"
13+
Trait {
14+
#name : 'FASTPyTUnaryOperator',
15+
#category : 'FAST-Python-Model-Traits',
16+
#package : 'FAST-Python-Model',
17+
#tag : 'Traits'
18+
}
19+
20+
{ #category : 'meta' }
21+
FASTPyTUnaryOperator classSide >> annotation [
22+
23+
<FMClass: #TUnaryOperator super: #Object>
24+
<package: #'FAST-Python-Model'>
25+
<generated>
26+
^ self
27+
]
28+
29+
{ #category : 'accessing' }
30+
FASTPyTUnaryOperator >> argument [
31+
"Relation named: #argument type: #FASTTExpression opposite: #parentUnaryOperator"
32+
33+
<generated>
34+
<FMComment: 'Expression influanced by the unary operator..'>
35+
<FMProperty: #argument type: #FASTTExpression opposite: #parentUnaryOperator>
36+
^ self attributeAt: #argument ifAbsent: [ nil ]
37+
]
38+
39+
{ #category : 'accessing' }
40+
FASTPyTUnaryOperator >> argument: anObject [
41+
42+
<generated>
43+
(self attributeAt: #argument ifAbsentPut: [nil]) == anObject ifTrue: [ ^ anObject ].
44+
anObject ifNil: [ | otherSide |
45+
otherSide := self argument.
46+
self attributeAt: #argument put: anObject.
47+
otherSide parentUnaryOperator: nil ]
48+
ifNotNil: [
49+
self attributeAt: #argument put: anObject.
50+
anObject parentUnaryOperator: self ]
51+
]
52+
53+
{ #category : 'navigation' }
54+
FASTPyTUnaryOperator >> argumentGroup [
55+
<generated>
56+
<navigation: 'Argument'>
57+
^ MooseSpecializedGroup with: self argument
58+
]

0 commit comments

Comments
 (0)