Skip to content

Commit 6b3d7c8

Browse files
committed
Allow any kind of expressions in slices because too many lib extend the syntax
1 parent 0af133b commit 6b3d7c8

13 files changed

Lines changed: 45 additions & 101 deletions

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ Class {
153153
'tWithParameters',
154154
'tDefinition',
155155
'tDecoratorExpression',
156-
'tWithElseClause',
157-
'tSliceContent'
156+
'tWithElseClause'
158157
],
159158
#category : 'FAST-Python-Model-Generator',
160159
#package : 'FAST-Python-Model-Generator'
@@ -326,7 +325,6 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
326325

327326
attribute --|> expression.
328327
attribute --|> tDecoratorExpression.
329-
attribute --|> tSliceContent.
330328

331329
await --|> tStatement.
332330

@@ -340,14 +338,12 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
340338

341339
boolean --|> literal.
342340
boolean --|> tBooleanLiteral.
343-
boolean --|> tSliceContent.
344341

345342
breakStatement --|> statement.
346343

347344
call --|> expression.
348345
call --|> tInvocation.
349346
call --|> tDecoratorExpression.
350-
call --|> tSliceContent.
351347

352348
classDefinition --|> tNamedBehaviouralEntity.
353349
classDefinition --|> tDefinition.
@@ -365,7 +361,6 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
365361

366362
conditionalExpression --|> expression.
367363
conditionalExpression --|> tWithCondition.
368-
conditionalExpression --|> tSliceContent.
369364

370365
continueStatement --|> statement.
371366

@@ -407,7 +402,6 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
407402

408403
identifier --|> expression.
409404
identifier --|> tDecoratorExpression.
410-
identifier --|> tSliceContent.
411405

412406
ifClause --|> expression. "This is wrong! I am just here temporarily until we rework the relation to the for in clause (I need to be able to be a clause of a list comprehension)"
413407

@@ -421,7 +415,6 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
421415

422416
integer --|> literal.
423417
integer --|> tNumericalLiteral.
424-
integer --|> tSliceContent. "Only integer can be slice content in the literals.Not even complex."
425418

426419
keywordArgument --|> expression.
427420
keywordArgument --|> tNamedEntity.
@@ -447,15 +440,13 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
447440
module --|> #THasImmediateSource.
448441

449442
none --|> literal.
450-
none --|> tSliceContent.
451443

452444
nonlocalStatement --|> statement.
453445

454446
notOperator --|> operator.
455447
notOperator --|> tUnaryOperator.
456448

457449
operator --|> expression.
458-
operator --|> tSliceContent.
459450

460451
pair --|> expression.
461452

@@ -482,7 +473,6 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
482473

483474
subscript --|> expression.
484475
subscript --|> tDecoratorExpression.
485-
subscript --|> tSliceContent.
486476

487477
thenClause --|> block.
488478

