Skip to content

Commit 8a480c4

Browse files
committed
Add support of exec statement
1 parent 415613c commit 8a480c4

13 files changed

Lines changed: 361 additions & 413 deletions

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ Class {
154154
'tSuperclass',
155155
'tCallable',
156156
'tSliceIndex',
157-
'tAwaitable'
157+
'tAwaitable',
158+
'tExecutable'
158159
],
159160
#category : 'FAST-Python-Model-Generator',
160161
#package : 'FAST-Python-Model-Generator'
@@ -370,6 +371,7 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
370371
conditionalExpression --|> tWithCondition.
371372
conditionalExpression --|> tSuperclass.
372373
conditionalExpression --|> tCallable.
374+
conditionalExpression --|> tExecutable.
373375

374376
continueStatement --|> statement.
375377

@@ -526,6 +528,7 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
526528
string --|> literal.
527529
string --|> tStringLiteral.
528530
string --|> tSplatExpression.
531+
string --|> tExecutable.
529532

530533
subscript --|> expression.
531534
subscript --|> tReturnReferenceable.
@@ -545,6 +548,7 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
545548
tReturnReferenceable --|> tSuperclass.
546549
tReturnReferenceable --|> tCallable.
547550
tReturnReferenceable --|> tAwaitable.
551+
tReturnReferenceable --|> tExecutable.
548552

549553
thenClause --|> tStatementBlock.
550554

