@@ -111,8 +111,6 @@ Class {
111111 ' unionPattern' ,
112112 ' unionType' ,
113113 ' whileStatement' ,
114- ' withClause' ,
115- ' withItem' ,
116114 ' withStatement' ,
117115 ' yield' ,
118116 ' tComment' ,
@@ -155,7 +153,10 @@ Class {
155153 ' tWithElseClause' ,
156154 ' tWithComment' ,
157155 ' collectionSplat' ,
158- ' tCanBeSplatExpression'
156+ ' tCanBeSplatExpression' ,
157+ ' tAsPatternTarget' ,
158+ ' tAsPatternSource' ,
159+ ' tWithStatementItem'
159160 ],
160161 #category : ' FAST-Python-Model-Generator' ,
161162 #package : ' FAST-Python-Model-Generator'
@@ -301,8 +302,6 @@ FASTPythonMetamodelGenerator >> defineClasses [
301302 unionType := builder ensureClassNamed: #UnionType ." Todo"
302303 variable := builder ensureClassNamed: #Variable . " To review"
303304 whileStatement := builder ensureClassNamed: #WhileStatement .
304- withClause := builder ensureClassNamed: #WithClause ." Todo"
305- withItem := builder ensureClassNamed: #WithItem ." Todo"
306305 withStatement := builder ensureClassNamed: #WithStatement ." Todo"
307306 yield := builder ensureClassNamed: #Yield " Todo"
308307]
@@ -319,6 +318,8 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
319318 " Adding a bunch of traits in errors to not interupt the parsing much if we have an error."
320319 _ERROR -- | > expression.
321320
321+ asPattern -- | > tWithStatementItem.
322+
322323 assignment -- | > statement.
323324 assignment -- | > tAssignment.
324325
@@ -351,6 +352,7 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
351352 call -- | > tInvocation.
352353 call -- | > tDecoratorExpression.
353354 call -- | > tCanBeSplatExpression.
355+ call -- | > tAsPatternSource.
354356
355357 classDefinition -- | > statement.
356358 classDefinition -- | > tDefinition.
@@ -415,6 +417,7 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
415417 identifier -- | > expression.
416418 identifier -- | > tDecoratorExpression.
417419 identifier -- | > tCanBeSplatExpression.
420+ identifier -- | > tAsPatternTarget.
418421
419422 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)"
420423
@@ -513,7 +516,8 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
513516 whileStatement -- | > tConditionalStatement.
514517 whileStatement -- | > tLoopStatement.
515518
516- withStatement -- | > statement
519+ withStatement -- | > statement.
520+ withStatement -- | > tStatementBlock
517521]
518522
519523{ #category : ' definition' }
@@ -549,16 +553,20 @@ FASTPythonMetamodelGenerator >> defineRelations [
549553
550554 (entity property: #genericChildren ) <> -* (entity property: #genericParent ).
551555
556+ (asPattern property: #target ) <> - (tAsPatternTarget property: #parentAsPatternTarget ).
557+
558+ (asPattern property: #source ) <> - (tAsPatternSource property: #parentAsPatternSource ).
559+
560+ ((assertStatement property: #expressions ) comment: ' The expressions asserted' )
561+ <> -* ((expression property: #parentAssertStatement ) comment: ' The assert statement that own the expression (if it' ' s the case)' ).
562+
552563 ((attribute property: #object ) comment:
553564 ' I am the receiver of the attribute. I can be multiple things such as a variable, a call, another attribute access, a primitive type, a subscript...' )
554565 <> - ((expression property: #attributeObjectOwner ) comment: ' My parent if I define the object of an attribute access (if it' ' s the case).' ).
555566
556567 ((attribute property: #attribute ) comment: ' The variable been accessed' )
557568 <> - ((variable property: #attributeOwner ) comment: ' The attribute access accessing me (if it' ' s the case)' ).
558569
559- ((assertStatement property: #expressions ) comment: ' The expressions asserted' )
560- <> -* ((expression property: #parentAssertStatement ) comment: ' The assert statement that own the expression (if it' ' s the case)' ).
561-
562570 (await property: #expression ) <> - (expression property: #parentAwait ).
563571
564572 ((call property: #callee ) comment:
@@ -567,13 +575,13 @@ FASTPythonMetamodelGenerator >> defineRelations [
567575
568576 ((collectionInitializer property: #initializers ) comment: ' Each initializer defines one element.' )
569577 <> -* ((expression property: #collectionInitializer ) comment: ' The owner of the expression' ).
570-
578+
571579 (collectionSplat property: #expression ) <> - (tCanBeSplatExpression property: #parentSplat ).
572580
573581 ((comparisonOperator property: #operands ) comment:
574582 ' List of the operands of the comparison operands. For example if we have `a == b != c`, it will be a, b and c.' )
575583 <> -* ((expression property: #parentComparisonOperator ) comment: ' Parent comparison expression of which I am.' ).
576-
584+
577585 (concatenatedString property: #strings ) <> -* (string property: #parentConcatenatedString ).
578586
579587 (conditionalExpression property: #thenExpression ) <> - (expression property: #conditionalExpressionThenOwner ).
@@ -627,7 +635,7 @@ FASTPythonMetamodelGenerator >> defineRelations [
627635 (pair property: #value ) <> - (tExpression property: #pairValueOwner ).
628636
629637 (patternList property: #elements ) <> -* (expression property: #patternListOwner ).
630-
638+
631639 (printStatement property: #expressions ) <> -* (expression property: #prarentPrintStatement ).
632640
633641 ((slice property: #components ) comment: ' The components are the expressions between the `:` of a slice.' )
@@ -652,7 +660,9 @@ FASTPythonMetamodelGenerator >> defineRelations [
652660 ((tUnaryOperator property: #argument ) comment: ' Expression influanced by the unary operator..' )
653661 <> - ((expression property: #parentUnaryOperator ) comment: ' Parent unary operator in which I am.' ).
654662
655- (tWithElseClause property: #elseClause ) <> - (elseClause property: #ifStatementOwner )
663+ (tWithElseClause property: #elseClause ) <> - (elseClause property: #ifStatementOwner ).
664+
665+ (withStatement property: #items ) <> -* (tWithStatementItem property: #parentWithClauseItem )
656666]
657667
658668{ #category : ' definition' }
@@ -664,11 +674,14 @@ FASTPythonMetamodelGenerator >> defineTraits [
664674 tEntity := self remoteTrait: #TEntity withPrefix: #FAST .
665675
666676 " FAST-Python"
677+ tAsPatternTarget := (builder newTraitNamed: #TAsPatternTarget ) comment: ' I represent an entity that could be the alias/target of an as pattern.' .
678+ tAsPatternSource := (builder newTraitNamed: #TAsPatternSource ) comment: ' I represent an entity that could be aliased in an as pattern.' .
667679 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.' .
668680 tComprehension := builder newTraitNamed: #TComprehension .
669681 tDefinition := builder newTraitNamed: #TDefinition .
670682 (tDecoratorExpression := builder newTraitNamed: #TDecoratorExpression ) comment: ' I represent an entity that *can* be the expression of a decorator.' .
671683 tUnaryOperator := builder newTraitNamed: #TUnaryOperator .
684+ tWithStatementItem := (builder newTraitNamed: #TWithStatementItem ) comment: ' I represent an entity that can be the item of a with_statement.' .
672685 tWithElseClause := builder newTraitNamed: #TWithElseClause .
673686
674687 " Remotes"
0 commit comments