@@ -154,7 +154,9 @@ Class {
154154 ' tDefinition' ,
155155 ' tDecoratorExpression' ,
156156 ' tWithElseClause' ,
157- ' tWithComment'
157+ ' tWithComment' ,
158+ ' collectionSplat' ,
159+ ' tCanBeSplatExpression'
158160 ],
159161 #category : ' FAST-Python-Model-Generator' ,
160162 #package : ' FAST-Python-Model-Generator'
@@ -203,6 +205,7 @@ FASTPythonMetamodelGenerator >> defineClasses [
203205 classDefinition withTesting.
204206 classPattern := builder ensureClassNamed: #ClassPattern ." Todo"
205207 collectionInitializer := builder ensureClassNamed: #CollectionInitializer .
208+ (collectionSplat := builder ensureClassNamed: #CollectionSplat ) comment: ' In Python a collection (list or dictionary) splat is the unpacking of a collection in a call or in the definition of another definition like `[ *list , 4 ]` or `func(*list)`' .
206209 comment := builder ensureClassNamed: #Comment ." Todo"
207210 comparisonOperator := builder ensureClassNamed: #ComparisonOperator .
208211 complex := builder ensureClassNamed: #Complex .
@@ -314,7 +317,6 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
314317
315318 entity -- | > tEntity.
316319 self flag: #todo . " The next two line are WRONG and NEEDS to be reviewed but we currently need it because else everything will break until the MM is in a better state."
317- entity -- | > tExpression.
318320 entity -- | > tStatement.
319321 entity -- | > tWithComment.
320322
@@ -327,16 +329,19 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
327329
328330 attribute -- | > expression.
329331 attribute -- | > tDecoratorExpression.
332+ attribute -- | > tCanBeSplatExpression.
330333
331334 await -- | > tStatement.
332335
333336 binaryOperator -- | > operator.
334337 binaryOperator -- | > tBinaryExpression.
338+ binaryOperator -- | > tCanBeSplatExpression.
335339
336340 block -- | > tStatementBlock.
337341
338342 booleanOperator -- | > operator.
339343 booleanOperator -- | > tBinaryExpression. " I am not 100% sure this is the best trait to use but it seems to work well for now"
344+ booleanOperator -- | > tCanBeSplatExpression.
340345
341346 boolean -- | > literal.
342347 boolean -- | > tBooleanLiteral.
@@ -346,11 +351,14 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
346351 call -- | > expression.
347352 call -- | > tInvocation.
348353 call -- | > tDecoratorExpression.
354+ call -- | > tCanBeSplatExpression.
349355
350356 classDefinition -- | > tNamedBehaviouralEntity.
351357 classDefinition -- | > tDefinition.
352358
353359 collectionInitializer -- | > expression.
360+
361+ collectionSplat -- | > expression.
354362
355363 comment -- | > tComment.
356364
@@ -369,9 +377,12 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
369377 deleteStatement -- | > statement.
370378
371379 dictionary -- | > collectionInitializer.
380+ dictionary -- | > tCanBeSplatExpression.
372381
373382 dictionaryComprehension -- | > expression.
374383 dictionaryComprehension -- | > tComprehension.
384+
385+ dictionarySplat -- | > collectionSplat.
375386
376387 elseClause -- | > block.
377388
@@ -404,6 +415,7 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
404415
405416 identifier -- | > expression.
406417 identifier -- | > tDecoratorExpression.
418+ identifier -- | > tCanBeSplatExpression.
407419
408420 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)"
409421
@@ -432,6 +444,8 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
432444 listComprehension -- | > expression.
433445 listComprehension -- | > tComprehension.
434446
447+ listSplat -- | > collectionSplat.
448+
435449 literal -- | > expression.
436450 literal -- | > tLiteral.
437451
@@ -479,6 +493,9 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
479493
480494 subscript -- | > expression.
481495 subscript -- | > tDecoratorExpression.
496+ subscript -- | > tCanBeSplatExpression.
497+
498+ tComprehension -- | > tCanBeSplatExpression.
482499
483500 thenClause -- | > block.
484501
@@ -548,6 +565,8 @@ FASTPythonMetamodelGenerator >> defineRelations [
548565
549566 ((collectionInitializer property: #initializers ) comment: ' Each initializer defines one element.' )
550567 <> -* ((expression property: #collectionInitializer ) comment: ' The owner of the expression' ).
568+
569+ (collectionSplat property: #expression ) <> - (tCanBeSplatExpression property: #parentSplat ).
551570
552571 ((comparisonOperator property: #operands ) comment:
553572 ' List of the operands of the comparison operands. For example if we have `a == b != c`, it will be a, b and c.' )
@@ -640,13 +659,20 @@ FASTPythonMetamodelGenerator >> defineRelations [
640659{ #category : ' definition' }
641660FASTPythonMetamodelGenerator >> defineTraits [
642661
643- super defineTraits. " Entity"
644- tEntity := self remoteTrait: #TEntity withPrefix: #FAST . " FAST-Python"
662+ super defineTraits.
663+
664+ " Entity"
665+ tEntity := self remoteTrait: #TEntity withPrefix: #FAST .
666+
667+ " FAST-Python"
668+ tCanBeSplatExpression := (builder newTraitNamed: #TCanBeSplatExpression ) comment: ' My users are expressions that can be in a collection splat. For example in `[ *getList(), 3 ]`, we have a list splat on the call `getList()`. Get list, is the expression of the splat.' .
645669 tComprehension := builder newTraitNamed: #TComprehension .
646670 tDefinition := builder newTraitNamed: #TDefinition .
647671 (tDecoratorExpression := builder newTraitNamed: #TDecoratorExpression ) comment: ' I represent an entity that *can* be the expression of a decorator.' .
648672 tUnaryOperator := builder newTraitNamed: #TUnaryOperator .
649- tWithElseClause := builder newTraitNamed: #TWithElseClause . " Remotes"
673+ tWithElseClause := builder newTraitNamed: #TWithElseClause .
674+
675+ " Remotes"
650676 tAssignment := self remoteTrait: #TAssignment withPrefix: #FAST .
651677 tBinaryExpression := self remoteTrait: #TBinaryExpression withPrefix: #FAST .
652678 tBooleanLiteral := self remoteTrait: #TBooleanLiteral withPrefix: #FAST .
0 commit comments