Skip to content

Commit d632af1

Browse files
committed
Start to add comments in the MM
1 parent 8e751c4 commit d632af1

23 files changed

Lines changed: 114 additions & 63 deletions

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

Lines changed: 70 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -181,39 +181,85 @@ FASTPythonMetamodelGenerator class >> submetamodels [
181181

182182
{ #category : 'definition' }
183183
FASTPythonMetamodelGenerator >> defineClasses [
184+
184185
super defineClasses.
185186
entity := builder newClassNamed: #Entity.
187+
186188
_ERROR := builder newClassNamed: #ERROR.
187-
asPattern := builder newClassNamed: #AsPattern.
188-
assertStatement := builder newClassNamed: #AssertStatement.
189-
assignment := builder newClassNamed: #Assignment.
190-
attribute := builder newClassNamed: #AttributeAccess.
191-
augmentedAssignment := builder newClassNamed: #AugmentedAssignment.
192-
await := builder newClassNamed: #Await.
189+
190+
(asPattern := builder newClassNamed: #AsPattern) comment:
191+
'I represent the aliasing of an expression in Python. When the expression can only be an identifier, I store it as a property named "alias" instead of instantiating an AsPattern node.'.
192+
193+
(assertStatement := builder newClassNamed: #AssertStatement) comment:
194+
'I represent an assert statement node in python. It hold a collection of expressions to assert.'.
195+
196+
(assignment := builder newClassNamed: #Assignment) comment:
197+
'I represent an assignment in Python (not to confuse with an augmented assignment or a wlrus assignment). My left value is the expression used to get the variable to assign. It can be typed optionally. My right side if the expression to store. It can be optional because I also represent a typed variable declaration.'.
198+
199+
(attribute := builder newClassNamed: #AttributeAccess) comment: 'I represent an access to an attribute such as `module.globalVariable`.'.
200+
201+
(augmentedAssignment := builder newClassNamed: #AugmentedAssignment) comment:
202+
'An augmented assignment is an assignment done using operands such as `+=` or `-=`. It is a specialization of normal assignments.'.
203+
204+
(await := builder newClassNamed: #Await) comment: 'I represent the usage of an await keyword in an asynchronous function definition'.
205+
193206
binaryOperator := builder newClassNamed: #BinaryOperator.
207+
194208
boolean := builder newClassNamed: #Boolean.
209+
195210
booleanOperator := builder newClassNamed: #BooleanOperator.
196-
breakStatement := builder newClassNamed: #BreakStatement.
197-
call := builder newClassNamed: #Call.
198-
caseClause := builder newClassNamed: #CaseClause.
199-
chevron := builder newClassNamed: #Chevron.
200-
classDefinition := builder newClassNamed: #ClassDefinition.
211+
212+
(breakStatement := builder newClassNamed: #BreakStatement) comment: 'I represent a break statement used to break loops.'.
213+
214+
(call := builder newClassNamed: #Call) comment: 'I represent a call in python. The call can represent multiple things such as:
215+
- a function invocation such as `flush(var)`
216+
- a method invocation such as `self.increment()`
217+
- a class instantiation such as Stack()'.
218+
219+
(caseClause := builder newClassNamed: #CaseClause) comment: 'I represent a case clause in a match statement in Python.'.
220+
221+
(chevron := builder newClassNamed: #Chevron) comment:
222+
'I am a node representing the `>>` part of a print statement. Print statement is only available in Python 2, not Python 3'.
223+
224+
(classDefinition := builder newClassNamed: #ClassDefinition) comment:
225+
'I represent a class definition. I have a name, a list of expressions to declare my superclasses, a list of keywords to customize the metaclass and a block of code.'.
201226
classDefinition withTesting.
202-
classPattern := builder newClassNamed: #ClassPattern.
203-
collectionInitializer := builder newClassNamed: #CollectionInitializer.
227+
228+
(classPattern := builder newClassNamed: #ClassPattern) comment: 'A class pattern is used in a case clause to match classes.'.
229+
230+
(collectionInitializer := builder newClassNamed: #CollectionInitializer) comment:
231+
'I am an abstract class to represent collection initializers in Python. I should be transformed into a trait to put in FAST directly.'.
232+
204233
comment := builder newClassNamed: #Comment.
234+
205235
comparisonOperator := builder newClassNamed: #ComparisonOperator.
206-
comprehension := builder newClassNamed: #Comprehension.
207-
complex := builder newClassNamed: #Complex.
236+
237+
(comprehension := builder newClassNamed: #Comprehension) comment:
238+
'I am an abstract class for comprehensions. Comprehensions are a structure in python to generate some collections or a generator.'.
239+
240+
(complex := builder newClassNamed: #Complex) comment: 'I represent a complex number such as `2j`'.
241+
208242
concatenatedString := builder newClassNamed: #ConcatenatedString.
209-
conditionalExpression := builder newClassNamed: #ConditionalExpression.
210-
constrainedType := builder newClassNamed: #ConstrainedType.
211-
continueStatement := builder newClassNamed: #ContinueStatement.
212-
decorator := builder newClassNamed: #Decorator.
213-
deleteStatement := builder newClassNamed: #DeleteStatement.
214-
dictionary := builder newClassNamed: #Dictionary.
243+
244+
(conditionalExpression := builder newClassNamed: #ConditionalExpression) comment: 'I represent a conditional expression such as `x if x > 2 else y`'.
245+
246+
(constrainedType := builder newClassNamed: #ConstrainedType) comment:
247+
'I represent the concretization of a generic type in a given context. For example: `def f[T: int](): pass`, we are here constraining `T` to be an `int` or a subclass of `int`'.
248+
249+
(continueStatement := builder newClassNamed: #ContinueStatement) comment: 'I represent a continue statement to use in loops.'.
250+
251+
(decorator := builder newClassNamed: #Decorator) comment:
252+
'I represent a decorator in Python. I can be applied to class, function or method definition using the `@` symbol.'.
253+
254+
(deleteStatement := builder newClassNamed: #DeleteStatement) comment: 'I represent a delete statement in Python.'.
255+
256+
(dictionary := builder newClassNamed: #Dictionary) comment:
257+
'I represent the initialization of a new dictionnary in Python. Each of my children should be instances of Pair.'.
258+
215259
dictionaryComprehension := builder newClassNamed: #DictionaryComprehension.
216-
dottedName := builder newClassNamed: #DottedName.
260+
261+
(dottedName := builder newClassNamed: #DottedName) comment: 'I have a syntax close to attribute accesses but I am used only in match statements.'.
262+
217263
elifClause := builder newClassNamed: #ElifClause.
218264
ellipsis := builder newClassNamed: #Ellipsis.
219265
elseClause := builder newClassNamed: #ElseClause.
@@ -269,7 +315,8 @@ FASTPythonMetamodelGenerator >> defineClasses [
269315
set := builder newClassNamed: #Set.
270316
setComprehension := builder newClassNamed: #SetComprehension.
271317
slice := builder newClassNamed: #Slice.
272-
(splat := builder newClassNamed: #Splat) 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)`'.
318+
(splat := builder newClassNamed: #Splat) comment:
319+
'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)`'.
273320
splatParameter := builder newClassNamed: #SplatParameter.
274321
splatType := builder newClassNamed: #SplatType.
275322
statement := builder newClassNamed: #Statement.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"
2+
I represent the aliasing of an expression in Python. When the expression can only be an identifier, I store it as a property named ""alias"" instead of instantiating an AsPattern node.
3+
24
## Relations
35
======================
46

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"
2+
I represent an assert statement node in python. It hold a collection of expressions to assert.
3+
24
## Relations
35
======================
46

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"
2+
I represent an assignment in Python (not to confuse with an augmented assignment or a wlrus assignment). My left value is the expression used to get the variable to assign. It can be typed optionally. My right side if the expression to store. It can be optional because I also represent a typed variable declaration.
3+
24
## Relations
35
======================
46

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"
2+
I represent an access to an attribute such as `module.globalVariable`.
3+
24
## Relations
35
======================
46

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"
2+
An augmented assignment is an assignment done using operands such as `+=` or `-=`. It is a specialization of normal assignments.
3+
24
## Properties
35
======================
46

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"
2+
I represent the usage of an await keyword in an asynchronous function definition
3+
24
## Relations
35
======================
46

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

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11
"
2-
## Relations
3-
======================
2+
I represent a break statement used to break loops.
43
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-
11-
12-
## Properties
13-
======================
14-
15-
| Name | Type | Default value | Comment |
16-
|---|
17-
| `endPos` | `Number` | nil | |
18-
| `startPos` | `Number` | nil | |
194
205
"
216
Class {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
"
2+
I represent a call in python. The call can represent multiple things such as:
3+
- a function invocation such as `flush(var)`
4+
- a method invocation such as `self.increment()`
5+
- a class instantiation such as Stack()
6+
27
## Relations
38
======================
49

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"
2+
I represent a case clause in a match statement in Python.
3+
24
## Relations
35
======================
46

0 commit comments

Comments
 (0)