Skip to content

Commit bb579bb

Browse files
committed
Rework a little the hierarchy
1 parent a906c38 commit bb579bb

15 files changed

Lines changed: 92 additions & 120 deletions

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

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ Class {
147147
'tConditionalStatement',
148148
'complex',
149149
'thenClause',
150-
'tLoopStatement'
150+
'tLoopStatement',
151+
'statement'
151152
],
152153
#category : 'FAST-Python-Model-Generator',
153154
#package : 'FAST-Python-Model-Generator'
@@ -280,6 +281,7 @@ FASTPythonMetamodelGenerator >> defineClasses [
280281
slice := builder ensureClassNamed: #Slice."Todo"
281282
splatPattern := builder ensureClassNamed: #SplatPattern."Todo"
282283
splatType := builder ensureClassNamed: #SplatType."Todo"
284+
statement := builder ensureClassNamed: #Statement.
283285
string := builder ensureClassNamed: #String.
284286
structuralEntity := builder ensureClassNamed: #StructuralEntity.
285287
subscript := builder ensureClassNamed: #Subscript."Todo"
@@ -318,7 +320,7 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
318320

319321
assignment --|> tAssignment.
320322

321-
assertStatement --|> tStatement.
323+
assertStatement --|> statement.
322324

323325
attribute --|> structuralEntity.
324326

@@ -333,8 +335,7 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
333335
boolean --|> literal.
334336
boolean --|> tBooleanLiteral.
335337

336-
breakStatement --|> expression.
337-
breakStatement --|> tStatement.
338+
breakStatement --|> statement.
338339

339340
call --|> tInvocation.
340341

@@ -348,11 +349,9 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
348349

349350
complex --|> literal.
350351

351-
continueStatement --|> expression.
352-
continueStatement --|> tStatement.
352+
continueStatement --|> statement.
353353

354-
deleteStatement --|> expression.
355-
deleteStatement --|> tStatement.
354+
deleteStatement --|> statement.
356355

357356
dictionary --|> collectionInitializer.
358357

@@ -361,17 +360,15 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
361360
elifClause --|> block.
362361
elifClause --|> tConditionalStatement.
363362

363+
expression --|> statement. "In Python expressions can also be expression statements."
364364
expression --|> tExpression.
365-
expression --|> tStatement. "In python expressions can be statements"
366365

367-
forStatement --|> expression.
366+
forStatement --|> statement.
368367
forStatement --|> tLoopStatement.
369368

370-
self flag: #todo. "I am not sure this should be the case but the importer is too young and we need this to not have everything breaking."
371369
identifier --|> expression.
372370

373-
ifStatement --|> expression.
374-
ifStatement --|> tStatement.
371+
ifStatement --|> statement.
375372
ifStatement --|> tConditionalStatement.
376373

377374
importStatement --|> import.
@@ -382,8 +379,7 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
382379

383380
functionDefinition --|> tNamedBehaviouralEntity.
384381

385-
globalStatement --|> expression.
386-
globalStatement --|> tStatement.
382+
globalStatement --|> statement.
387383

388384
integer --|> literal.
389385

@@ -394,15 +390,13 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
394390

395391
none --|> literal.
396392

397-
nonlocalStatement --|> expression.
398-
nonlocalStatement --|> tStatement.
393+
nonlocalStatement --|> statement.
399394

400395
pair --|> expression.
401396

402397
parameter --|> structuralEntity.
403398

404-
passStatement --|> expression.
405-
passStatement --|> tStatement.
399+
passStatement --|> statement.
406400

407401
listSplat --|> expression.
408402

@@ -417,11 +411,12 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
417411

418412
pair --|> expression.
419413

420-
returnStatement --|> expression.
421-
returnStatement --|> tStatement.
414+
returnStatement --|> statement.
422415
returnStatement --|> tReturnStatement.
423416

424417
set --|> collectionInitializer.
418+
419+
statement --|> tStatement.
425420

426421
string --|> literal.
427422
string --|> tStringLiteral.
@@ -437,7 +432,7 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
437432

438433
variable --|> structuralEntity.
439434

440-
whileStatement --|> expression.
435+
whileStatement --|> statement.
441436
whileStatement --|> tConditionalStatement.
442437
whileStatement --|> tLoopStatement
443438
]

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

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,17 @@
22
## Relations
33
======================
44
5-
### Parents
6-
| Relation | Origin | Opposite | Type | Comment |
7-
|---|
8-
| `parentLoopStatement` | `FASTTStatement` | `body` | `FASTTLoopStatement` | Optional loop of which this statement is the body|
9-
| `statementContainer` | `FASTTStatement` | `statements` | `FASTTStatementBlock` | Block containing this statement.|
10-
115
### Children
126
| Relation | Origin | Opposite | Type | Comment |
137
|---|
148
| `expression` | `FASTPyAssertStatement` | `assertOwner` | `FASTPyExpression` | The expression asserted|
159
1610
17-
## Properties
18-
======================
19-
20-
| Name | Type | Default value | Comment |
21-
|---|
22-
| `endPos` | `Number` | nil | |
23-
| `startPos` | `Number` | nil | |
2411
2512
"
2613
Class {
2714
#name : 'FASTPyAssertStatement',
28-
#superclass : 'FASTPyEntity',
29-
#traits : 'FASTTStatement',
30-
#classTraits : 'FASTTStatement classTrait',
15+
#superclass : 'FASTPyStatement',
3116
#instVars : [
3217
'#expression => FMOne type: #FASTPyExpression opposite: #assertOwner'
3318
],
@@ -39,7 +24,7 @@ Class {
3924
{ #category : 'meta' }
4025
FASTPyAssertStatement class >> annotation [
4126

42-
<FMClass: #AssertStatement super: #FASTPyEntity>
27+
<FMClass: #AssertStatement super: #FASTPyStatement>
4328
<package: #'FAST-Python-Model'>
4429
<generated>
4530
^ self

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020
"
2121
Class {
2222
#name : 'FASTPyBreakStatement',
23-
#superclass : 'FASTPyExpression',
24-
#traits : 'FASTTStatement',
25-
#classTraits : 'FASTTStatement classTrait',
23+
#superclass : 'FASTPyStatement',
2624
#category : 'FAST-Python-Model-Entities',
2725
#package : 'FAST-Python-Model',
2826
#tag : 'Entities'
@@ -31,7 +29,7 @@ Class {
3129
{ #category : 'meta' }
3230
FASTPyBreakStatement class >> annotation [
3331

34-
<FMClass: #BreakStatement super: #FASTPyExpression>
32+
<FMClass: #BreakStatement super: #FASTPyStatement>
3533
<package: #'FAST-Python-Model'>
3634
<generated>
3735
^ self

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020
"
2121
Class {
2222
#name : 'FASTPyContinueStatement',
23-
#superclass : 'FASTPyExpression',
24-
#traits : 'FASTTStatement',
25-
#classTraits : 'FASTTStatement classTrait',
23+
#superclass : 'FASTPyStatement',
2624
#category : 'FAST-Python-Model-Entities',
2725
#package : 'FAST-Python-Model',
2826
#tag : 'Entities'
@@ -31,7 +29,7 @@ Class {
3129
{ #category : 'meta' }
3230
FASTPyContinueStatement class >> annotation [
3331

34-
<FMClass: #ContinueStatement super: #FASTPyExpression>
32+
<FMClass: #ContinueStatement super: #FASTPyStatement>
3533
<package: #'FAST-Python-Model'>
3634
<generated>
3735
^ self

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

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,17 @@
22
## Relations
33
======================
44
5-
### Parents
6-
| Relation | Origin | Opposite | Type | Comment |
7-
|---|
8-
| `parentLoopStatement` | `FASTTStatement` | `body` | `FASTTLoopStatement` | Optional loop of which this statement is the body|
9-
| `statementContainer` | `FASTTStatement` | `statements` | `FASTTStatementBlock` | Block containing this statement.|
10-
115
### Children
126
| Relation | Origin | Opposite | Type | Comment |
137
|---|
148
| `expression` | `FASTPyDeleteStatement` | `deleteOwner` | `FASTPyExpression` | The expression to apply the delete on|
159
1610
17-
## Properties
18-
======================
19-
20-
| Name | Type | Default value | Comment |
21-
|---|
22-
| `endPos` | `Number` | nil | |
23-
| `startPos` | `Number` | nil | |
2411
2512
"
2613
Class {
2714
#name : 'FASTPyDeleteStatement',
28-
#superclass : 'FASTPyExpression',
29-
#traits : 'FASTTStatement',
30-
#classTraits : 'FASTTStatement classTrait',
15+
#superclass : 'FASTPyStatement',
3116
#instVars : [
3217
'#expression => FMOne type: #FASTPyExpression opposite: #deleteOwner'
3318
],
@@ -39,7 +24,7 @@ Class {
3924
{ #category : 'meta' }
4025
FASTPyDeleteStatement class >> annotation [
4126

42-
<FMClass: #DeleteStatement super: #FASTPyExpression>
27+
<FMClass: #DeleteStatement super: #FASTPyStatement>
4328
<package: #'FAST-Python-Model'>
4429
<generated>
4530
^ self

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@
2121
| `parentExpression` | `FASTTExpression` | `expression` | `FASTTUnaryExpression` | Parent (unary) expression|
2222
| `parentExpressionLeft` | `FASTTExpression` | `leftOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am left side|
2323
| `parentExpressionRight` | `FASTTExpression` | `rightOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am right side|
24-
| `parentLoopStatement` | `FASTTStatement` | `body` | `FASTTLoopStatement` | Optional loop of which this statement is the body|
2524
| `parentUnaryOperator` | `FASTPyExpression` | `argument` | `FASTPyTUnaryOperator` | Parent unary operator in which I am.|
2625
| `returnOwner` | `FASTTExpression` | `expression` | `FASTTReturnStatement` | The return statement that own the expression (if it's the case)|
27-
| `statementContainer` | `FASTTStatement` | `statements` | `FASTTStatementBlock` | Block containing this statement.|
2826
2927
3028
## Properties
@@ -38,9 +36,9 @@
3836
"
3937
Class {
4038
#name : 'FASTPyExpression',
41-
#superclass : 'FASTPyEntity',
42-
#traits : 'FASTTExpression + FASTTStatement',
43-
#classTraits : 'FASTTExpression classTrait + FASTTStatement classTrait',
39+
#superclass : 'FASTPyStatement',
40+
#traits : 'FASTTExpression',
41+
#classTraits : 'FASTTExpression classTrait',
4442
#instVars : [
4543
'#assertOwner => FMOne type: #FASTPyAssertStatement opposite: #expression',
4644
'#collectionInitializer => FMOne type: #FASTPyCollectionInitializer opposite: #initializers',
@@ -59,7 +57,7 @@ Class {
5957
{ #category : 'meta' }
6058
FASTPyExpression class >> annotation [
6159

62-
<FMClass: #Expression super: #FASTPyEntity>
60+
<FMClass: #Expression super: #FASTPyStatement>
6361
<package: #'FAST-Python-Model'>
6462
<generated>
6563
^ self

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"
2828
Class {
2929
#name : 'FASTPyForStatement',
30-
#superclass : 'FASTPyExpression',
30+
#superclass : 'FASTPyStatement',
3131
#traits : 'FASTTLoopStatement',
3232
#classTraits : 'FASTTLoopStatement classTrait',
3333
#instVars : [
@@ -42,7 +42,7 @@ Class {
4242
{ #category : 'meta' }
4343
FASTPyForStatement class >> annotation [
4444

45-
<FMClass: #ForStatement super: #FASTPyExpression>
45+
<FMClass: #ForStatement super: #FASTPyStatement>
4646
<package: #'FAST-Python-Model'>
4747
<generated>
4848
^ self

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

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,17 @@
22
## Relations
33
======================
44
5-
### Parents
6-
| Relation | Origin | Opposite | Type | Comment |
7-
|---|
8-
| `parentLoopStatement` | `FASTTStatement` | `body` | `FASTTLoopStatement` | Optional loop of which this statement is the body|
9-
| `statementContainer` | `FASTTStatement` | `statements` | `FASTTStatementBlock` | Block containing this statement.|
10-
115
### Children
126
| Relation | Origin | Opposite | Type | Comment |
137
|---|
148
| `variable` | `FASTPyGlobalStatement` | `globalOwner` | `FASTPyVariable` | The variable scoped|
159
1610
17-
## Properties
18-
======================
19-
20-
| Name | Type | Default value | Comment |
21-
|---|
22-
| `endPos` | `Number` | nil | |
23-
| `startPos` | `Number` | nil | |
2411
2512
"
2613
Class {
2714
#name : 'FASTPyGlobalStatement',
28-
#superclass : 'FASTPyExpression',
29-
#traits : 'FASTTStatement',
30-
#classTraits : 'FASTTStatement classTrait',
15+
#superclass : 'FASTPyStatement',
3116
#instVars : [
3217
'#variable => FMOne type: #FASTPyVariable opposite: #globalOwner'
3318
],
@@ -39,7 +24,7 @@ Class {
3924
{ #category : 'meta' }
4025
FASTPyGlobalStatement class >> annotation [
4126

42-
<FMClass: #GlobalStatement super: #FASTPyExpression>
27+
<FMClass: #GlobalStatement super: #FASTPyStatement>
4328
<package: #'FAST-Python-Model'>
4429
<generated>
4530
^ self

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
"
2929
Class {
3030
#name : 'FASTPyIfStatement',
31-
#superclass : 'FASTPyExpression',
32-
#traits : 'FASTTConditionalStatement + FASTTStatement',
33-
#classTraits : 'FASTTConditionalStatement classTrait + FASTTStatement classTrait',
31+
#superclass : 'FASTPyStatement',
32+
#traits : 'FASTTConditionalStatement',
33+
#classTraits : 'FASTTConditionalStatement classTrait',
3434
#instVars : [
3535
'#elifClauses => FMMany type: #FASTPyElifClause opposite: #ifStatementOwner',
3636
'#elseClause => FMOne type: #FASTPyElseClause opposite: #ifStatementOwner',
@@ -44,7 +44,7 @@ Class {
4444
{ #category : 'meta' }
4545
FASTPyIfStatement class >> annotation [
4646

47-
<FMClass: #IfStatement super: #FASTPyExpression>
47+
<FMClass: #IfStatement super: #FASTPyStatement>
4848
<package: #'FAST-Python-Model'>
4949
<generated>
5050
^ self

0 commit comments

Comments
 (0)