Open panky1998 opened 1 year ago
Hi @panky1998 ,
you should be able to call getCtx
on each ASG element to retrieve the corresponding AST element. So for each ASG element there should be an AST element named ctx. The AST ctx element should always be an ANTLR class.
The interface is in ASGElement.java
Best Ulrich
Hi @uwol , As you said I'm calling each AST element with getCtx(). But when I'm trying to call AST elements it is returning numbers. Am I calling in improper way? Please help me as am a novice...
// navigate on ASG
CompilationUnit compilationUnit = program.getCompilationUnit("HelloWorld");
ProgramUnit programUnit = compilationUnit.getProgramUnit();
DataDivision dataDivision = programUnit.getDataDivision();
DataDescriptionEntry dataDescriptionEntry = dataDivision
.getWorkingStorageSection().getDataDescriptionEntry("ITEMS");
Integer levelNumber = dataDescriptionEntry.getLevelNumber();
System.out.println("Compilation unit => "+compilationUnit.getCtx());
System.out.println("Program Unit => "+programUnit.getCtx());
System.out.println("Data Division => "+dataDivision.getCtx());
System.out.println("Data Description Entry => "+dataDescriptionEntry.getCtx());
System.out.println("Level number =--> "+levelNumber);
I'm getting output as
Compilation unit => [1198] Program Unit => [1201 1198] Data Division => [1211 1201 1198] Data Description Entry => [3171 2286 2005 1997 1211 1201 1198] Level number =--> 1
Regards, Pankaj
Hi @panky1998 ,
this is correct, those are the ANTLR ParserRuleContext elements. In Eclipse debugger you can introspect them.
You can use them to navigate to children, to the parent element etc. For this the normal ANTLR documentation applies, nothing COBOL- or ProLeap-specific.
Best Ulrich
Since I'm trying to get the AST elements . I'm unable to get them. If you have any suggestions please help!