Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created subroutine-subprogram action (rule 1231) similarly to function-subprogram action (R1223) #112

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/fortran/ofp/parser/FortranParserBase.g
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,12 @@ declaration_construct

// R208
execution_part
@init{int count = 0;}
@after {
action.execution_part();
action.execution_part(count);
}
: executable_construct
( execution_part_construct )*
( execution_part_construct {count += 1;} )*
;

// R209
Expand Down Expand Up @@ -5665,11 +5666,16 @@ end_function_stmt
// specification_part made non-optional to remove END ambiguity (as can
// be empty)
subroutine_subprogram
@init {
boolean hasExePart = false;
boolean hasIntSubProg = false;
}
: subroutine_stmt
specification_part
( execution_part )?
( internal_subprogram_part )?
( execution_part { hasExePart=true; } )?
( internal_subprogram_part { hasIntSubProg=true; } )?
end_subroutine_stmt
{ action.subroutine_subprogram(hasExePart, hasIntSubProg); }
;

// R1232
Expand Down
19 changes: 18 additions & 1 deletion src/fortran/ofp/parser/java/FortranParserActionPrint.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ public void declaration_construct() {
* execution_part
*
*/
public void execution_part() {
public void execution_part(int count) {
printRuleHeader(208, "execution-part");
printParameter(count, "count");
printRuleTrailer();
}

Expand Down Expand Up @@ -4928,6 +4929,22 @@ public void end_function_stmt(Token label, Token keyword1, Token keyword2,
printRuleTrailer();
}

/**
* R1231
* subroutine_subprogram
*
* @param hasExePart Flag specifying if optional execution_part was given.
* @param hasIntSubProg Flag specifying if optional
* internal_subprogram_part was given.
*/
public void subroutine_subprogram(boolean hasExePart,
boolean hasIntSubProg) {
printRuleHeader(1231, "subroutine-subprogram");
printParameter(hasExePart, "hasExePart");
printParameter(hasIntSubProg, "hasIntSubProg");
printRuleTrailer();
}

/** R1232
* subroutine_stmt__begin
*/
Expand Down
12 changes: 11 additions & 1 deletion src/fortran/ofp/parser/java/IFortranParserAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public abstract interface IFortranParserAction {
/** R208
* execution_part
*/
public abstract void execution_part();
public abstract void execution_part(int count);

/** R209
* execution_part_construct
Expand Down Expand Up @@ -4282,6 +4282,16 @@ public abstract void function_stmt(Token label, Token keyword, Token name,
*/
public abstract void subroutine_stmt__begin();

/** R1231
* subroutine_subprogram
*
* @param hasExePart Flag specifying if optional execution_part was given.
* @param hasIntSubProg Flag specifying if optional internal_subprogram_part
* was given.
*/
public abstract void
subroutine_subprogram(boolean hasExePart, boolean hasIntSubProg);

/** R1232
* subroutine_stmt
* : (label)? (t_prefix )? T_SUBROUTINE T_IDENT
Expand Down