Skip to content

Commit

Permalink
Add subroutines
Browse files Browse the repository at this point in the history
  • Loading branch information
certik committed Oct 26, 2017
1 parent 64196ce commit e6e1c59
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ javac fortran*.java

# Test:
$grun fortran module -tree examples/m1.f90
$grun fortran module -tree examples/subroutine1.f90
14 changes: 14 additions & 0 deletions examples/subroutine1.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module subroutine1
implicit none

contains

subroutine some_subroutine
integer :: a, b, c
end subroutine

subroutine some_other_subroutine
integer :: a, b
end subroutine

end module
6 changes: 5 additions & 1 deletion fortran.g4
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
grammar fortran;

module
: 'module' IDENT 'implicit none' decl* 'end' IDENT?
: 'module' IDENT 'implicit none' decl* ('contains' subroutine+ )? 'end' IDENT?
;

decl
Expand Down Expand Up @@ -42,6 +42,10 @@ modifier
: 'parameter' | 'intent' | 'dimension' | 'allocatable' | 'pointer'
;

subroutine
: 'subroutine' IDENT decl* 'end' 'subroutine'?
;

NUMBER
: ([0-9]+ '.' [0-9]* | '.' [0-9]+) ([eEdD] [+-]? [0-9]+)?
| [0-9]+ ([eEdD] [+-]? [0-9]+)?
Expand Down

0 comments on commit e6e1c59

Please sign in to comment.