@@ -615,7 +605,7 @@ FASTPythonMetamodelGenerator >> defineRelations [
615605
(patternList property: #elements) <>-* (expression property: #patternListOwner).
616606

617607
((slice property: #components) comment: 'The components are the expressions between the `:` of a slice.')
618-
<>-* ((tSliceContent property: #sliceOwner) comment: 'Slice in which I am a component (start, end or step) (If it''s the case)''').
608+
<>-* ((expression property: #sliceOwner) comment: 'Slice in which I am a component (start, end or step) (If it''s the case)'''). "Originally, I created a trait for Slice content because the python syntax does not allow all expressions. But multiple libraries are changing the syntax to accept other objects such as float, list or even string. So now I point FASTPyExpression to not fail on all those cases."
619609

620610
(string property: #interpolations) <>-* (interpolation property: #parentString).
621611

@@ -651,7 +641,6 @@ FASTPythonMetamodelGenerator >> defineTraits [
651641
tComprehension := builder newTraitNamed: #TComprehension.
652642
tDefinition := builder newTraitNamed: #TDefinition.
653643
(tDecoratorExpression := builder newTraitNamed: #TDecoratorExpression) comment: 'I represent an entity that *can* be the expression of a decorator.'.
654-
(tSliceContent := builder newTraitNamed: #TSliceContent) comment: 'I represent an entity that can be one of the component of a slice.'.
655644
tUnaryOperator := builder newTraitNamed: #TUnaryOperator.
656645
tWithElseClause := builder newTraitNamed: #TWithElseClause.
657646

‎src/FAST-Python-Model/FASTPyAttributeAccess.class.st‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
| Relation | Origin | Opposite | Type | Comment |
77
|---|
88
| `parentDeclarator` | `FASTPyTDecoratorExpression` | `expression` | `FASTPyDecorator` | |
9-
| `sliceOwner` | `FASTPyTSliceContent` | `components` | `FASTPySlice` | Slice in which I am a component (start, end or step) (If it's the case)'|
109
1110
### Children
1211
| Relation | Origin | Opposite | Type | Comment |
@@ -20,8 +19,8 @@
2019
Class {
2120
#name : 'FASTPyAttributeAccess',
2221
#superclass : 'FASTPyExpression',
23-
#traits : 'FASTPyTDecoratorExpression + FASTPyTSliceContent',
24-
#classTraits : 'FASTPyTDecoratorExpression classTrait + FASTPyTSliceContent classTrait',
22+
#traits : 'FASTPyTDecoratorExpression',
23+
#classTraits : 'FASTPyTDecoratorExpression classTrait',
2524
#instVars : [
2625
'#attribute => FMOne type: #FASTPyVariable opposite: #attributeOwner',
2726
'#object => FMOne type: #FASTPyExpression opposite: #attributeObjectOwner'

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
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|
1717
| `returnOwner` | `FASTTExpression` | `expression` | `FASTTReturnStatement` | The return statement that own the expression (if it's the case)|
18-
| `sliceOwner` | `FASTPyTSliceContent` | `components` | `FASTPySlice` | Slice in which I am a component (start, end or step) (If it's the case)'|
1918
2019
2120
## Properties
@@ -31,8 +30,8 @@
3130
Class {
3231
#name : 'FASTPyBoolean',
3332
#superclass : 'FASTPyLiteral',
34-
#traits : 'FASTPyTSliceContent + FASTTBooleanLiteral',
35-
#classTraits : 'FASTPyTSliceContent classTrait + FASTTBooleanLiteral classTrait',
33+
#traits : 'FASTTBooleanLiteral',
34+
#classTraits : 'FASTTBooleanLiteral classTrait',
3635
#category : 'FAST-Python-Model-Entities',
3736
#package : 'FAST-Python-Model',
3837
#tag : 'Entities'

‎src/FAST-Python-Model/FASTPyCall.class.st‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
| `parentExpressionLeft` | `FASTTExpression` | `leftOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am left side|
1717
| `parentExpressionRight` | `FASTTExpression` | `rightOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am right side|
1818
| `returnOwner` | `FASTTExpression` | `expression` | `FASTTReturnStatement` | The return statement that own the expression (if it's the case)|
19-
| `sliceOwner` | `FASTPyTSliceContent` | `components` | `FASTPySlice` | Slice in which I am a component (start, end or step) (If it's the case)'|
2019
2120
### Children
2221
| Relation | Origin | Opposite | Type | Comment |
@@ -38,8 +37,8 @@
3837
Class {
3938
#name : 'FASTPyCall',
4039
#superclass : 'FASTPyExpression',
41-
#traits : 'FASTPyTDecoratorExpression + FASTPyTSliceContent + FASTTInvocation',
42-
#classTraits : 'FASTPyTDecoratorExpression classTrait + FASTPyTSliceContent classTrait + FASTTInvocation classTrait',
40+
#traits : 'FASTPyTDecoratorExpression + FASTTInvocation',
41+
#classTraits : 'FASTPyTDecoratorExpression classTrait + FASTTInvocation classTrait',
4342
#instVars : [
4443
'#callee => FMOne type: #FASTPyExpression opposite: #caller'
4544
],

‎src/FAST-Python-Model/FASTPyConditionalExpression.class.st‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
## Relations
33
======================
44
5-
### Parents
6-
| Relation | Origin | Opposite | Type | Comment |
7-
|---|
8-
| `sliceOwner` | `FASTPyTSliceContent` | `components` | `FASTPySlice` | Slice in which I am a component (start, end or step) (If it's the case)'|
9-
105
### Children
116
| Relation | Origin | Opposite | Type | Comment |
127
|---|
@@ -20,8 +15,8 @@
2015
Class {
2116
#name : 'FASTPyConditionalExpression',
2217
#superclass : 'FASTPyExpression',
23-
#traits : 'FASTPyTSliceContent + FASTTWithCondition',
24-
#classTraits : 'FASTPyTSliceContent classTrait + FASTTWithCondition classTrait',
18+
#traits : 'FASTTWithCondition',
19+
#classTraits : 'FASTTWithCondition classTrait',
2520
#instVars : [
2621
'#elseExpression => FMOne type: #FASTPyExpression opposite: #conditionalExpressionElseOwner',
2722
'#thenExpression => FMOne type: #FASTPyExpression opposite: #conditionalExpressionThenOwner'

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
| `parentUnaryOperator` | `FASTPyExpression` | `argument` | `FASTPyTUnaryOperator` | Parent unary operator in which I am.|
3939
| `patternListOwner` | `FASTPyExpression` | `elements` | `FASTPyPatternList` | |
4040
| `returnOwner` | `FASTTExpression` | `expression` | `FASTTReturnStatement` | The return statement that own the expression (if it's the case)|
41+
| `sliceOwner` | `FASTPyExpression` | `components` | `FASTPySlice` | Slice in which I am a component (start, end or step) (If it's the case)'|
4142
| `subscriptIndiceOwner` | `FASTPyExpression` | `indices` | `FASTPySubscript` | My parent if I am defining an index to select of a subscript (if it's the case)|
4243
| `subscriptValueOwner` | `FASTPyExpression` | `value` | `FASTPySubscript` | My parent if I define the receiver of a subscript (if it's the case).|
4344
| `tuplePatternOwner` | `FASTPyExpression` | `patterns` | `FASTPyTuplePattern` | |
@@ -81,6 +82,7 @@ Class {
8182
'#parentInterpolation => FMOne type: #FASTPyInterpolation opposite: #expression',
8283
'#parentUnaryOperator => FMOne type: #FASTPyTUnaryOperator opposite: #argument',
8384
'#patternListOwner => FMOne type: #FASTPyPatternList opposite: #elements',
85+
'#sliceOwner => FMOne type: #FASTPySlice opposite: #components',
8486
'#subscriptIndiceOwner => FMOne type: #FASTPySubscript opposite: #indices',
8587
'#subscriptValueOwner => FMOne type: #FASTPySubscript opposite: #value',
8688
'#tuplePatternOwner => FMOne type: #FASTPyTuplePattern opposite: #patterns'
@@ -656,6 +658,30 @@ FASTPyExpression >> patternListOwnerGroup [
656658
^ MooseSpecializedGroup with: self patternListOwner
657659
]
658660

661+
{ #category : 'accessing' }
662+
FASTPyExpression >> sliceOwner [
663+
"Relation named: #sliceOwner type: #FASTPySlice opposite: #components"
664+
665+
<generated>
666+
<FMComment: 'Slice in which I am a component (start, end or step) (If it''s the case)'''>
667+
<container>
668+
^ sliceOwner
669+
]
670+
671+
{ #category : 'accessing' }
672+
FASTPyExpression >> sliceOwner: anObject [
673+
674+
<generated>
675+
sliceOwner := anObject
676+
]
677+
678+
{ #category : 'navigation' }
679+
FASTPyExpression >> sliceOwnerGroup [
680+
<generated>
681+
<navigation: 'SliceOwner'>
682+
^ MooseSpecializedGroup with: self sliceOwner
683+
]
684+
659685
{ #category : 'accessing' }
660686
FASTPyExpression >> subscriptIndiceOwner [
661687
"Relation named: #subscriptIndiceOwner type: #FASTPySubscript opposite: #indices"

‎src/FAST-Python-Model/FASTPyIdentifier.class.st‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@
66
| Relation | Origin | Opposite | Type | Comment |
77
|---|
88
| `parentDeclarator` | `FASTPyTDecoratorExpression` | `expression` | `FASTPyDecorator` | |
9-
| `sliceOwner` | `FASTPyTSliceContent` | `components` | `FASTPySlice` | Slice in which I am a component (start, end or step) (If it's the case)'|
109
1110
1211
1312
"
1413
Class {
1514
#name : 'FASTPyIdentifier',
1615
#superclass : 'FASTPyExpression',
17-
#traits : 'FASTPyTDecoratorExpression + FASTPyTSliceContent',
18-
#classTraits : 'FASTPyTDecoratorExpression classTrait + FASTPyTSliceContent classTrait',
16+
#traits : 'FASTPyTDecoratorExpression',
17+
#classTraits : 'FASTPyTDecoratorExpression classTrait',
1918
#category : 'FAST-Python-Model-Entities',
2019
#package : 'FAST-Python-Model',
2120
#tag : 'Entities'

‎src/FAST-Python-Model/FASTPyInteger.class.st‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
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|
1717
| `returnOwner` | `FASTTExpression` | `expression` | `FASTTReturnStatement` | The return statement that own the expression (if it's the case)|
18-
| `sliceOwner` | `FASTPyTSliceContent` | `components` | `FASTPySlice` | Slice in which I am a component (start, end or step) (If it's the case)'|
1918
2019
2120
## Properties
@@ -31,8 +30,8 @@
3130
Class {
3231
#name : 'FASTPyInteger',
3332
#superclass : 'FASTPyLiteral',
34-
#traits : 'FASTPyTSliceContent + FASTTNumericalLiteral',
35-
#classTraits : 'FASTPyTSliceContent classTrait + FASTTNumericalLiteral classTrait',
33+
#traits : 'FASTTNumericalLiteral',
34+
#classTraits : 'FASTTNumericalLiteral classTrait',
3635
#category : 'FAST-Python-Model-Entities',
3736
#package : 'FAST-Python-Model',
3837
#tag : 'Entities'

‎src/FAST-Python-Model/FASTPyNone.class.st‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
Class {
1414
#name : 'FASTPyNone',
1515
#superclass : 'FASTPyLiteral',
16-
#traits : 'FASTPyTSliceContent',
17-
#classTraits : 'FASTPyTSliceContent classTrait',
1816
#category : 'FAST-Python-Model-Entities',
1917
#package : 'FAST-Python-Model',
2018
#tag : 'Entities'

‎src/FAST-Python-Model/FASTPyOperator.class.st‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
Class {
1414
#name : 'FASTPyOperator',
1515
#superclass : 'FASTPyExpression',
16-
#traits : 'FASTPyTSliceContent',
17-
#classTraits : 'FASTPyTSliceContent classTrait',
1816
#category : 'FAST-Python-Model-Entities',
1917
#package : 'FAST-Python-Model',
2018
#tag : 'Entities'

0 commit comments

Comments
 (0)