diff --git a/src/main/kotlin/org/jetbrains/fortran/lang/parser/FortranParser.bnf b/src/main/kotlin/org/jetbrains/fortran/lang/parser/FortranParser.bnf index b6c64182..b9d5be69 100644 --- a/src/main/kotlin/org/jetbrains/fortran/lang/parser/FortranParser.bnf +++ b/src/main/kotlin/org/jetbrains/fortran/lang/parser/FortranParser.bnf @@ -611,7 +611,7 @@ assumed_size_spec ::= (explicit_shape_spec ',')* (expr ':')? '*' // R522 implied_shape_spec ::= (expr ':')? '*' // R523 -private intent_spec ::= in_ | out_ | inout_ +private intent_spec ::= (in_ out_) | inout_ | in_ | out_ // R524 access_stmt ::= label_decl? access_spec (('::')? <>)? { pin = 2; extends=specification_stmt } // R525 diff --git a/src/test/kotlin/org/jetbrains/fortran/lang/parsing/FortranParsingTest.kt b/src/test/kotlin/org/jetbrains/fortran/lang/parsing/FortranParsingTest.kt index 5d2eb952..31c681a6 100644 --- a/src/test/kotlin/org/jetbrains/fortran/lang/parsing/FortranParsingTest.kt +++ b/src/test/kotlin/org/jetbrains/fortran/lang/parsing/FortranParsingTest.kt @@ -93,6 +93,10 @@ class FortranParsingTest : FortranBaseParsingTestCase() { @Test fun testOOP() = doParsingTest(FortranTestDataFixture().navigationMetadata("OOP.f95")) + @Throws(Exception::class) + @Test + fun testIntent() = doParsingTest(FortranTestDataFixture().navigationMetadata("Intent.f95")) + @Throws(Exception::class) @Test fun testInterface() = doParsingTest(FortranTestDataFixture().navigationMetadata("Interface.f95")) diff --git a/src/test/resources/psi/Intent.f95 b/src/test/resources/psi/Intent.f95 new file mode 100644 index 00000000..e32c2c4e --- /dev/null +++ b/src/test/resources/psi/Intent.f95 @@ -0,0 +1,7 @@ +SUBROUTINE foo(a, b, c, d) + IMPLICIT NONE + INTEGER, INTENT(IN) :: a + INTEGER, INTENT(OUT) :: b + INTEGER, INTENT(INOUT) :: c + INTEGER, INTENT(IN OUT) :: d +END SUBROUTINE foo diff --git a/src/test/resources/psi/Intent.txt b/src/test/resources/psi/Intent.txt new file mode 100644 index 00000000..b907c76b --- /dev/null +++ b/src/test/resources/psi/Intent.txt @@ -0,0 +1,108 @@ +FILE + FortranSubroutineSubprogramImpl(SUBROUTINE) + FortranSubroutineStmtImpl(SUBROUTINE_STMT) + PsiElement(keyword)('SUBROUTINE') + PsiWhiteSpace(' ') + FortranEntityDeclImpl(ENTITY_DECL) + PsiElement(identifier)('foo') + PsiElement(()('(') + FortranDataPathImpl(DATA_PATH) + PsiElement(identifier)('a') + PsiElement(,)(',') + PsiWhiteSpace(' ') + FortranDataPathImpl(DATA_PATH) + PsiElement(identifier)('b') + PsiElement(,)(',') + PsiWhiteSpace(' ') + FortranDataPathImpl(DATA_PATH) + PsiElement(identifier)('c') + PsiElement(,)(',') + PsiWhiteSpace(' ') + FortranDataPathImpl(DATA_PATH) + PsiElement(identifier)('d') + PsiElement())(')') + PsiElement(eol)('\n') + PsiWhiteSpace(' ') + FortranBlockImpl(BLOCK) + IMPLICIT_STMT + PsiElement(keyword)('IMPLICIT') + PsiWhiteSpace(' ') + PsiElement(keyword)('NONE') + PsiElement(eol)('\n') + PsiWhiteSpace(' ') + FortranTypeDeclarationStmtImpl(TYPE_DECLARATION_STMT) + NUMBER_TYPE_SPEC + PsiElement(integer)('INTEGER') + PsiElement(,)(',') + PsiWhiteSpace(' ') + ATTR_SPEC + PsiElement(keyword)('INTENT') + PsiElement(()('(') + PsiElement(keyword)('IN') + PsiElement())(')') + PsiWhiteSpace(' ') + PsiElement(::)('::') + PsiWhiteSpace(' ') + FortranEntityDeclImpl(ENTITY_DECL) + PsiElement(identifier)('a') + PsiElement(eol)('\n') + PsiWhiteSpace(' ') + FortranTypeDeclarationStmtImpl(TYPE_DECLARATION_STMT) + NUMBER_TYPE_SPEC + PsiElement(integer)('INTEGER') + PsiElement(,)(',') + PsiWhiteSpace(' ') + ATTR_SPEC + PsiElement(keyword)('INTENT') + PsiElement(()('(') + PsiElement(keyword)('OUT') + PsiElement())(')') + PsiWhiteSpace(' ') + PsiElement(::)('::') + PsiWhiteSpace(' ') + FortranEntityDeclImpl(ENTITY_DECL) + PsiElement(identifier)('b') + PsiElement(eol)('\n') + PsiWhiteSpace(' ') + FortranTypeDeclarationStmtImpl(TYPE_DECLARATION_STMT) + NUMBER_TYPE_SPEC + PsiElement(integer)('INTEGER') + PsiElement(,)(',') + PsiWhiteSpace(' ') + ATTR_SPEC + PsiElement(keyword)('INTENT') + PsiElement(()('(') + PsiElement(keyword)('INOUT') + PsiElement())(')') + PsiWhiteSpace(' ') + PsiElement(::)('::') + PsiWhiteSpace(' ') + FortranEntityDeclImpl(ENTITY_DECL) + PsiElement(identifier)('c') + PsiElement(eol)('\n') + PsiWhiteSpace(' ') + FortranTypeDeclarationStmtImpl(TYPE_DECLARATION_STMT) + NUMBER_TYPE_SPEC + PsiElement(integer)('INTEGER') + PsiElement(,)(',') + PsiWhiteSpace(' ') + ATTR_SPEC + PsiElement(keyword)('INTENT') + PsiElement(()('(') + PsiElement(keyword)('IN') + PsiWhiteSpace(' ') + PsiElement(keyword)('OUT') + PsiElement())(')') + PsiWhiteSpace(' ') + PsiElement(::)('::') + PsiWhiteSpace(' ') + FortranEntityDeclImpl(ENTITY_DECL) + PsiElement(identifier)('d') + PsiElement(eol)('\n') + END_SUBROUTINE_STMT + PsiElement(keyword)('END') + PsiWhiteSpace(' ') + PsiElement(keyword)('SUBROUTINE') + PsiWhiteSpace(' ') + FortranDataPathImpl(DATA_PATH) + PsiElement(identifier)('foo') \ No newline at end of file