@@ -681,6 +685,9 @@ FASTPythonMetamodelGenerator >> defineRelations [
681685
<>- ((tDeletable property: #parentDeleteStatement) comment: 'The delete statement that own the expression (if it''s the case)').
682686

683687
(exceptClause property: #expressions) <>-* (expression property: #parentExceptClause). "We could point less things than expression, but in reality in Python any expression can be provided. It will just end up in runtime error."
688+
689+
(execStatement property: #code) <>- (tExecutable property: #parentExecStatement).
690+
(execStatement property: #scopes) <>-* (expression property: #parentExecStatementScopes).
684691

685692
(forInClause property: #left) <>- (expression property: #forInClauseLeftOwner).
686693
(forInClause property: #right) <>- (expression property: #forInClauseRightOwner).
@@ -804,6 +811,8 @@ FASTPythonMetamodelGenerator >> defineTraits [
804811

805812
tDeletable := (builder newTraitNamed: #TDeletable) comment: 'I represent an expression that can be in a delete statement.'.
806813

814+
tExecutable := (builder newTraitNamed: #TExecutable) comment: 'I represent something that can be executed by an exec statement'.
815+
807816
tPattern := (builder newTraitNamed: #TPattern) comment: 'I represent an entity that can be the pattern of a case clause in a match statement..'.
808817

809818
tRaised := (builder newTraitNamed: #TRaised) comment: 'I represent an expression that can give an exception to raise in a raise statement.'.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
| `parentClassDefinition` | `FASTPyTSuperclass` | `superclasses` | `FASTPyClassDefinition` | |
1515
| `parentDeclarator` | `FASTPyTDecoratorExpression` | `expression` | `FASTPyDecorator` | |
1616
| `parentDeleteStatement` | `FASTPyTDeletable` | `expression` | `FASTPyDeleteStatement` | The delete statement that own the expression (if it's the case)|
17+
| `parentExecStatement` | `FASTPyTExecutable` | `code` | `FASTPyExecStatement` | |
1718
| `parentRaiseStatement` | `FASTPyTRaised` | `exception` | `FASTPyRaiseStatement` | |
1819
| `parentSplat` | `FASTPyTSplatExpression` | `expression` | `FASTPySplat` | |
1920
| `parentSplatParameter` | `FASTPyTSplatParameterTarget` | `target` | `FASTPySplatParameter` | |

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
| `parentConditional` | `FASTTExpression` | `condition` | `FASTTWithCondition` | Optional condition statement/expression where this expression is used|
1717
| `parentDeclarator` | `FASTPyTDecoratorExpression` | `expression` | `FASTPyDecorator` | |
1818
| `parentDeleteStatement` | `FASTPyTDeletable` | `expression` | `FASTPyDeleteStatement` | The delete statement that own the expression (if it's the case)|
19+
| `parentExecStatement` | `FASTPyTExecutable` | `code` | `FASTPyExecStatement` | |
1920
| `parentExpression` | `FASTTExpression` | `expression` | `FASTTUnaryExpression` | Parent (unary) expression|
2021
| `parentExpressionLeft` | `FASTTExpression` | `leftOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am left side|
2122
| `parentExpressionRight` | `FASTTExpression` | `rightOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am right side|

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
|---|
88
| `caller` | `FASTPyTCallable` | `callee` | `FASTPyCall` | The call entity calling me (if it's the case)|
99
| `parentClassDefinition` | `FASTPyTSuperclass` | `superclasses` | `FASTPyClassDefinition` | |
10+
| `parentExecStatement` | `FASTPyTExecutable` | `code` | `FASTPyExecStatement` | |
1011
1112
### Children
1213
| Relation | Origin | Opposite | Type | Comment |
@@ -21,8 +22,8 @@
2122
Class {
2223
#name : 'FASTPyConditionalExpression',
2324
#superclass : 'FASTPyExpression',
24-
#traits : 'FASTPyTCallable + FASTPyTSuperclass + FASTTWithCondition',
25-
#classTraits : 'FASTPyTCallable classTrait + FASTPyTSuperclass classTrait + FASTTWithCondition classTrait',
25+
#traits : 'FASTPyTCallable + FASTPyTExecutable + FASTPyTSuperclass + FASTTWithCondition',
26+
#classTraits : 'FASTPyTCallable classTrait + FASTPyTExecutable classTrait + FASTPyTSuperclass classTrait + FASTTWithCondition classTrait',
2627
#instVars : [
2728
'#elseExpression => FMOne type: #FASTPyExpression opposite: #conditionalExpressionElseOwner',
2829
'#thenExpression => FMOne type: #FASTPyExpression opposite: #conditionalExpressionThenOwner'

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

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
1+
"
2+
## Relations
3+
======================
4+
5+
### Children
6+
| Relation | Origin | Opposite | Type | Comment |
7+
|---|
8+
| `code` | `FASTPyExecStatement` | `parentExecStatement` | `FASTPyTExecutable` | |
9+
| `scopes` | `FASTPyExecStatement` | `parentExecStatementScopes` | `FASTPyExpression` | |
10+
11+
12+
13+
"
114
Class {
215
#name : 'FASTPyExecStatement',
316
#superclass : 'FASTPyStatement',
17+
#instVars : [
18+
'#code => FMOne type: #FASTPyTExecutable opposite: #parentExecStatement',
19+
'#scopes => FMMany type: #FASTPyExpression opposite: #parentExecStatementScopes'
20+
],
421
#category : 'FAST-Python-Model-Entities',
522
#package : 'FAST-Python-Model',
623
#tag : 'Entities'
@@ -14,3 +31,54 @@ FASTPyExecStatement class >> annotation [
1431
<generated>
1532
^ self
1633
]
34+
35+
{ #category : 'adding' }
36+
FASTPyExecStatement >> addScope: anObject [
37+
<generated>
38+
^ self scopes add: anObject
39+
]
40+
41+
{ #category : 'accessing' }
42+
FASTPyExecStatement >> code [
43+
"Relation named: #code type: #FASTPyTExecutable opposite: #parentExecStatement"
44+
45+
<generated>
46+
^ code
47+
]
48+
49+
{ #category : 'accessing' }
50+
FASTPyExecStatement >> code: anObject [
51+
52+
<generated>
53+
code := anObject
54+
]
55+
56+
{ #category : 'navigation' }
57+
FASTPyExecStatement >> codeGroup [
58+
<generated>
59+
<navigation: 'Code'>
60+
^ MooseSpecializedGroup with: self code
61+
]
62+
63+
{ #category : 'accessing' }
64+
FASTPyExecStatement >> scopes [
65+
"Relation named: #scopes type: #FASTPyExpression opposite: #parentExecStatementScopes"
66+
67+
<generated>
68+
<derived>
69+
^ scopes
70+
]
71+
72+
{ #category : 'accessing' }
73+
FASTPyExecStatement >> scopes: anObject [
74+
75+
<generated>
76+
scopes value: anObject
77+
]
78+
79+
{ #category : 'navigation' }
80+
FASTPyExecStatement >> scopesGroup [
81+
<generated>
82+
<navigation: 'Scopes'>
83+
^ MooseSpecializedGroup withAll: self scopes asSet
84+
]

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
| `parentConditional` | `FASTTExpression` | `condition` | `FASTTWithCondition` | Optional condition statement/expression where this expression is used|
2626
| `parentDefaultParameterValue` | `FASTPyExpression` | `defaultValue` | `FASTPyParameter` | |
2727
| `parentExceptClause` | `FASTPyExpression` | `expressions` | `FASTPyExceptClause` | |
28+
| `parentExecStatementScopes` | `FASTPyExpression` | `scopes` | `FASTPyExecStatement` | |
2829
| `parentExpression` | `FASTTExpression` | `expression` | `FASTTUnaryExpression` | Parent (unary) expression|
2930
| `parentExpressionLeft` | `FASTTExpression` | `leftOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am left side|
3031
| `parentExpressionRight` | `FASTTExpression` | `rightOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am right side|
@@ -77,6 +78,7 @@ Class {
7778
'#parentComprehensionForClause => FMOne type: #FASTPyComprehension opposite: #forClauses',
7879
'#parentDefaultParameterValue => FMOne type: #FASTPyParameter opposite: #defaultValue',
7980
'#parentExceptClause => FMOne type: #FASTPyExceptClause opposite: #expressions',
81+
'#parentExecStatementScopes => FMOne type: #FASTPyExecStatement opposite: #scopes',
8082
'#parentForStatementLeft => FMOne type: #FASTPyForStatement opposite: #right',
8183
'#parentForStatementRight => FMOne type: #FASTPyForStatement opposite: #left',
8284
'#parentIfClause => FMOne type: #FASTPyIfClause opposite: #expression',
@@ -488,6 +490,29 @@ FASTPyExpression >> parentExceptClauseGroup [
488490
^ MooseSpecializedGroup with: self parentExceptClause
489491
]
490492

493+
{ #category : 'accessing' }
494+
FASTPyExpression >> parentExecStatementScopes [
495+
"Relation named: #parentExecStatementScopes type: #FASTPyExecStatement opposite: #scopes"
496+
497+
<generated>
498+
<container>
499+
^ parentExecStatementScopes
500+
]
501+
502+
{ #category : 'accessing' }
503+
FASTPyExpression >> parentExecStatementScopes: anObject [
504+
505+
<generated>
506+
parentExecStatementScopes := anObject
507+
]
508+
509+
{ #category : 'navigation' }
510+
FASTPyExpression >> parentExecStatementScopesGroup [
511+
<generated>
512+
<navigation: 'ParentExecStatementScopes'>
513+
^ MooseSpecializedGroup with: self parentExecStatementScopes
514+
]
515+
491516
{ #category : 'accessing' }
492517
FASTPyExpression >> parentForStatementLeft [
493518
"Relation named: #parentForStatementLeft type: #FASTPyForStatement opposite: #right"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
| `parentClassDefinition` | `FASTPyTSuperclass` | `superclasses` | `FASTPyClassDefinition` | |
1414
| `parentDeclarator` | `FASTPyTDecoratorExpression` | `expression` | `FASTPyDecorator` | |
1515
| `parentDeleteStatement` | `FASTPyTDeletable` | `expression` | `FASTPyDeleteStatement` | The delete statement that own the expression (if it's the case)|
16+
| `parentExecStatement` | `FASTPyTExecutable` | `code` | `FASTPyExecStatement` | |
1617
| `parentRaiseStatement` | `FASTPyTRaised` | `exception` | `FASTPyRaiseStatement` | |
1718
| `parentSplat` | `FASTPyTSplatExpression` | `expression` | `FASTPySplat` | |
1819
| `parentSplatParameter` | `FASTPyTSplatParameterTarget` | `target` | `FASTPySplatParameter` | |

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
| `expressionStatementOwner` | `FASTTExpression` | `expression` | `FASTTExpressionStatement` | The expression statement that own me (if it's the case|
1111
| `parentConcatenatedString` | `FASTPyString` | `strings` | `FASTPyConcatenatedString` | |
1212
| `parentConditional` | `FASTTExpression` | `condition` | `FASTTWithCondition` | Optional condition statement/expression where this expression is used|
13+
| `parentExecStatement` | `FASTPyTExecutable` | `code` | `FASTPyExecStatement` | |
1314
| `parentExpression` | `FASTTExpression` | `expression` | `FASTTUnaryExpression` | Parent (unary) expression|
1415
| `parentExpressionLeft` | `FASTTExpression` | `leftOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am left side|
1516
| `parentExpressionRight` | `FASTTExpression` | `rightOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am right side|
@@ -35,8 +36,8 @@
3536
Class {
3637
#name : 'FASTPyString',
3738
#superclass : 'FASTPyLiteral',
38-
#traits : 'FASTPyTSplatExpression + FASTTStringLiteral',
39-
#classTraits : 'FASTPyTSplatExpression classTrait + FASTTStringLiteral classTrait',
39+
#traits : 'FASTPyTExecutable + FASTPyTSplatExpression + FASTTStringLiteral',
40+
#classTraits : 'FASTPyTExecutable classTrait + FASTPyTSplatExpression classTrait + FASTTStringLiteral classTrait',
4041
#instVars : [
4142
'#interpolations => FMMany type: #FASTPyInterpolation opposite: #parentString',
4243
'#parentConcatenatedString => FMOne type: #FASTPyConcatenatedString opposite: #strings'

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
| `parentClassDefinition` | `FASTPyTSuperclass` | `superclasses` | `FASTPyClassDefinition` | |
1414
| `parentDeclarator` | `FASTPyTDecoratorExpression` | `expression` | `FASTPyDecorator` | |
1515
| `parentDeleteStatement` | `FASTPyTDeletable` | `expression` | `FASTPyDeleteStatement` | The delete statement that own the expression (if it's the case)|
16+
| `parentExecStatement` | `FASTPyTExecutable` | `code` | `FASTPyExecStatement` | |
1617
| `parentRaiseStatement` | `FASTPyTRaised` | `exception` | `FASTPyRaiseStatement` | |
1718
| `parentSplat` | `FASTPyTSplatExpression` | `expression` | `FASTPySplat` | |
1819
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
"
2+
I represent something that can be executed by an exec statement
3+
4+
## Relations
5+
======================
6+
7+
### Parents
8+
| Relation | Origin | Opposite | Type | Comment |
9+
|---|
10+
| `parentExecStatement` | `FASTPyTExecutable` | `code` | `FASTPyExecStatement` | |
11+
12+
13+
14+
"
15+
Trait {
16+
#name : 'FASTPyTExecutable',
17+
#instVars : [
18+
'#parentExecStatement => FMOne type: #FASTPyExecStatement opposite: #code'
19+
],
20+
#category : 'FAST-Python-Model-Traits',
21+
#package : 'FAST-Python-Model',
22+
#tag : 'Traits'
23+
}
24+
25+
{ #category : 'meta' }
26+
FASTPyTExecutable classSide >> annotation [
27+
28+
<FMClass: #TExecutable super: #Object>
29+
<package: #'FAST-Python-Model'>
30+
<generated>
31+
^ self
32+
]
33+
34+
{ #category : 'accessing' }
35+
FASTPyTExecutable >> parentExecStatement [
36+
"Relation named: #parentExecStatement type: #FASTPyExecStatement opposite: #code"
37+
38+
<generated>
39+
<container>
40+
<derived>
41+
^ parentExecStatement
42+
]
43+
44+
{ #category : 'accessing' }
45+
FASTPyTExecutable >> parentExecStatement: anObject [
46+
47+
<generated>
48+
parentExecStatement := anObject
49+
]
50+
51+
{ #category : 'navigation' }
52+
FASTPyTExecutable >> parentExecStatementGroup [
53+
<generated>
54+
<navigation: 'ParentExecStatement'>
55+
^ MooseSpecializedGroup with: self parentExecStatement
56+
]

0 commit comments

Comments
 (0)