Skip to content

Commit ac7f41c

Browse files
committed
Manage chevron
1 parent 0915dd2 commit ac7f41c

6 files changed

Lines changed: 173 additions & 1 deletion

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,8 @@ FASTPythonMetamodelGenerator >> defineRelations [
634634

635635
(caseClause property: #pattern) <>-(tPattern property: #parentCaseClause).
636636

637+
(chevron property: #expression) <>- (expression property: #parentChevron).
638+
637639
(classPattern property: #elements) <>-* (tClassPatternElement property: #parentClassPattern).
638640

639641
((collectionInitializer property: #initializers) comment: 'Each initializer defines one element.')
@@ -711,6 +713,8 @@ FASTPythonMetamodelGenerator >> defineRelations [
711713

712714
(printStatement property: #expressions) <>-* (expression property: #prarentPrintStatement).
713715

716+
(printStatement property: #redirection) <>- (chevron property: #parentPrintStatement).
717+
714718
(raiseStatement property: #exception) <>- (tRaised property: #parentRaiseStatement).
715719

716720
((slice property: #components) comment: 'The components are the expressions between the `:` of a slice.')

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

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
1+
"
2+
## Relations
3+
======================
4+
5+
### Parents
6+
| Relation | Origin | Opposite | Type | Comment |
7+
|---|
8+
| `parentPrintStatement` | `FASTPyChevron` | `redirection` | `FASTPyPrintStatement` | |
9+
10+
### Children
11+
| Relation | Origin | Opposite | Type | Comment |
12+
|---|
13+
| `expression` | `FASTPyChevron` | `parentChevron` | `FASTPyExpression` | |
14+
15+
16+
17+
"
118
Class {
219
#name : 'FASTPyChevron',
320
#superclass : 'FASTPyEntity',
21+
#instVars : [
22+
'#expression => FMOne type: #FASTPyExpression opposite: #parentChevron',
23+
'#parentPrintStatement => FMOne type: #FASTPyPrintStatement opposite: #redirection'
24+
],
425
#category : 'FAST-Python-Model-Entities',
526
#package : 'FAST-Python-Model',
627
#tag : 'Entities'
@@ -14,3 +35,49 @@ FASTPyChevron class >> annotation [
1435
<generated>
1536
^ self
1637
]
38+
39+
{ #category : 'accessing' }
40+
FASTPyChevron >> expression [
41+
"Relation named: #expression type: #FASTPyExpression opposite: #parentChevron"
42+
43+
<generated>
44+
^ expression
45+
]
46+
47+
{ #category : 'accessing' }
48+
FASTPyChevron >> expression: anObject [
49+
50+
<generated>
51+
expression := anObject
52+
]
53+
54+
{ #category : 'navigation' }
55+
FASTPyChevron >> expressionGroup [
56+
<generated>
57+
<navigation: 'Expression'>
58+
^ MooseSpecializedGroup with: self expression
59+
]
60+
61+
{ #category : 'accessing' }
62+
FASTPyChevron >> parentPrintStatement [
63+
"Relation named: #parentPrintStatement type: #FASTPyPrintStatement opposite: #redirection"
64+
65+
<generated>
66+
<container>
67+
<derived>
68+
^ parentPrintStatement
69+
]
70+
71+
{ #category : 'accessing' }
72+
FASTPyChevron >> parentPrintStatement: anObject [
73+
74+
<generated>
75+
parentPrintStatement := anObject
76+
]
77+
78+
{ #category : 'navigation' }
79+
FASTPyChevron >> parentPrintStatementGroup [
80+
<generated>
81+
<navigation: 'ParentPrintStatement'>
82+
^ MooseSpecializedGroup with: self parentPrintStatement
83+
]

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
| `parentAssertStatement` | `FASTPyExpression` | `expressions` | `FASTPyAssertStatement` | The assert statement that own the expression (if it's the case)|
2828
| `parentAssignmentRight` | `FASTPyExpression` | `right` | `FASTPyAssignment` | |
2929
| `parentAwait` | `FASTPyExpression` | `expression` | `FASTPyAwait` | |
30+
| `parentChevron` | `FASTPyExpression` | `expression` | `FASTPyChevron` | |
3031
| `parentComparisonOperator` | `FASTPyExpression` | `operands` | `FASTPyComparisonOperator` | Parent comparison expression of which I am.|
3132
| `parentConditional` | `FASTTExpression` | `condition` | `FASTTWithCondition` | Optional condition statement/expression where this expression is used|
3233
| `parentDefaultParameterValue` | `FASTPyExpression` | `defaultValue` | `FASTPyParameter` | |
@@ -79,6 +80,7 @@ Class {
7980
'#parentAssertStatement => FMOne type: #FASTPyAssertStatement opposite: #expressions',
8081
'#parentAssignmentRight => FMOne type: #FASTPyAssignment opposite: #right',
8182
'#parentAwait => FMOne type: #FASTPyAwait opposite: #expression',
83+
'#parentChevron => FMOne type: #FASTPyChevron opposite: #expression',
8284
'#parentComparisonOperator => FMOne type: #FASTPyComparisonOperator opposite: #operands',
8385
'#parentDefaultParameterValue => FMOne type: #FASTPyParameter opposite: #defaultValue',
8486
'#parentExceptClause => FMOne type: #FASTPyExceptClause opposite: #expressions',
@@ -565,6 +567,30 @@ FASTPyExpression >> parentAwaitGroup [
565567
^ MooseSpecializedGroup with: self parentAwait
566568
]
567569

570+
{ #category : 'accessing' }
571+
FASTPyExpression >> parentChevron [
572+
"Relation named: #parentChevron type: #FASTPyChevron opposite: #expression"
573+
574+
<generated>
575+
<container>
576+
<derived>
577+
^ parentChevron
578+
]
579+
580+
{ #category : 'accessing' }
581+
FASTPyExpression >> parentChevron: anObject [
582+
583+
<generated>
584+
parentChevron := anObject
585+
]
586+
587+
{ #category : 'navigation' }
588+
FASTPyExpression >> parentChevronGroup [
589+
<generated>
590+
<navigation: 'ParentChevron'>
591+
^ MooseSpecializedGroup with: self parentChevron
592+
]
593+
568594
{ #category : 'accessing' }
569595
FASTPyExpression >> parentComparisonOperator [
570596
"Relation named: #parentComparisonOperator type: #FASTPyComparisonOperator opposite: #operands"

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
| Relation | Origin | Opposite | Type | Comment |
77
|---|
88
| `expressions` | `FASTPyPrintStatement` | `prarentPrintStatement` | `FASTPyExpression` | |
9+
| `redirection` | `FASTPyPrintStatement` | `parentPrintStatement` | `FASTPyChevron` | |
910
1011
1112
@@ -14,7 +15,8 @@ Class {
1415
#name : 'FASTPyPrintStatement',
1516
#superclass : 'FASTPyStatement',
1617
#instVars : [
17-
'#expressions => FMMany type: #FASTPyExpression opposite: #prarentPrintStatement'
18+
'#expressions => FMMany type: #FASTPyExpression opposite: #prarentPrintStatement',
19+
'#redirection => FMOne type: #FASTPyChevron opposite: #parentPrintStatement'
1820
],
1921
#category : 'FAST-Python-Model-Entities',
2022
#package : 'FAST-Python-Model',
@@ -58,3 +60,25 @@ FASTPyPrintStatement >> expressionsGroup [
5860
<navigation: 'Expressions'>
5961
^ MooseSpecializedGroup withAll: self expressions asSet
6062
]
63+
64+
{ #category : 'accessing' }
65+
FASTPyPrintStatement >> redirection [
66+
"Relation named: #redirection type: #FASTPyChevron opposite: #parentPrintStatement"
67+
68+
<generated>
69+
^ redirection
70+
]
71+
72+
{ #category : 'accessing' }
73+
FASTPyPrintStatement >> redirection: anObject [
74+
75+
<generated>
76+
redirection := anObject
77+
]
78+
79+
{ #category : 'navigation' }
80+
FASTPyPrintStatement >> redirectionGroup [
81+
<generated>
82+
<navigation: 'Redirection'>
83+
^ MooseSpecializedGroup with: self redirection
84+
]

‎src/FAST-Python-Tools-Tests/FASTPythonImporterTest.class.st‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18294,6 +18294,49 @@ FASTPythonImporterTest >> testPrintStatement [
1829418294
self assert: (self topEntity isOfType: FASTTNumericalLiteral)
1829518295
]
1829618296

18297+
{ #category : 'tests - statements' }
18298+
FASTPythonImporterTest >> testPrintStatmentWithChevron [
18299+
<generated>
18300+
"Generated as regression test by FASTPyImporterTestGenerator>>#generateTestNamed:fromCode:protocol:
18301+
Regenerate executing: self regenerateTest: #testPrintStatmentWithChevron "
18302+
18303+
self parse: 'print >> file_object, "message"'.
18304+
18305+
self assert: (fast allWithType: FASTPyChevron) size equals: 1.
18306+
self assert: (fast allWithType: FASTPyIdentifier) size equals: 1.
18307+
self assert: (fast allWithType: FASTPyModule) size equals: 1.
18308+
self assert: (fast allWithType: FASTPyPrintStatement) size equals: 1.
18309+
self assert: (fast allWithType: FASTPyString) size equals: 1.
18310+
18311+
stack push: fast rootEntities anyOne containedEntities first.
18312+
self assert: self topEntity sourceCode equals: 'print >> file_object, "message"'.
18313+
self assert: (self topEntity isOfType: FASTPyPrintStatement).
18314+
18315+
"Testing value of multivalued relation expressions"
18316+
self assert: self topEntity expressions size equals: 1.
18317+
18318+
stack push: (stack top expressions at: 1).
18319+
self assert: self topEntity sourceCode equals: '"message"'.
18320+
self assert: (self topEntity isOfType: FASTPyString).
18321+
self assert: (self topEntity isOfType: FASTTLiteral).
18322+
self assert: (self topEntity isOfType: FASTTStringLiteral).
18323+
stack pop.
18324+
18325+
"Testing value of monovalue relation redirection"
18326+
self assert: self topEntity redirection isNotNil.
18327+
18328+
stack push: self topEntity redirection.
18329+
self assert: self topEntity sourceCode equals: '>> file_object'.
18330+
self assert: (self topEntity isOfType: FASTPyChevron).
18331+
18332+
"Testing value of monovalue relation expression"
18333+
self assert: self topEntity expression isNotNil.
18334+
18335+
stack push: self topEntity expression.
18336+
self assert: self topEntity sourceCode equals: 'file_object'.
18337+
self assert: (self topEntity isOfType: FASTPyIdentifier)
18338+
]
18339+
1829718340
{ #category : 'tests - raise statement' }
1829818341
FASTPythonImporterTest >> testRaise [
1829918342
<generated>

‎src/FAST-Python-Tools/TSFASTPythonImporter.class.st‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,14 @@ TSFASTPythonImporter >> visitCasePattern: aTSNode [
214214
^ self rawVisitChildren: aTSNode
215215
]
216216

217+
{ #category : 'visiting' }
218+
TSFASTPythonImporter >> visitChevron: aTSNode [
219+
220+
self onNextContextDo: [ :entry | entry aliasUnnamedFieldAs: #expression ].
221+
222+
^ self handleNode: aTSNode kind: FASTPyChevron parentBlock: [ :entity | self topFastEntity redirection: entity ]
223+
]
224+
217225
{ #category : 'visiting - alias' }
218226
TSFASTPythonImporter >> visitClassDefinition: aNode [
219227

0 commit comments

Comments
 (0)