From ea932a7f0264a48afa661c0a3f5094837ba06866 Mon Sep 17 00:00:00 2001 From: uNouss Date: Thu, 20 Feb 2025 10:20:25 +0100 Subject: [PATCH 1/3] make comment behave as abstractStatement --- src/FAST-Fortran-Generator/FASTFortranGenerator.class.st | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/FAST-Fortran-Generator/FASTFortranGenerator.class.st b/src/FAST-Fortran-Generator/FASTFortranGenerator.class.st index c784bcf..5c0eee1 100644 --- a/src/FAST-Fortran-Generator/FASTFortranGenerator.class.st +++ b/src/FAST-Fortran-Generator/FASTFortranGenerator.class.st @@ -472,6 +472,7 @@ FASTFortranGenerator >> defineHierarchy [ "other entities" comment --|> tEntity. comment --|> tComment. + comment --|> abstractStatement. "FORTRAN STATEMENTS" abstractStatement --|> tStatement. @@ -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: From c06db55c020b59e26a1d30fccd74b2cae9b11246 Mon Sep 17 00:00:00 2001 From: uNouss Date: Thu, 20 Feb 2025 10:23:37 +0100 Subject: [PATCH 2/3] regenerate entities after changing the metamodel (previous commit) --- .../FASTFortranAbstractExpression.class.st | 2 +- .../FASTFortranComment.class.st | 23 ++----------------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/FAST-Fortran-Entities/FASTFortranAbstractExpression.class.st b/src/FAST-Fortran-Entities/FASTFortranAbstractExpression.class.st index 790f0af..e5b7e27 100644 --- a/src/FAST-Fortran-Entities/FASTFortranAbstractExpression.class.st +++ b/src/FAST-Fortran-Entities/FASTFortranAbstractExpression.class.st @@ -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` | | diff --git a/src/FAST-Fortran-Entities/FASTFortranComment.class.st b/src/FAST-Fortran-Entities/FASTFortranComment.class.st index ea030c7..3cc419b 100644 --- a/src/FAST-Fortran-Entities/FASTFortranComment.class.st +++ b/src/FAST-Fortran-Entities/FASTFortranComment.class.st @@ -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' @@ -37,23 +33,8 @@ Class { { #category : 'meta' } FASTFortranComment class >> annotation [ - + ^ self ] - -{ #category : 'accessing' } -FASTFortranComment >> content [ - - - - - ^ content -] - -{ #category : 'accessing' } -FASTFortranComment >> content: anObject [ - - content := anObject -] From 79fd8d881b161357a95a08eddc7a6c8edfdc60e3 Mon Sep 17 00:00:00 2001 From: uNouss Date: Thu, 20 Feb 2025 10:56:44 +0100 Subject: [PATCH 3/3] correct the tests --- .../FortranToFASTTests.class.st | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/FAST-Fortran-Visitors-Tests/FortranToFASTTests.class.st b/src/FAST-Fortran-Visitors-Tests/FortranToFASTTests.class.st index 628467d..bf506c2 100644 --- a/src/FAST-Fortran-Visitors-Tests/FortranToFASTTests.class.st +++ b/src/FAST-Fortran-Visitors-Tests/FortranToFASTTests.class.st @@ -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. @@ -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' } @@ -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' } @@ -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. @@ -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' }