有人可以建议我如何提取Cobol Copybook的字段吗? 如果您帮助处理代码段或任何链接,将会有所帮助? 例: 我想像这样提取。 现场号 字段名称 字段类型(999或S9(4)或x(5)....) 归档类型添加(COMP,COMP-3等) 其他详细信息(将所有内容复制到“。”,不包括PIC子句)
答案 0 :(得分:2)
免责声明:我是ProLeap COBOL解析器的维护者。
您可以使用基于Java的ProLeap COBOL parser从COBOL文件中提取各种数据,例如level numbers,picture strings等。您还可以提取COMP,COMP-1等。来自使用条款like this。
ProLeap COBOL解析器是根据开源许可证授权的,因此可以免费使用。
答案 1 :(得分:0)
如果您使用为此目的而设计的COBOL解析器,那么这相对容易。
这样的解析器必须愿意不仅解析 整个程序,但要解析各种子部分,例如包含段落或数据声明的副本。这样的工具必须做好准备 处理真正的抄写本中的复杂性,例如字段声明,PIC字符串,REDEFINE,77和88级变量,用作初始化器的所有疯狂文字值,以及线条连续和COPY REPLACING的混乱/丑陋问题,或者它将只处理香草抄写本。根据副本的来源,您可能必须将文本处理为EBCDIC。实际上,构建一个解决所有这些问题的解析器需要做很多工作。
如果你试图使用正则表达式或其他无法执行无上下文解析的操作来破解它,那么生成的工具将无法处理任何复杂的情况。
一个好的解析器将生成一个抽象语法树,将所有这些细节捕获为数据结构 在内存中要处理(这是有效的)或作为XML文件 由其他工具处理。
我们的DMS COBOL parser可以处理上述所有内容并生成AST转储或XML等价物。
鉴于此COBOL字帖片段:
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'.
我们的COBOL解析器直接应用于副本文件, 生成以下抽象语法树:
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
**由于SO答案的大小限制,AST中间被删除**
| | (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>
一旦你拥有了树,走过树并提取有关COBOL符号声明的事实是相当简单的。
答案 2 :(得分:0)
免责声明:我保留cb2xml
您可以使用cb2xml来解析副本
请参阅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.
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>
中描述了 cb2xml 的一个有趣应用
答案 3 :(得分:0)
免责声明:我维持https://www.cobolcopybook.co.in
您好,请检查站点https://www.cobolcopybook.co.in,该站点专门用于分析COBOL抄写本。
例如您输入的抄写本是:
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).
然后输出将是:
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
我希望这能解决您的问题。
答案 4 :(得分:0)
对于python,请看一下Copybook软件包(https://github.com/zalmane/copybook)。它支持Copybook的大多数功能,包括REDEFINES和OCCURS以及多种PIC格式。
pip install copybook
root = copybook.parse_file('sample.cbl')
的维护者