I need to extract information from a COBOL program. I'm using the ANTLR grammar for COBOL. I need to extract group variables as a whole. I'm not able to extract this with ANTLR as the parser extracts every variable subdivision/group item as an individual element. I need somehow to get the group items as a bunch. I'm new to COBOL, so I want to get an understanding of how the compiler understands which elements to include in a group, and where to stop.
EX:
01 EMPREC.
02 EEMPNAME.
10 FIRSTNAME PIC X(10)
10 LASTNAM PIC X(15)
07 SNO PIC X(15)
Is the above definition valid? Will the compiler include all elements(=>2 and <=49) after the first item (01 EMPREC), in the group EMPREC until it encounters another 01 or 77 ? Is this safe to assume? Is the level information enough to derive what elements fall under a group? Any pointers is appreciated.