Skip to content

Commit

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

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

contains

subroutine a
integer :: a, b
a = 1+2*3
b = (1+2+a)*3
end subroutine

end module
7 changes: 6 additions & 1 deletion fortran.g4
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ var_sym_decl
;

expr
: IDENT | NUMBER | fn_call
: expr ('*'|'/') expr
| expr ('+'|'-') expr
| NUMBER
| IDENT
| fn_call
| '(' expr ')'
;

fn_call
Expand Down

0 comments on commit e00c0c4

Please sign in to comment.