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

Support for Extracting Nested CALL and PERFORM Statements #109

Open
MatteoBenvenuti opened this issue Oct 29, 2024 · 0 comments
Open

Support for Extracting Nested CALL and PERFORM Statements #109

MatteoBenvenuti opened this issue Oct 29, 2024 · 0 comments

Comments

@MatteoBenvenuti
Copy link

Hello,

I'm currently using Proleap COBOL Parser to analyze COBOL files and extract all CALL and PERFORM statements from the code. I have a method that iterates through a list of statements and handles both CALL and PERFORM instructions. Here is my current code:

private Node extractNode(Node baseNode, List<Statement> statements) {
    for (Statement statement : statements) {
        // Handling CALL
        if (statement instanceof CallStatement callStatement) {
            ValueStmt programValueStmt = callStatement.getProgramValueStmt();
            if (programValueStmt != null && programValueStmt.getValue() != null) {
                baseNode.getCalls().add(programValueStmt.getValue().toString());
            }
        }

        // Handling PERFORM
        if (statement instanceof PerformStatement performStatement) {
            PerformProcedureStatement performProcedureStatement = performStatement.getPerformProcedureStatement();
            if (performProcedureStatement != null) {
                for (Call call : performProcedureStatement.getCalls()) {
                    baseNode.getPerforms().add(call.getName());
                }
            }
        }
      
        // Retrieve all inner statements from the current statement and call extractNode recursively
    }
}

I'm looking for a way to retrieve inner statements within each Statement instance to handle nested structures more effectively. Is there a method in Proleap that allows me to access these inner statements? Or is there an approach you would recommend for parsing and extracting all CALL and PERFORM instructions from deeply nested statements?

Thank you for your time and help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant