Reputation: 39
Can anybody suggest me how to extract the fields of a Cobol Copybook? It will be helpful if you could help with the code snippet or any links? Example:
I want to extract it like this.
Field No.
Field Name
Field Type (999 or S9(4) or x(5)....)
Field Type-add (COMP, COMP-3, etc.,)
Other-Details (Copy Everything until "." excluding PIC clause)
Upvotes: 4
Views: 15731
Reputation: 351
For python, take a look at the Copybook package (https://github.com/zalmane/copybook). It supports most features of Copybook includes REDEFINES and OCCURS as well as a wide variety of PIC formats.
pip install copybook
root = copybook.parse_file('sample.cbl')
disclaimer : I am the maintainer of https://github.com/zalmane/copybook
Upvotes: 2
Reputation: 79
disclaimer : I maintain https://www.cobolcopybook.co.in
Hi, check the site https://www.cobolcopybook.co.in, This site is designed specially for the analyze COBOL copybooks.
for Eg. Your input copybook is:
000100 01 BGG-FILE-REC.
000200 03 BGG-RCD-KEY.
000300 05 BGG-DUDENAME PIC XXXX.
000400 05 BGG-DUDEADDR PIC XX.
000500 05 BGG-HAIRCOLOR PIC X(71).
000600 05 BGG-EYECOLOR PIC X(8).
Then the output will be:
SR# LEVEL FIELD NAME PICTURE TYPE START END LENGTH
0 1 BGG-FILE-REC. @ AN 1 85 85
1 3 BGG-RCD-KEY. @ AN 1 85 85
2 5 BGG-DUDENAME XXXX. AN 1 4 4
3 5 BGG-DUDEADDR XX. AN 5 6 2
4 5 BGG-HAIRCOLOR X(71). AN 7 77 71
5 5 BGG-EYECOLOR X(8). AN 78 85 8
I hope this will solve your problem.
Upvotes: 0
Reputation: 163
Disclaimer: I am the maintainer of ProLeap COBOL parser.
You could use the Java-based ProLeap COBOL parser to extract all kinds of data from COBOL files such as level numbers, picture strings etc. Also you can extract COMP, COMP-1 etc. from the usage clause like this.
The ProLeap COBOL parser is licensed under an open source license, so it can be used for free.
Upvotes: 4
Reputation: 10553
Disclaimer: I maintain cb2xml
You could use cb2xml to parse your copybooks
See Looking for The right way with Regular Expression with groups in different order
Cobol:
01 Ams-Vendor.
03 Brand Pic x(3).
03 Location-details.
05 Location-Number Pic 9(4).
05 Location-Type Pic XX.
05 Location-Name Pic X(35).
03 Address-Details.
05 actual-address.
10 Address-1 Pic X(40).
10 Address-2 Pic X(40).
10 Address-3 Pic X(35).
05 Postcode Pic 9(4).
05 Empty pic x(6).
05 State Pic XXX.
03 Location-Active Pic X.
Output from cb2xml:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<copybook filename="cbl2xml_Test110.cbl">
<item display-length="173" level="01" name="Ams-Vendor" position="1" storage-length="173">
<item display-length="3" level="03" name="Brand" picture="x(3)" position="1" storage-length="3"/>
<item display-length="41" level="03" name="Location-details" position="4" storage-length="41">
<item display-length="4" level="05" name="Location-Number" numeric="true" picture="9(4)" position="4" storage-length="4"/>
<item display-length="2" level="05" name="Location-Type" picture="XX" position="8" storage-length="2"/>
<item display-length="35" level="05" name="Location-Name" picture="X(35)" position="10" storage-length="35"/>
</item>
<item display-length="128" level="03" name="Address-Details" position="45" storage-length="128">
<item display-length="115" level="05" name="actual-address" position="45" storage-length="115">
<item display-length="40" level="10" name="Address-1" picture="X(40)" position="45" storage-length="40"/>
<item display-length="40" level="10" name="Address-2" picture="X(40)" position="85" storage-length="40"/>
<item display-length="35" level="10" name="Address-3" picture="X(35)" position="125" storage-length="35"/>
</item>
<item display-length="4" level="05" name="Postcode" numeric="true" picture="9(4)" position="160" storage-length="4"/>
<item display-length="6" level="05" name="Empty" picture="x(6)" position="164" storage-length="6"/>
<item display-length="3" level="05" name="State" picture="XXX" position="170" storage-length="3"/>
</item>
<item display-length="1" level="03" name="Location-Active" picture="X" position="173" storage-length="1"/>
</item>
</copybook>
An interesting application of cb2xml is described in Dynamically Reading COBOL Redefines with C#
Upvotes: 1
Reputation: 95420
If you use a COBOL parser designed for the purpose, then this is relatively easy.
Such a parser has to be willing to parse not just an entire program, but to parse various subparts, such as a copybook containing a paragraph or a data declaration. Such a tool has to be prepared to handle the complexities found in real copybooks, such as field declarations, PIC strings, REDEFINEs, 77 and 88 level variables, all manner of crazy literal values used as initializers, and the messy/ugly problems with line continuations and COPY REPLACING, or it will only handle vanilla copybooks. Depending the origin of the copybook, you may have to process the text as EBCDIC. Its actually a lot of work to build a parser that handles all of this.
If you try to hack it with regexes or something else that can't do something like context-free parsing, your resulting tool will simply not work on any complex cases.
A good parser will produce an abstract syntax tree capturing all these details as a data structure in memory to be processed (this is efficient) or as an XML file to be processed by some other tool.
Our COBOL parser for DMS can handle all of the above and generate an AST dump or an XML equivalent.
Given this COBOL copybook fragment:
003110****************************************
003120* GEGVD - GEGVD-0872-WS
003130****************************************
003140 01 GEGVDC.
003150****************************************
003160****************************************
003170 10 GEJVD-CDA PIC X(11)
003180 VALUE
003190 '<<<GEGVD>>>'.
003200 10 GEJVD-COUNT PIC 9(9)
003210 VALUE ZERO
003220 COMPUTATIONAL-3.
003230 10 GEJVD-ITER PIC 9(3)
003240 VALUE ZERO
003250 COMPUTATIONAL-3.
003260 10 GEJVD-OP-CODE PIC X(1)
003270 VALUE SPACE.
003280 10 GEJVD-STATUS PIC X(2)
003290 VALUE SPACE.
003300 10 GEJVD-OPEN-SW PIC X(1)
003310 VALUE SPACE.
003320 10 GEGVD-STATUS PIC X(2)
003330 VALUE SPACE.
003340 10 STATUS-CODE REDEFINES
003350 GEGVD-STATUS PIC X(2).
003360 01 GEGVD.
003370****************************************
003380****************************************
003390 02 GEGVD-C.
003400 10 GEGVD-INPT-SCTN.
003410 15 GEGVD-ACTL-SERL-LN-CD PIC X(1)
003420 VALUE SPACE.
003430 15 GEGVD-FORM-VER-CD PIC X(5)
003440 VALUE SPACE.
003450 10 GEGVD-OUTP-SCTN.
003460 15 GEGVD-GE-RULE-RSLT-CD PIC X(1)
003470 VALUE SPACE.
003480 10 GEGVD-WORK-SCTN.
003490 15 GEGVD-GE-RSN-00826-ID PIC S9(5)
003500 VALUE +00826
003510 COMPUTATIONAL-3.
003520 15 GEGVD-WS-N-LIT PIC X(1)
003530 VALUE 'N'.
003540 15 GEGVD-WS-S-LIT PIC X(1)
003550 VALUE 'S'.
003560 15 GEGVD-MPN-FORM-VER-CD PIC X(5)
003570 VALUE '99-00'.
003580 15 GEGVD-PLUS-MPN-FORM-VER-CD PIC X(5)
003590 VALUE '03-04'.
our COBOL parser applied directly to the copybook file, produces the following abstract syntax tree:
C:\DMS\Domains\COBOL\IBMEnterprise\Tools\Parser\Source>run ../domainparser ++AST c:/DMS/Domains/COBOL/IBMEnterprise/Examples/SallieMae/copylibs/GEGVD.COP
COBOL~IBMEnterprise Domain Parser Version 2.7.17
Copyright (C) 1996-2017 Semantic Designs, Inc; All Rights Reserved; SD Confidential
Powered by DMS (R) Software Reengineering Toolkit
AST Optimizations: remove constant tokens, remove unary productions, compact sequences
Using encoding Unicode-UTF-8?ANSI +CRLF +1 /^I
393 tree nodes in tree.
(cobol_source_file@COBOL~IBMEnterprise=17#92facc0^0 Line 4 Column 8
(record_or_data_item_entry_list@COBOL~IBMEnterprise=721#92fac80^1#92facc0:1 Line 4 Column 8
(record_01_description_entry@COBOL~IBMEnterprise=576#92f6240^1#92fac80:1 Line 4 Column 8
(one@COBOL~IBMEnterprise=2170#92f10e0^1#92f6240:1 Line 4 Column 8
|(unsigned_integer_number@COBOL~IBMEnterprise=2579#92f1080^1#92f10e0:1[1] Line 4 Column 8
| precomment 0:1 Type 0 Line 1 Column 7 `****************************************'
| precomment 0:2 Type 0 Line 2 Column 7 `* GEGVD - GEGVD-0872-WS'
| precomment 0:3 Type 0 Line 3 Column 7 `****************************************')unsigned_integer_number
)one#92f10e0
(data_description_entry@COBOL~IBMEnterprise=607#92f12c0^1#92f6240:2 Line 4 Column 12
|(composed_identifier@COBOL~IBMEnterprise=2351#92f12a0^1#92f12c0:1 Line 4 Column 12
| (identifier@COBOL~IBMEnterprise=2850#92f10c0^1#92f12a0:1[`GEGVDC'] Line 4 Column 12
|)composed_identifier#92f12a0
)data_description_entry#92f12c0
('.'@COBOL~IBMEnterprise=2358#92f1280^1#92f6240:3[Keyword:4] Line 4 Column 18
(subsidiary_description_entry_list@COBOL~IBMEnterprise=585#92f61c0^1#92f6240:4 Line 7 Column 15
|(subsidiary_description_entry@COBOL~IBMEnterprise=588#92f1800^1#92f61c0:1 Line 7 Column 15
| (level_number@COBOL~IBMEnterprise=2174#92f1360^1#92f1800:1 Line 7 Column 15
| (unsigned_integer_number@COBOL~IBMEnterprise=2579#92f1320^1#92f1360:1[10] Line 7 Column 15
| precomment 0:1 Type 0 Line 5 Column 7 `****************************************'
| precomment 0:2 Type 0 Line 6 Column 7 `****************************************')unsigned_integer_number
| )level_number#92f1360
| (data_description_entry@COBOL~IBMEnterprise=608#92f1720^1#92f1800:2 Line 7 Column 18
| (composed_identifier@COBOL~IBMEnterprise=2351#92f13c0^1#92f1720:1 Line 7 Column 18
| (identifier@COBOL~IBMEnterprise=2850#92f1340^1#92f13c0:1[`GEJVD-CDA'] Line 7 Column 18
er
| )composed_identifier#92f13c0
| (data_description_clause_list@COBOL~IBMEnterprise=613#92f16e0^1#92f1720:2 Line 7 Column 55
| (picture_clause@COBOL~IBMEnterprise=653#92f1520^1#92f16e0:1 Line 7 Column 55
| |(pic_picture@COBOL~IBMEnterprise=194#92f1420^1#92f1520:1 Line 7 Column 55
| | ('PIC'@COBOL~IBMEnterprise=2430#92f13a0^1#92f1420:1[Keyword:0] Line 7 Column 55
| |)pic_picture#92f1420
| |(optional_is@COBOL~IBMEnterprise=59#92f1440^1#92f1520:2 Line 7 Column 59
| |(picture_string@COBOL~IBMEnterprise=656#92f1500^1#92f1520:3 Line 7 Column 59
| | (alphanumeric_picture_string@COBOL~IBMEnterprise=2543#92f1400^1#92f1500:1[`X(11)'] Line 7 Column 59
VD.COP)alphanumeric_picture_string
| |)picture_string#92f1500
| )picture_clause#92f1520
| (value_is_clause@COBOL~IBMEnterprise=711#92f16a0^1#92f16e0:2 Line 8 Column 44
| |(value_values@COBOL~IBMEnterprise=202#92f1600^1#92f16a0:1 Line 8 Column 44
| | ('VALUE'@COBOL~IBMEnterprise=2437#92f14e0^1#92f1600:1[Keyword:0] Line 8 Column 44
| |)value_values#92f1600
| |(optional_is_are@COBOL~IBMEnterprise=63#92f1620^1#92f16a0:2 Line 9 Column 20
| |(non_figurative_non_numeric_literal@COBOL~IBMEnterprise=2205#92f1680^1#92f16a0:3 Line 9 Column 20
COP
| | (non_numeric_literal_string@COBOL~IBMEnterprise=2187#92f1660^1#92f1680:1 Line 9 Column 20
| | (non_numeric_literal_quote@COBOL~IBMEnterprise=2840#92f15e0^1#92f1660:1[`<<<GEGVD>>>'] Line 9 Column 20
s/GEGVD.COP)non_numeric_literal_quote
| | )non_numeric_literal_string#92f1660
| |)non_figurative_non_numeric_literal#92f1680
| )value_is_clause#92f16a0
| )data_description_clause_list#92f16e0
| )data_description_entry#92f1720
| ('.'@COBOL~IBMEnterprise=2358#92f1640^1#92f1800:3[Keyword:0] Line 9 Column 33
|)subsidiary_description_entry#92f1800
|(subsidiary_description_entry_list@COBOL~IBMEnterprise=585#92f6120^1#92f61c0:2 Line 10 Column 15
| (subsidiary_description_entry@COBOL~IBMEnterprise=588#92f1c20^1#92f6120:1 Line 10 Column 15
| (level_number@COBOL~IBMEnterprise=2174#92f18a0^1#92f1c20:1 Line 10 Column 15
| (unsigned_integer_number@COBOL~IBMEnterprise=2579#92f17e0^1#92f18a0:1[10] Line 10 Column 15
igned_integer_number
| )level_number#92f18a0
| (data_description_entry@COBOL~IBMEnterprise=608#92f1bc0^1#92f1c20:2 Line 10 Column 18
| (composed_identifier@COBOL~IBMEnterprise=2351#92f18e0^1#92f1bc0:1 Line 10 Column 18
| |(identifier@COBOL~IBMEnterprise=2850#92f1820^1#92f18e0:1[`GEJVD-COUNT'] Line 10 Column 18
tifier
| )composed_identifier#92f18e0
| (data_description_clause_list@COBOL~IBMEnterprise=613#92f1ba0^1#92f1bc0:2 Line 10 Column 55
| |(data_description_clause_list@COBOL~IBMEnterprise=613#92f1aa0^1#92f1ba0:1 Line 10 Column 55
| | (picture_clause@COBOL~IBMEnterprise=653#92f19a0^1#92f1aa0:1 Line 10 Column 55
| | (pic_picture@COBOL~IBMEnterprise=194#92f1920^1#92f19a0:1 Line 10 Column 55
| | ('PIC'@COBOL~IBMEnterprise=2430#92f18c0^1#92f1920:1[Keyword:0] Line 10 Column 55
| | )pic_picture#92f1920
| | (optional_is@COBOL~IBMEnterprise=59#92f1940^1#92f19a0:2 Line 10 Column 59
| | (picture_string@COBOL~IBMEnterprise=655#92f1980^1#92f19a0:3 Line 10 Column 59
| | (numeric_picture_string@COBOL~IBMEnterprise=2542#92f1900^1#92f1980:1[`9(9)'] Line 10 Column 59
COP)numeric_picture_string
| | )picture_string#92f1980
| | )picture_clause#92f19a0
| | (value_is_clause@COBOL~IBMEnterprise=711#92f1a80^1#92f1aa0:2 Line 11 Column 44
| | (value_values@COBOL~IBMEnterprise=202#92f1a00^1#92f1a80:1 Line 11 Column 44
| | ('VALUE'@COBOL~IBMEnterprise=2437#92f1960^1#92f1a00:1[Keyword:0] Line 11 Column 44
| | )value_values#92f1a00
| | (optional_is_are@COBOL~IBMEnterprise=63#92f1a20^1#92f1a80:2 Line 11 Column 54
e
| | (non_all_figurative_numeric_or_non_numeric_literal@COBOL~IBMEnterprise=2203#92f1a60^1#92f1a80:3 Line 11 Column 54
ae/copylibs/GEGVD.COP
| | ('ZERO'@COBOL~IBMEnterprise=2533#92f19e0^1#92f1a60:1[Keyword:0] Line 11 Column 54
| | )non_all_figurative_numeric_or_non_numeric_literal#92f1a60
| | )value_is_clause#92f1a80
| |)data_description_clause_list#92f1aa0
| |(usage_clause@COBOL~IBMEnterprise=684#92f1b80^1#92f1ba0:2 Line 12 Column 44
| | (optional_usage_is@COBOL~IBMEnterprise=674#92f1ae0^1#92f1b80:1 Line 12 Column 44
ge_is
| | ('COMPUTATIONAL-3'@COBOL~IBMEnterprise=2565#92f1a40^1#92f1b80:2[Keyword:0] Line 12 Column 44
'COMPUTATIONAL-3'
| |)usage_clause#92f1b80
| )data_description_clause_list#92f1ba0
| )data_description_entry#92f1bc0
| ('.'@COBOL~IBMEnterprise=2358#92f1b60^1#92f1c20:3[Keyword:0] Line 12 Column 59
| )subsidiary_description_entry#92f1c20
| (subsidiary_description_entry_list@COBOL~IBMEnterprise=585#92f5fe0^1#92f6120:2 Line 13 Column 15
| (subsidiary_description_entry@COBOL~IBMEnterprise=588#92f4120^1#92f5fe0:1 Line 13 Column 15
| (level_number@COBOL~IBMEnterprise=2174#92f1d40^1#92f4120:1 Line 13 Column 15
| |(unsigned_integer_number@COBOL~IBMEnterprise=2579#92f1be0^1#92f1d40:1[10] Line 13 Column 15
signed_integer_number
| )level_number#92f1d40
| (data_description_entry@COBOL~IBMEnterprise=608#92f40c0^1#92f4120:2 Line 13 Column 18
| |(composed_identifier@COBOL~IBMEnterprise=2351#92f1d80^1#92f40c0:1 Line 13 Column 18
| | (identifier@COBOL~IBMEnterprise=2850#92f1d00^1#92f1d80:1[`GEJVD-ITER'] Line 13 Column 18
tifier
| |)composed_identifier#92f1d80
| |(data_description_clause_list@COBOL~IBMEnterprise=613#92f40a0^1#92f40c0:2 Line 13 Column 55
| | (data_description_clause_list@COBOL~IBMEnterprise=613#92f1fa0^1#92f40a0:1 Line 13 Column 55
| | (picture_clause@COBOL~IBMEnterprise=653#92f1e40^1#92f1fa0:1 Line 13 Column 55
| | (pic_picture@COBOL~IBMEnterprise=194#92f1dc0^1#92f1e40:1 Line 13 Column 55
| | |('PIC'@COBOL~IBMEnterprise=2430#92f1d60^1#92f1dc0:1[Keyword:0] Line 13 Column 55
| | )pic_picture#92f1dc0
| | (optional_is@COBOL~IBMEnterprise=59#92f1de0^1#92f1e40:2 Line 13 Column 59
| | (picture_string@COBOL~IBMEnterprise=655#92f1e20^1#92f1e40:3 Line 13 Column 59
| | |(numeric_picture_string@COBOL~IBMEnterprise=2542#92f1da0^1#92f1e20:1[`9(3)'] Line 13 Column 59
.COP)numeric_picture_string
| | )picture_string#92f1e20
| | )picture_clause#92f1e40
| | (value_is_clause@COBOL~IBMEnterprise=711#92f1f80^1#92f1fa0:2 Line 14 Column 44
| | (value_values@COBOL~IBMEnterprise=202#92f1f00^1#92f1f80:1 Line 14 Column 44
| | |('VALUE'@COBOL~IBMEnterprise=2437#92f1e00^1#92f1f00:1[Keyword:0] Line 14 Column 44
| | )value_values#92f1f00
| | (optional_is_are@COBOL~IBMEnterprise=63#92f1f20^1#92f1f80:2 Line 14 Column 54
re
| | (non_all_figurative_numeric_or_non_numeric_literal@COBOL~IBMEnterprise=2203#92f1f60^1#92f1f80:3 Line 14 Column 54
Mae/copylibs/GEGVD.COP
| | |('ZERO'@COBOL~IBMEnterprise=2533#92f1ee0^1#92f1f60:1[Keyword:0] Line 14 Column 54
| | )non_all_figurative_numeric_or_non_numeric_literal#92f1f60
| | )value_is_clause#92f1f80
| | )data_description_clause_list#92f1fa0
| | (usage_clause@COBOL~IBMEnterprise=684#92f4080^1#92f40a0:2 Line 15 Column 44
| | (optional_usage_is@COBOL~IBMEnterprise=674#92f4000^1#92f4080:1 Line 15 Column 44
age_is
| | ('COMPUTATIONAL-3'@COBOL~IBMEnterprise=2565#92f1f40^1#92f4080:2[Keyword:0] Line 15 Column 44
)'COMPUTATIONAL-3'
| | )usage_clause#92f4080
| |)data_description_clause_list#92f40a0
| )data_description_entry#92f40c0
| ('.'@COBOL~IBMEnterprise=2358#92f4060^1#92f4120:3[Keyword:0] Line 15 Column 59
| )subsidiary_description_entry#92f4120
| (subsidiary_description_entry_list@COBOL~IBMEnterprise=585#92f5e60^1#92f5fe0:2 Line 16 Column 15
| (subsidiary_description_entry@COBOL~IBMEnterprise=588#92f45c0^1#92f5e60:1 Line 16 Column 15
| |(level_number@COBOL~IBMEnterprise=2174#92f4240^1#92f45c0:1 Line 16 Column 15
| | (unsigned_integer_number@COBOL~IBMEnterprise=2579#92f40e0^1#92f4240:1[10] Line 16 Column 15
nsigned_integer_number
| |)level_number#92f4240
| |(data_description_entry@COBOL~IBMEnterprise=608#92f44e0^1#92f45c0:2 Line 16 Column 18
| | (composed_identifier@COBOL~IBMEnterprise=2351#92f4280^1#92f44e0:1 Line 16 Column 18
| | (identifier@COBOL~IBMEnterprise=2850#92f4200^1#92f4280:1[`GEJVD-OP-CODE'] Line 16 Column 18
identifier
| | )composed_identifier#92f4280
| | (data_description_clause_list@COBOL~IBMEnterprise=613#92f44a0^1#92f44e0:2 Line 16 Column 55
| | (picture_clause@COBOL~IBMEnterprise=653#92f4340^1#92f44a0:1 Line 16 Column 55
| | (pic_picture@COBOL~IBMEnterprise=194#92f42c0^1#92f4340:1 Line 16 Column 55
| | |('PIC'@COBOL~IBMEnterprise=2430#92f4260^1#92f42c0:1[Keyword:0] Line 16 Column 55
| | )pic_picture#92f42c0
| | (optional_is@COBOL~IBMEnterprise=59#92f42e0^1#92f4340:2 Line 16 Column 59
| | (picture_string@COBOL~IBMEnterprise=656#92f4320^1#92f4340:3 Line 16 Column 59
| | |(alphanumeric_picture_string@COBOL~IBMEnterprise=2543#92f42a0^1#92f4320:1[`X(1)'] Line 16 Column 59
GEGVD.COP)alphanumeric_picture_string
| | )picture_string#92f4320
| | )picture_clause#92f4340
| | (value_is_clause@COBOL~IBMEnterprise=711#92f4480^1#92f44a0:2
** middle of AST deleted due to size limitations on SO answers **
| | (level_number@COBOL~IBMEnterprise=2174#92f7140^1#92f7600:1 Line 44 Column 18
| | |(unsigned_integer_number@COBOL~IBMEnterprise=2579#92f6fa0^1#92f7140:1[15] Line 44 Column 18
P)unsigned_integer_number
| | )level_number#92f7140
| | (data_description_entry@COBOL~IBMEnterprise=608#92f7540^1#92f7600:2 Line 44 Column 21
| | |(composed_identifier@COBOL~IBMEnterprise=2351#92f71a0^1#92f7540:1 Line 44 Column 21
| | | (identifier@COBOL~IBMEnterprise=2850#92f70c0^1#92f71a0:1[`GEGVD-WS-S-LIT'] Line 44 Column 21
COP)identifier
| | |)composed_identifier#92f71a0
| | |(data_description_clause_list@COBOL~IBMEnterprise=613#92f74a0^1#92f7540:2 Line 44 Column 55
P
| | | (picture_clause@COBOL~IBMEnterprise=653#92f72c0^1#92f74a0:1 Line 44 Column 55
| | | (pic_picture@COBOL~IBMEnterprise=194#92f7220^1#92f72c0:1 Line 44 Column 55
| | | ('PIC'@COBOL~IBMEnterprise=2430#92f7160^1#92f7220:1[Keyword:0] Line 44 Column 55
| | | )pic_picture#92f7220
| | | (optional_is@COBOL~IBMEnterprise=59#92f7260^1#92f72c0:2 Line 44 Column 59
| | | (picture_string@COBOL~IBMEnterprise=656#92f72a0^1#92f72c0:3 Line 44 Column 59
| | | (alphanumeric_picture_string@COBOL~IBMEnterprise=2543#92f7200^1#92f72a0:1[`X(1)'] Line 44 Column 59
bs/GEGVD.COP)alphanumeric_picture_string
| | | )picture_string#92f72a0
| | | )picture_clause#92f72c0
| | | (value_is_clause@COBOL~IBMEnterprise=711#92f7460^1#92f74a0:2 Line 45 Column 44
| | | (value_values@COBOL~IBMEnterprise=202#92f7380^1#92f7460:1 Line 45 Column 44
| | | ('VALUE'@COBOL~IBMEnterprise=2437#92f7280^1#92f7380:1[Keyword:0] Line 45 Column 44
UE'
| | | )value_values#92f7380
| | | (optional_is_are@COBOL~IBMEnterprise=63#92f73a0^1#92f7460:2 Line 45 Column 54
s_are
| | | (non_figurative_non_numeric_literal@COBOL~IBMEnterprise=2205#92f7440^1#92f7460:3 Line 45 Column 54
/GEGVD.COP
| | | (non_numeric_literal_string@COBOL~IBMEnterprise=2187#92f7420^1#92f7440:1 Line 45 Column 54
COP
| | | |(non_numeric_literal_quote@COBOL~IBMEnterprise=2840#92f7360^1#92f7420:1[`S'] Line 45 Column 54
EGVD.COP)non_numeric_literal_quote
| | | )non_numeric_literal_string#92f7420
| | | )non_figurative_non_numeric_literal#92f7440
| | | )value_is_clause#92f7460
| | |)data_description_clause_list#92f74a0
| | )data_description_entry#92f7540
| | ('.'@COBOL~IBMEnterprise=2358#92f73c0^1#92f7600:3[Keyword:0] Line 45 Column 57
| | )subsidiary_description_entry#92f7600
| | (subsidiary_description_entry_list@COBOL~IBMEnterprise=585#92fa180^1#92fa200:2 Line 46 Column 18
.COP
| | (subsidiary_description_entry@COBOL~IBMEnterprise=588#92f7b40^1#92fa180:1 Line 46 Column 18
| | |(level_number@COBOL~IBMEnterprise=2174#92f7760^1#92f7b40:1 Line 46 Column 18
| | | (unsigned_integer_number@COBOL~IBMEnterprise=2579#92f75a0^1#92f7760:1[15] Line 46 Column 18
OP)unsigned_integer_number
| | |)level_number#92f7760
| | |(data_description_entry@COBOL~IBMEnterprise=608#92f7a60^1#92f7b40:2 Line 46 Column 21
| | | (composed_identifier@COBOL~IBMEnterprise=2351#92f77c0^1#92f7a60:1 Line 46 Column 21
| | | (identifier@COBOL~IBMEnterprise=2850#92f7660^1#92f77c0:1[`GEGVD-MPN-FORM-VER-CD'] Line 46 Column 21
s/GEGVD.COP)identifier
| | | )composed_identifier#92f77c0
| | | (data_description_clause_list@COBOL~IBMEnterprise=613#92f7a20^1#92f7a60:2 Line 46 Column 55
OP
| | | (picture_clause@COBOL~IBMEnterprise=653#92f7880^1#92f7a20:1 Line 46 Column 55
| | | (pic_picture@COBOL~IBMEnterprise=194#92f7800^1#92f7880:1 Line 46 Column 55
| | | |('PIC'@COBOL~IBMEnterprise=2430#92f77a0^1#92f7800:1[Keyword:0] Line 46 Column 55
| | | )pic_picture#92f7800
| | | (optional_is@COBOL~IBMEnterprise=59#92f7820^1#92f7880:2 Line 46 Column 59
| | | (picture_string@COBOL~IBMEnterprise=656#92f7860^1#92f7880:3 Line 46 Column 59
| | | |(alphanumeric_picture_string@COBOL~IBMEnterprise=2543#92f77e0^1#92f7860:1[`X(5)'] Line 46 Column 59
ibs/GEGVD.COP)alphanumeric_picture_string
| | | )picture_string#92f7860
| | | )picture_clause#92f7880
| | | (value_is_clause@COBOL~IBMEnterprise=711#92f79c0^1#92f7a20:2 Line 47 Column 44
| | | (value_values@COBOL~IBMEnterprise=202#92f7920^1#92f79c0:1 Line 47 Column 44
| | | |('VALUE'@COBOL~IBMEnterprise=2437#92f7840^1#92f7920:1[Keyword:0] Line 47 Column 44
LUE'
| | | )value_values#92f7920
| | | (optional_is_are@COBOL~IBMEnterprise=63#92f7940^1#92f79c0:2 Line 47 Column 54
is_are
| | | (non_figurative_non_numeric_literal@COBOL~IBMEnterprise=2205#92f79a0^1#92f79c0:3 Line 47 Column 54
s/GEGVD.COP
| | | |(non_numeric_literal_string@COBOL~IBMEnterprise=2187#92f7980^1#92f79a0:1 Line 47 Column 54
.COP
| | | | (non_numeric_literal_quote@COBOL~IBMEnterprise=2840#92f7900^1#92f7980:1[`99-00'] Line 47 Column 54
ibs/GEGVD.COP)non_numeric_literal_quote
| | | |)non_numeric_literal_string#92f7980
| | | )non_figurative_non_numeric_literal#92f79a0
| | | )value_is_clause#92f79c0
| | | )data_description_clause_list#92f7a20
| | |)data_description_entry#92f7a60
| | |('.'@COBOL~IBMEnterprise=2358#92f7960^1#92f7b40:3[Keyword:0] Line 47 Column 61
| | )subsidiary_description_entry#92f7b40
| | (subsidiary_description_entry@COBOL~IBMEnterprise=588#92fa0c0^1#92fa180:2 Line 48 Column 18
| | |(level_number@COBOL~IBMEnterprise=2174#92f7c80^1#92fa0c0:1 Line 48 Column 18
| | | (unsigned_integer_number@COBOL~IBMEnterprise=2579#92f7ae0^1#92f7c80:1[15] Line 48 Column 18
OP)unsigned_integer_number
| | |)level_number#92f7c80
| | |(data_description_entry@COBOL~IBMEnterprise=608#92f7fc0^1#92fa0c0:2 Line 48 Column 21
| | | (composed_identifier@COBOL~IBMEnterprise=2351#92f7cc0^1#92f7fc0:1 Line 48 Column 21
| | | (identifier@COBOL~IBMEnterprise=2850#92f7b60^1#92f7cc0:1[`GEGVD-PLUS-MPN-FORM-VER-CD'] Line 48 Column 21
pylibs/GEGVD.COP)identifier
| | | )composed_identifier#92f7cc0
| | | (data_description_clause_list@COBOL~IBMEnterprise=613#92f7f60^1#92f7fc0:2 Line 48 Column 55
OP
| | | (picture_clause@COBOL~IBMEnterprise=653#92f7de0^1#92f7f60:1 Line 48 Column 55
| | | (pic_picture@COBOL~IBMEnterprise=194#92f7d20^1#92f7de0:1 Line 48 Column 55
| | | |('PIC'@COBOL~IBMEnterprise=2430#92f7ca0^1#92f7d20:1[Keyword:0] Line 48 Column 55
| | | )pic_picture#92f7d20
| | | (optional_is@COBOL~IBMEnterprise=59#92f7d40^1#92f7de0:2 Line 48 Column 59
| | | (picture_string@COBOL~IBMEnterprise=656#92f7da0^1#92f7de0:3 Line 48 Column 59
| | | |(alphanumeric_picture_string@COBOL~IBMEnterprise=2543#92f7ce0^1#92f7da0:1[`X(5)'] Line 48 Column 59
ibs/GEGVD.COP)alphanumeric_picture_string
| | | )picture_string#92f7da0
| | | )picture_clause#92f7de0
| | | (value_is_clause@COBOL~IBMEnterprise=711#92f7f20^1#92f7f60:2 Line 49 Column 44
| | | (value_values@COBOL~IBMEnterprise=202#92f7e80^1#92f7f20:1 Line 49 Column 44
| | | |('VALUE'@COBOL~IBMEnterprise=2437#92f7d80^1#92f7e80:1[Keyword:0] Line 49 Column 44
LUE'
| | | )value_values#92f7e80
| | | (optional_is_are@COBOL~IBMEnterprise=63#92f7ea0^1#92f7f20:2 Line 49 Column 54
is_are
| | | (non_figurative_non_numeric_literal@COBOL~IBMEnterprise=2205#92f7f00^1#92f7f20:3 Line 49 Column 54
s/GEGVD.COP
| | | |(non_numeric_literal_string@COBOL~IBMEnterprise=2187#92f7ee0^1#92f7f00:1 Line 49 Column 54
.COP
| | | | (non_numeric_literal_quote@COBOL~IBMEnterprise=2840#92f7e60^1#92f7ee0:1[`03-04'] Line 49 Column 54
ibs/GEGVD.COP)non_numeric_literal_quote
| | | |)non_numeric_literal_string#92f7ee0
| | | )non_figurative_non_numeric_literal#92f7f00
| | | )value_is_clause#92f7f20
| | | )data_description_clause_list#92f7f60
| | |)data_description_entry#92f7fc0
| | |('.'@COBOL~IBMEnterprise=2358#92f7ec0^1#92fa0c0:3[Keyword:0] Line 49 Column 61
| | )subsidiary_description_entry#92fa0c0
| | )subsidiary_description_entry_list#92fa180
| | )subsidiary_description_entry_list#92fa200
| |)subsidiary_description_entry_list#92fa340
| )subsidiary_description_entry_list#92fa3c0
| )subsidiary_description_entry#92fa500
| )subsidiary_description_entry_list#92fa6e0
|)subsidiary_description_entry_list#92fa7a0
)subsidiary_description_entry#92fa840
)record_01_description_entry#92faac0
)record_or_data_item_entry_list#92fac80
)cobol_source_file#92facc0
C:\DMS\Domains\COBOL\IBMEnterprise\Tools\Parser\Source>
Once you have the tree, it is fairly straightforward to walk over the tree and extract facts about the COBOL symbol declarations.
Upvotes: 0