Closed e-kwsm closed 1 year ago
Also, following are missing we should add:
I don’t have a planned ETA on when I will get to this since I’m pretty backlogged but if you could attach files showing these in use that would be a great start. If you want to take a crack at implementing it I’ll be happy to try and squeeze some time in for code review. Thanks!
@stadelmanma thank you for replying!
Last night, I read about tree-sitter, and tried to make changes.
At first, I want to treat submodules just like modules (this is simplest approach for getting the syntax highlighing correctly)
For example:
Module: Vector_Class.F90
MODULE Vector_Class
USE stmt
implicit none
private stmt
public stmt
!! header only
interface
module subroutine foo1( arg1, arg2)
real :: arg1
integer :: arg2
end subroutine foo1
end interface
public :: foo1
!! similarly goes the function
interface
module function foo2(arg1, arg3) results(ans)
integer :: arg1
real :: arg2
end function foo2
end interface
public :: foo2
END MODULE Vector_Class
As you can see, we have just declared the interface of methods.
We will provide interface in submodules. A module can have many submodules, I think this is called child.
But each submodule can have only a unique parent module.
Let us define two submodules, each implementing a method in module.
File: Vector_Class@foo1Methods.F90
submodule(Vector_Class) foo1Methods
contains
module procedure foo1
!! implementation
end module procedure foo1
end submodule foo1Methods
File: Vector_Class@foo2Methods.F90
submodule(Vector_Class) foo2Methods
contains
module procedure foo2
!! implementation
end module procedure foo2
end submodule foo2Methods
As you can see, foo1 and foo2 contains only the implementation.
So a submodule structure is as follows:
submodule(module_name) submodule_name
use stmt
implicit none
contains
implementation plus new routines
...
end submodule submodule_name
Regards Vikas
@stadelmanma I have created a PR, please check if possible.
If you can guide me, then I would like to implement this feature and learn tree-sitter.
regards Vikas
if you could attach files showing these in use that would be a great start
PROGRAM BLOCK_EXAMPLE
IMPLICIT NONE
BLOCK
INTEGER :: I
END BLOCK
label: BLOCK
INTEGER :: J
EXIT label
PRINT *, "unreachable"
END BLOCK label
! block-construct-name, i.e. "label", must be appended
END PROGRAM
PROGRAM DO_CONCURRENT_EXAMPLE
IMPLICIT NONE
INTEGER :: a(3, 4)
INTEGER :: i, j
DO CONCURRENT (j=1:4)
a(:, j) = j
END DO
label: DO CONCURRENT (i=1:3, j=1:4)
a(i, j) = i + j * 10
END DO label
! do-construct-name, i.e. "label", must be appended
END PROGRAM
PROGRAM ERROR_STOP_EXAMPLE
ERROR STOP
ERROR STOP 1
ERROR STOP 2, QUIET=.TRUE.
ERROR STOP "message"
ERROR STOP "message", QUIET=.TRUE.
END PROGRAM
INTEGER IMPURE FUNCTION f1()
END FUNCTION
IMPURE FUNCTION f2() RESULT(r)
REAL :: r
END FUNCTION
IMPURE SUBROUTINE g()
END SUBROUTINE
Also, the following attribute is missed:
CONTIGUOUS
SUBROUTINE CONTIGUOUS_EXAMPLE(a)
IMPLICIT NONE
REAL, CONTIGUOUS, INTENT(INOUT) :: a(:)
REAL, CONTIGUOUS, POINTER :: p(:)
END SUBROUTINE
@vickysharma0812 merged in your changes, @e-kwsm added support for the two missing keywords. Some of the new statements I will need to visit later when I have some more time. Apologies for the delay, I didn't intend for it to take me this long to review the PR.
@stadelmanma Thanks a lot, I will check it. I really appreciate you for this creation and update.
Support for block
added in #76
I think just do concurrent
missing from this issue?
The followings do not seem to be supported:
BLOCK
DO CONCURRENT
ERROR STOP
IMPURE