Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update metamodel #264

Merged
merged 3 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ I am the super class of all Fortran expressions
| `assignementExpressionOwner` | `FASTFortranAbstractExpression` | `expression` | `FASTFortranFunctionStatement` | The AssignementExpression owner (if possible)|
| `expressionStatementOwner` | `FASTTExpression` | `expression` | `FASTTExpressionStatement` | The expression statement that own me (if it's the case|
| `ioSpecifier` | `FASTTExpression` | `expression` | `FASTFortranIOParameter` | name of the parameter (keyword argument)|
| `parentArrayDimensionDeclarator` | `FASTFortranAbstractExpression` | `upperBound` | `FASTFortranArrayRange` | Parent array dimension declarator|
| `parentArrayDimensionDeclarator` | `FASTFortranAbstractExpression` | `lowerBound` | `FASTFortranArrayRange` | Parent array dimension declarator|
| `parentArrayDimensionDeclarator` | `FASTFortranAbstractExpression` | `upperBound` | `FASTFortranArrayRange` | Parent array dimension declarator|
| `parentArrayExpression` | `FASTFortranAbstractExpression` | `indices` | `FASTFortranArrayVariable` | an ArrayVariable expression of which I am an indice|
| `parentConditionalStatement` | `FASTFortranAbstractExpression` | `condition` | `FASTFortranConditionalStatement` | Parent conditional statement (if-block, if-logical, ...)|
| `parentDataStatement` | `FASTFortranAbstractExpression` | `dataConstants` | `FASTFortranDataGroup` | |
Expand Down
23 changes: 2 additions & 21 deletions src/FAST-Fortran-Entities/FASTFortranComment.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,15 @@ A fortran comment
| Name | Type | Default value | Comment |
|---|
| `content` | `String` | nil | Content of the comment as a String|
| `content` | `String` | nil | Determines a content of a comment|
| `endPos` | `Number` | nil | |
| `startPos` | `Number` | nil | |

"
Class {
#name : 'FASTFortranComment',
#superclass : 'FASTFortranEntity',
#superclass : 'FASTFortranAbstractStatement',
#traits : 'FASTTComment + FASTTEntity',
#classTraits : 'FASTTComment classTrait + FASTTEntity classTrait',
#instVars : [
'#content => FMProperty'
],
#category : 'FAST-Fortran-Entities-Entities',
#package : 'FAST-Fortran-Entities',
#tag : 'Entities'
Expand All @@ -37,23 +33,8 @@ Class {
{ #category : 'meta' }
FASTFortranComment class >> annotation [

<FMClass: #Comment super: #FASTFortranEntity>
<FMClass: #Comment super: #FASTFortranAbstractStatement>
<package: #'FAST-Fortran-Entities'>
<generated>
^ self
]

{ #category : 'accessing' }
FASTFortranComment >> content [

<FMProperty: #content type: #String>
<generated>
<FMComment: 'Determines a content of a comment'>
^ content
]

{ #category : 'accessing' }
FASTFortranComment >> content: anObject [
<generated>
content := anObject
]
4 changes: 1 addition & 3 deletions src/FAST-Fortran-Generator/FASTFortranGenerator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ FASTFortranGenerator >> defineHierarchy [
"other entities"
comment --|> tEntity.
comment --|> tComment.
comment --|> abstractStatement.

"FORTRAN STATEMENTS"
abstractStatement --|> tStatement.
Expand Down Expand Up @@ -631,9 +632,6 @@ FASTFortranGenerator >> defineProperties [
(callStatement property: #name type: #String) comment:
'Name of called entity (a subroutine)'.

(comment property: #content type: #String) comment:
'Determines a content of a comment'.

(formatStatement property: #formatDescription type: #String).

(functionCall property: #name type: #String) comment:
Expand Down
25 changes: 12 additions & 13 deletions src/FAST-Fortran-Visitors-Tests/FortranToFASTTests.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ C comment in a function''s body
jsonCode := '{"meta":{"miVersion":"fortran77","miFilename":"fortran77.f"},"program_units":[{"anno":[],"arguments":null,"blocks":[{"anno":[],"comment":" comment in a function''s body","span":"(2:1)-(2:30)","tag":"comment"}],"name":"afct","result":null,"span":"(1:7)-(3:9)","subprograms":null,"tag":"function","type":{"anno":[],"base_type":"integer","selector":null,"span":"(1:7)-(1:13)"}}]}'.
result := self visitJsonCode.

cmt := result first statementBlock comments anyOne.
cmt := result first statementBlock statements anyOne.
self assert: cmt content equals: 'C comment in a function''s body'.
self assert: cmt startPos equals: 31.
self assert: cmt endPos equals: 60.
Expand Down Expand Up @@ -1461,11 +1461,10 @@ C comment in loop
stmt := result first statementBlock statements first.
self assert: stmt class equals: FASTFortranDoStatement.
self assert: stmt loopControl isNotNil.
self assert: stmt statementBlock statements isEmpty.
self assert: stmt statementBlock statements size equals: 1.
self assert: stmt statementBlock statements anyOne class equals: FASTFortranComment.
self assert: stmt startPos equals: 26.
self assert: stmt endPos equals: 67.

self assert: stmt statementBlock comments size equals: 1.
]

{ #category : 'tests-statement' }
Expand Down Expand Up @@ -2080,8 +2079,8 @@ C comment in else part
conditional := result first statementBlock statements first.
self assert: conditional class equals: FASTFortranIfBlockStatement.
self assert: conditional thenStatementBlock statements isEmpty.
self assert: conditional elseStatementBlock statements isEmpty.
self assert: conditional elseStatementBlock comments size equals: 1.
self assert: conditional elseStatementBlock statements size equals: 1.
self assert: conditional elseStatementBlock statements anyOne class equals: FASTFortranComment.
]

{ #category : 'tests-statement' }
Expand Down Expand Up @@ -2145,8 +2144,8 @@ C comment in then part

conditional := result first statementBlock statements first.
self assert: conditional class equals: FASTFortranIfBlockStatement.
self assert: conditional thenStatementBlock statements isEmpty.
self assert: conditional thenStatementBlock comments size equals: 1.
self assert: conditional thenStatementBlock statements size equals: 1.
self assert: conditional thenStatementBlock statements anyOne class equals: FASTFortranComment.
self assert: conditional thenStatementBlock startPos equals: 43.
self assert: conditional thenStatementBlock endPos equals: 64.

Expand Down Expand Up @@ -2607,12 +2606,12 @@ c23456789 123456789 123456789 123456789 123456789 123456789 12

body := result first statementBlock.
self assert: body statements isCollection.
self assert: body statements size equals: 1.
self assert: body statements size equals: 2.

self assert: body statements first class equals: FASTFortranImplicitStatement.

self assert: body comments size equals: 1.
self assert: body comments first class equals: FASTFortranComment.
self assert: body comments first content equals: 'C23456789 123456789 123456789 123456789 123456789 123456789 12'.

self assert: body statements second class equals: FASTFortranComment.
self assert: body statements second content equals: 'C23456789 123456789 123456789 123456789 123456789 123456789 12'.
]

{ #category : 'tests-programUnit' }
Expand Down