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

276 support on EXCEPTION in CALLs #311

Closed
wants to merge 2 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,27 @@ public static boolean isEndOfStatement(CobolLine currentLine, CobolLine nextMean
if (containsOnlyPeriod(nextMeaningfulLine)) {
return false;
}
if (currentLine.containsToken(Constants.CALL_TOKEN)) {
List<String> currentTokens = currentLine.getTokens();
int callTokenCount = 0, endCallTokenCount = 0;
for (String token : currentTokens) {
if (token.equals(Constants.CALL_TOKEN)) {
callTokenCount++;
}
if (token.equals(Constants.END_CALL_TOKEN)) {
endCallTokenCount++;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might break if the "end-call-token" is replaced with a period.

Try making this test:
CALL "PROGRAM" USING DATA-1 ON EXCEPTION
DISPLAY "ERROR".
CALL "PROGRAM" USING DATA-1 ON EXCEPTION
DISPLAY "ERROR".
What code does that result in?
It should look something like this:

  • CALL "PROGRAM" USING DATA-1 ON EXCEPTION DISPLAY "ERROR".
  • CALL "PROGRAM" USING DATA-1 ON EXCEPTION DISPLAY "ERROR".
    But I think it will concatenate it like this:
  • CALL "PROGRAM" USING DATA-1 ON EXCEPTION DISPLAY "ERROR". CALL
  • "PROGRAM" USING DATA-1 ON EXCEPTION DISPLAY "ERROR".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rune-Christensen
Thanks for the question.

The If conditions above line 166 will take care of the period terminator preventing the code from breaking.

The above code is returning the below code:

*CALL "PROGRAM" USING DATA-1 ON EXCEPTION
*    DISPLAY "ERROR"
           CONTINUE                                                            
           .                                                                 
*CALL "PROGRAM" USING DATA-1 ON EXCEPTION
*    DISPLAY "ERROR".                                       
            CONTINUE                                                            
           .

I have also added tests in my new PR :)

Regards,
Akash Kumar

}
}
if (callTokenCount == endCallTokenCount) {
return true;
}
if (nextMeaningfulLine.containsToken("ON")) {
return false;
}
if (currentLine.containsToken("ON")) {
return false;
}
}
if (CobolVerbs.isStartOrEndCobolVerb(nextMeaningfulLine.getTokens().get(0))) {
return true;
}
Expand Down
Loading
Loading