-
Notifications
You must be signed in to change notification settings - Fork 78
/
Cobol.g4
3269 lines (2559 loc) · 72.2 KB
/
Cobol.g4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (C) 2017, Ulrich Wolffgang <[email protected]>
* All rights reserved.
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/*
* COBOL Grammar for ANTLR4
*
* This is a COBOL grammar, which is part of the COBOL parser at
* https://github.com/uwol/proleap-cobol-parser.
*
* The grammar passes the NIST test suite and has successfully been applied to
* numerous COBOL files from banking and insurance. To be used in conjunction
* with the provided preprocessor, which executes COPY and REPLACE statements.
*/
grammar Cobol;
startRule : compilationUnit EOF;
compilationUnit
: programUnit*
;
programUnit
: identificationDivision environmentDivision? dataDivision? procedureDivision? programUnit* endProgramStatement?
;
endProgramStatement
: END PROGRAM programName DOT_FS
;
// --- identification division --------------------------------------------------------------------
identificationDivision
: (IDENTIFICATION | ID) DIVISION DOT_FS programIdParagraph identificationDivisionBody*
;
identificationDivisionBody
: authorParagraph | installationParagraph | dateWrittenParagraph | dateCompiledParagraph | securityParagraph | remarksParagraph
;
// - program id paragraph ----------------------------------
programIdParagraph
: PROGRAM_ID DOT_FS programName (IS? (COMMON | INITIAL | LIBRARY | DEFINITION | RECURSIVE) PROGRAM?)? DOT_FS? commentEntry?
;
// - author paragraph ----------------------------------
authorParagraph
: AUTHOR DOT_FS commentEntry?
;
// - installation paragraph ----------------------------------
installationParagraph
: INSTALLATION DOT_FS commentEntry?
;
// - date written paragraph ----------------------------------
dateWrittenParagraph
: DATE_WRITTEN DOT_FS commentEntry?
;
// - date compiled paragraph ----------------------------------
dateCompiledParagraph
: DATE_COMPILED DOT_FS commentEntry?
;
// - security paragraph ----------------------------------
securityParagraph
: SECURITY DOT_FS commentEntry?
;
// - remarks paragraph ----------------------------------
remarksParagraph
: REMARKS DOT_FS commentEntry? END_REMARKS? DOT_FS?
;
// --- environment division --------------------------------------------------------------------
environmentDivision
: ENVIRONMENT DIVISION DOT_FS environmentDivisionBody*
;
environmentDivisionBody
: configurationSection | specialNamesParagraph | inputOutputSection
;
// -- configuration section ----------------------------------
configurationSection
: CONFIGURATION SECTION DOT_FS configurationSectionParagraph*
;
// - configuration section paragraph ----------------------------------
configurationSectionParagraph
: sourceComputerParagraph | objectComputerParagraph | specialNamesParagraph
// strictly, specialNamesParagraph does not belong into configurationSectionParagraph, but IBM-COBOL allows this
;
// - source computer paragraph ----------------------------------
sourceComputerParagraph
: SOURCE_COMPUTER DOT_FS (computerName (WITH? DEBUGGING MODE)? DOT_FS)?
;
// - object computer paragraph ----------------------------------
objectComputerParagraph
: OBJECT_COMPUTER DOT_FS (computerName objectComputerClause* DOT_FS)?
;
objectComputerClause
: memorySizeClause | diskSizeClause | collatingSequenceClause | segmentLimitClause | characterSetClause
;
memorySizeClause
: MEMORY SIZE? (integerLiteral | cobolWord) (WORDS | CHARACTERS | MODULES)?
;
diskSizeClause
: DISK SIZE? IS? (integerLiteral | cobolWord) (WORDS | MODULES)?
;
collatingSequenceClause
: PROGRAM? COLLATING? SEQUENCE (IS? alphabetName+) collatingSequenceClauseAlphanumeric? collatingSequenceClauseNational?
;
collatingSequenceClauseAlphanumeric
: FOR? ALPHANUMERIC IS? alphabetName
;
collatingSequenceClauseNational
: FOR? NATIONAL IS? alphabetName
;
segmentLimitClause
: SEGMENT_LIMIT IS? integerLiteral
;
characterSetClause
: CHARACTER SET DOT_FS
;
// - special names paragraph ----------------------------------
specialNamesParagraph
: SPECIAL_NAMES DOT_FS (specialNameClause+ DOT_FS)?
;
specialNameClause
: channelClause | odtClause | alphabetClause | classClause | currencySignClause | decimalPointClause | symbolicCharactersClause | environmentSwitchNameClause | defaultDisplaySignClause | defaultComputationalSignClause | reserveNetworkClause
;
alphabetClause
: alphabetClauseFormat1 | alphabetClauseFormat2
;
alphabetClauseFormat1
: ALPHABET alphabetName (FOR ALPHANUMERIC)? IS? (EBCDIC | ASCII | STANDARD_1 | STANDARD_2 | NATIVE | cobolWord | alphabetLiterals+)
;
alphabetLiterals
: literal (alphabetThrough | alphabetAlso+)?
;
alphabetThrough
: (THROUGH | THRU) literal
;
alphabetAlso
: ALSO literal+
;
alphabetClauseFormat2
: ALPHABET alphabetName FOR? NATIONAL IS? (NATIVE | CCSVERSION literal)
;
channelClause
: CHANNEL integerLiteral IS? mnemonicName
;
classClause
: CLASS className (FOR? (ALPHANUMERIC | NATIONAL))? IS? classClauseThrough+
;
classClauseThrough
: classClauseFrom ((THROUGH | THRU) classClauseTo)?
;
classClauseFrom
: identifier | literal
;
classClauseTo
: identifier | literal
;
currencySignClause
: CURRENCY SIGN? IS? literal (WITH? PICTURE SYMBOL literal)?
;
decimalPointClause
: DECIMAL_POINT IS? COMMA
;
defaultComputationalSignClause
: DEFAULT (COMPUTATIONAL | COMP)? (SIGN IS?)? (LEADING | TRAILING)? (SEPARATE CHARACTER?)
;
defaultDisplaySignClause
: DEFAULT_DISPLAY (SIGN IS?)? (LEADING | TRAILING) (SEPARATE CHARACTER?)?
;
environmentSwitchNameClause
: environmentName IS? mnemonicName environmentSwitchNameSpecialNamesStatusPhrase? | environmentSwitchNameSpecialNamesStatusPhrase
;
environmentSwitchNameSpecialNamesStatusPhrase
: ON STATUS? IS? condition (OFF STATUS? IS? condition)? | OFF STATUS? IS? condition (ON STATUS? IS? condition)?
;
odtClause
: ODT IS? mnemonicName
;
reserveNetworkClause
: RESERVE WORDS? LIST? IS? NETWORK CAPABLE?
;
symbolicCharactersClause
: SYMBOLIC CHARACTERS? (FOR? (ALPHANUMERIC | NATIONAL))? symbolicCharacters+ (IN alphabetName)?
;
symbolicCharacters
: symbolicCharacter+ (IS | ARE)? integerLiteral+
;
// -- input output section ----------------------------------
inputOutputSection
: INPUT_OUTPUT SECTION DOT_FS inputOutputSectionParagraph*
;
// - input output section paragraph ----------------------------------
inputOutputSectionParagraph
: fileControlParagraph | ioControlParagraph
;
// - file control paragraph ----------------------------------
fileControlParagraph
: FILE_CONTROL? (DOT_FS? fileControlEntry)* DOT_FS
;
fileControlEntry
: selectClause fileControlClause*
;
selectClause
: SELECT OPTIONAL? fileName
;
fileControlClause
: assignClause | reserveClause | organizationClause | paddingCharacterClause | recordDelimiterClause | accessModeClause | recordKeyClause | alternateRecordKeyClause | fileStatusClause | passwordClause | relativeKeyClause
;
assignClause
: ASSIGN TO? (DISK | DISPLAY | KEYBOARD | PORT | PRINTER | READER | REMOTE | TAPE | VIRTUAL | (DYNAMIC | EXTERNAL)? assignmentName | literal)
;
reserveClause
: RESERVE (NO | integerLiteral) ALTERNATE? (AREA | AREAS)?
;
organizationClause
: (ORGANIZATION IS?)? (LINE | RECORD BINARY | RECORD | BINARY)? (SEQUENTIAL | RELATIVE | INDEXED)
;
paddingCharacterClause
: PADDING CHARACTER? IS? (qualifiedDataName | literal)
;
recordDelimiterClause
: RECORD DELIMITER IS? (STANDARD_1 | IMPLICIT | assignmentName)
;
accessModeClause
: ACCESS MODE? IS? (SEQUENTIAL | RANDOM | DYNAMIC | EXCLUSIVE)
;
recordKeyClause
: RECORD KEY? IS? qualifiedDataName passwordClause? (WITH? DUPLICATES)?
;
alternateRecordKeyClause
: ALTERNATE RECORD KEY? IS? qualifiedDataName passwordClause? (WITH? DUPLICATES)?
;
passwordClause
: PASSWORD IS? dataName
;
fileStatusClause
: FILE? STATUS IS? qualifiedDataName qualifiedDataName?
;
relativeKeyClause
: RELATIVE KEY? IS? qualifiedDataName
;
// - io control paragraph ----------------------------------
ioControlParagraph
: I_O_CONTROL DOT_FS (fileName DOT_FS)? (ioControlClause* DOT_FS)?
;
ioControlClause
: rerunClause | sameClause | multipleFileClause | commitmentControlClause
;
rerunClause
: RERUN (ON (assignmentName | fileName))? EVERY (rerunEveryRecords | rerunEveryOf | rerunEveryClock)
;
rerunEveryRecords
: integerLiteral RECORDS
;
rerunEveryOf
: END? OF? (REEL | UNIT) OF fileName
;
rerunEveryClock
: integerLiteral CLOCK_UNITS?
;
sameClause
: SAME (RECORD | SORT | SORT_MERGE)? AREA? FOR? fileName+
;
multipleFileClause
: MULTIPLE FILE TAPE? CONTAINS? multipleFilePosition+
;
multipleFilePosition
: fileName (POSITION integerLiteral)?
;
commitmentControlClause
: COMMITMENT CONTROL FOR? fileName
;
// --- data division --------------------------------------------------------------------
dataDivision
: DATA DIVISION DOT_FS dataDivisionSection*
;
dataDivisionSection
: fileSection | dataBaseSection | workingStorageSection | linkageSection | communicationSection | localStorageSection | screenSection | reportSection | programLibrarySection
;
// -- file section ----------------------------------
fileSection
: FILE SECTION DOT_FS fileDescriptionEntry*
;
fileDescriptionEntry
: (FD | SD) fileName (DOT_FS? fileDescriptionEntryClause)* DOT_FS dataDescriptionEntry*
;
fileDescriptionEntryClause
: externalClause | globalClause | blockContainsClause | recordContainsClause | labelRecordsClause | valueOfClause | dataRecordsClause | linageClause | codeSetClause | reportClause | recordingModeClause
;
externalClause
: IS? EXTERNAL
;
globalClause
: IS? GLOBAL
;
blockContainsClause
: BLOCK CONTAINS? integerLiteral blockContainsTo? (RECORDS | CHARACTERS)?
;
blockContainsTo
: TO integerLiteral
;
recordContainsClause
: RECORD (recordContainsClauseFormat1 | recordContainsClauseFormat2 | recordContainsClauseFormat3)
;
recordContainsClauseFormat1
: CONTAINS? integerLiteral CHARACTERS?
;
recordContainsClauseFormat2
: IS? VARYING IN? SIZE? (FROM? integerLiteral recordContainsTo? CHARACTERS?)? (DEPENDING ON? qualifiedDataName)?
;
recordContainsClauseFormat3
: CONTAINS? integerLiteral recordContainsTo CHARACTERS?
;
recordContainsTo
: TO integerLiteral
;
labelRecordsClause
: LABEL (RECORD IS? | RECORDS ARE?) (OMITTED | STANDARD | dataName+)
;
valueOfClause
: VALUE OF valuePair+
;
valuePair
: systemName IS? (qualifiedDataName | literal)
;
dataRecordsClause
: DATA (RECORD IS? | RECORDS ARE?) dataName+
;
linageClause
: LINAGE IS? (dataName | integerLiteral) LINES? linageAt*
;
linageAt
: linageFootingAt | linageLinesAtTop | linageLinesAtBottom
;
linageFootingAt
: WITH? FOOTING AT? (dataName | integerLiteral)
;
linageLinesAtTop
: LINES? AT? TOP (dataName | integerLiteral)
;
linageLinesAtBottom
: LINES? AT? BOTTOM (dataName | integerLiteral)
;
recordingModeClause
: RECORDING MODE? IS? modeStatement
;
modeStatement
: cobolWord
;
codeSetClause
: CODE_SET IS? alphabetName
;
reportClause
: (REPORT IS? | REPORTS ARE?) reportName+
;
// -- data base section ----------------------------------
dataBaseSection
: DATA_BASE SECTION DOT_FS dataBaseSectionEntry*
;
dataBaseSectionEntry
: integerLiteral literal INVOKE literal
;
// -- working storage section ----------------------------------
workingStorageSection
: WORKING_STORAGE SECTION DOT_FS dataDescriptionEntry*
;
// -- linkage section ----------------------------------
linkageSection
: LINKAGE SECTION DOT_FS dataDescriptionEntry*
;
// -- communication section ----------------------------------
communicationSection
: COMMUNICATION SECTION DOT_FS (communicationDescriptionEntry | dataDescriptionEntry)*
;
communicationDescriptionEntry
: communicationDescriptionEntryFormat1 | communicationDescriptionEntryFormat2 | communicationDescriptionEntryFormat3
;
communicationDescriptionEntryFormat1
: CD cdName FOR? INITIAL? INPUT ((symbolicQueueClause | symbolicSubQueueClause | messageDateClause | messageTimeClause | symbolicSourceClause | textLengthClause | endKeyClause | statusKeyClause | messageCountClause) | dataDescName)* DOT_FS
;
communicationDescriptionEntryFormat2
: CD cdName FOR? OUTPUT (destinationCountClause | textLengthClause | statusKeyClause | destinationTableClause | errorKeyClause | symbolicDestinationClause)* DOT_FS
;
communicationDescriptionEntryFormat3
: CD cdName FOR? INITIAL I_O ((messageDateClause | messageTimeClause | symbolicTerminalClause | textLengthClause | endKeyClause | statusKeyClause) | dataDescName)* DOT_FS
;
destinationCountClause
: DESTINATION COUNT IS? dataDescName
;
destinationTableClause
: DESTINATION TABLE OCCURS integerLiteral TIMES (INDEXED BY indexName+)?
;
endKeyClause
: END KEY IS? dataDescName
;
errorKeyClause
: ERROR KEY IS? dataDescName
;
messageCountClause
: MESSAGE? COUNT IS? dataDescName
;
messageDateClause
: MESSAGE DATE IS? dataDescName
;
messageTimeClause
: MESSAGE TIME IS? dataDescName
;
statusKeyClause
: STATUS KEY IS? dataDescName
;
symbolicDestinationClause
: SYMBOLIC? DESTINATION IS? dataDescName
;
symbolicQueueClause
: SYMBOLIC? QUEUE IS? dataDescName
;
symbolicSourceClause
: SYMBOLIC? SOURCE IS? dataDescName
;
symbolicTerminalClause
: SYMBOLIC? TERMINAL IS? dataDescName
;
symbolicSubQueueClause
: SYMBOLIC? (SUB_QUEUE_1 | SUB_QUEUE_2 | SUB_QUEUE_3) IS? dataDescName
;
textLengthClause
: TEXT LENGTH IS? dataDescName
;
// -- local storage section ----------------------------------
localStorageSection
: LOCAL_STORAGE SECTION DOT_FS (LD localName DOT_FS)? dataDescriptionEntry*
;
// -- screen section ----------------------------------
screenSection
: SCREEN SECTION DOT_FS screenDescriptionEntry*
;
screenDescriptionEntry
: INTEGERLITERAL (FILLER | screenName)? (screenDescriptionBlankClause | screenDescriptionBellClause | screenDescriptionBlinkClause | screenDescriptionEraseClause | screenDescriptionLightClause | screenDescriptionGridClause | screenDescriptionReverseVideoClause | screenDescriptionUnderlineClause | screenDescriptionSizeClause | screenDescriptionLineClause | screenDescriptionColumnClause | screenDescriptionForegroundColorClause | screenDescriptionBackgroundColorClause | screenDescriptionControlClause | screenDescriptionValueClause | screenDescriptionPictureClause | (screenDescriptionFromClause | screenDescriptionUsingClause) | screenDescriptionUsageClause | screenDescriptionBlankWhenZeroClause | screenDescriptionJustifiedClause | screenDescriptionSignClause | screenDescriptionAutoClause | screenDescriptionSecureClause | screenDescriptionRequiredClause | screenDescriptionPromptClause | screenDescriptionFullClause | screenDescriptionZeroFillClause)* DOT_FS
;
screenDescriptionBlankClause
: BLANK (SCREEN | LINE)
;
screenDescriptionBellClause
: BELL | BEEP
;
screenDescriptionBlinkClause
: BLINK
;
screenDescriptionEraseClause
: ERASE (EOL | EOS)
;
screenDescriptionLightClause
: HIGHLIGHT | LOWLIGHT
;
screenDescriptionGridClause
: GRID | LEFTLINE | OVERLINE
;
screenDescriptionReverseVideoClause
: REVERSE_VIDEO
;
screenDescriptionUnderlineClause
: UNDERLINE
;
screenDescriptionSizeClause
: SIZE IS? (identifier | integerLiteral)
;
screenDescriptionLineClause
: LINE (NUMBER? IS? (PLUS | PLUSCHAR | MINUSCHAR))? (identifier | integerLiteral)
;
screenDescriptionColumnClause
: (COLUMN | COL) (NUMBER? IS? (PLUS | PLUSCHAR | MINUSCHAR))? (identifier | integerLiteral)
;
screenDescriptionForegroundColorClause
: (FOREGROUND_COLOR | FOREGROUND_COLOUR) IS? (identifier | integerLiteral)
;
screenDescriptionBackgroundColorClause
: (BACKGROUND_COLOR | BACKGROUND_COLOUR) IS? (identifier | integerLiteral)
;
screenDescriptionControlClause
: CONTROL IS? identifier
;
screenDescriptionValueClause
: (VALUE IS?) literal
;
screenDescriptionPictureClause
: (PICTURE | PIC) IS? pictureString
;
screenDescriptionFromClause
: FROM (identifier | literal) screenDescriptionToClause?
;
screenDescriptionToClause
: TO identifier
;
screenDescriptionUsingClause
: USING identifier
;
screenDescriptionUsageClause
: (USAGE IS?) (DISPLAY | DISPLAY_1)
;
screenDescriptionBlankWhenZeroClause
: BLANK WHEN? ZERO
;
screenDescriptionJustifiedClause
: (JUSTIFIED | JUST) RIGHT?
;
screenDescriptionSignClause
: (SIGN IS?)? (LEADING | TRAILING) (SEPARATE CHARACTER?)?
;
screenDescriptionAutoClause
: AUTO | AUTO_SKIP
;
screenDescriptionSecureClause
: SECURE | NO_ECHO
;
screenDescriptionRequiredClause
: REQUIRED | EMPTY_CHECK
;
screenDescriptionPromptClause
: PROMPT CHARACTER? IS? (identifier | literal) screenDescriptionPromptOccursClause?
;
screenDescriptionPromptOccursClause
: OCCURS integerLiteral TIMES?
;
screenDescriptionFullClause
: FULL | LENGTH_CHECK
;
screenDescriptionZeroFillClause
: ZERO_FILL
;
// -- report section ----------------------------------
reportSection
: REPORT SECTION DOT_FS reportDescription*
;
reportDescription
: reportDescriptionEntry reportGroupDescriptionEntry+
;
reportDescriptionEntry
: RD reportName reportDescriptionGlobalClause? (reportDescriptionPageLimitClause reportDescriptionHeadingClause? reportDescriptionFirstDetailClause? reportDescriptionLastDetailClause? reportDescriptionFootingClause?)? DOT_FS
;
reportDescriptionGlobalClause
: IS? GLOBAL
;
reportDescriptionPageLimitClause
: PAGE (LIMIT IS? | LIMITS ARE?)? integerLiteral (LINE | LINES)?
;
reportDescriptionHeadingClause
: HEADING integerLiteral
;
reportDescriptionFirstDetailClause
: FIRST DETAIL integerLiteral
;
reportDescriptionLastDetailClause
: LAST DETAIL integerLiteral
;
reportDescriptionFootingClause
: FOOTING integerLiteral
;
reportGroupDescriptionEntry
: reportGroupDescriptionEntryFormat1 | reportGroupDescriptionEntryFormat2 | reportGroupDescriptionEntryFormat3
;
reportGroupDescriptionEntryFormat1
: integerLiteral dataName reportGroupLineNumberClause? reportGroupNextGroupClause? reportGroupTypeClause reportGroupUsageClause? DOT_FS
;
reportGroupDescriptionEntryFormat2
: integerLiteral dataName? reportGroupLineNumberClause? reportGroupUsageClause DOT_FS
;
reportGroupDescriptionEntryFormat3
: integerLiteral dataName? (reportGroupPictureClause | reportGroupUsageClause | reportGroupSignClause | reportGroupJustifiedClause | reportGroupBlankWhenZeroClause | reportGroupLineNumberClause | reportGroupColumnNumberClause | (reportGroupSourceClause | reportGroupValueClause | reportGroupSumClause | reportGroupResetClause) | reportGroupIndicateClause)* DOT_FS
;
reportGroupBlankWhenZeroClause
: BLANK WHEN? ZERO
;
reportGroupColumnNumberClause
: COLUMN NUMBER? IS? integerLiteral
;
reportGroupIndicateClause
: GROUP INDICATE?
;
reportGroupJustifiedClause
: (JUSTIFIED | JUST) RIGHT?
;
reportGroupLineNumberClause
: LINE? NUMBER? IS? (reportGroupLineNumberNextPage | reportGroupLineNumberPlus)
;
reportGroupLineNumberNextPage
: integerLiteral (ON? NEXT PAGE)?
;
reportGroupLineNumberPlus
: PLUS integerLiteral
;
reportGroupNextGroupClause
: NEXT GROUP IS? (integerLiteral | reportGroupNextGroupNextPage | reportGroupNextGroupPlus)
;
reportGroupNextGroupPlus
: PLUS integerLiteral
;
reportGroupNextGroupNextPage
: NEXT PAGE
;
reportGroupPictureClause
: (PICTURE | PIC) IS? pictureString
;
reportGroupResetClause
: RESET ON? (FINAL | dataName)
;
reportGroupSignClause
: SIGN IS? (LEADING | TRAILING) SEPARATE CHARACTER?
;
reportGroupSourceClause
: SOURCE IS? identifier
;
reportGroupSumClause
: SUM identifier (COMMACHAR? identifier)* (UPON dataName (COMMACHAR? dataName)*)?
;
reportGroupTypeClause
: TYPE IS? (reportGroupTypeReportHeading | reportGroupTypePageHeading | reportGroupTypeControlHeading | reportGroupTypeDetail | reportGroupTypeControlFooting | reportGroupTypePageFooting | reportGroupTypeReportFooting)
;
reportGroupTypeReportHeading
: REPORT HEADING | RH
;
reportGroupTypePageHeading
: PAGE HEADING | PH
;
reportGroupTypeControlHeading
: (CONTROL HEADING | CH) (FINAL | dataName)
;
reportGroupTypeDetail
: DETAIL | DE
;
reportGroupTypeControlFooting
: (CONTROL FOOTING | CF) (FINAL | dataName)
;
reportGroupUsageClause
: (USAGE IS?)? (DISPLAY | DISPLAY_1)
;
reportGroupTypePageFooting
: PAGE FOOTING | PF
;
reportGroupTypeReportFooting
: REPORT FOOTING | RF
;
reportGroupValueClause
: VALUE IS? literal
;
// -- program library section ----------------------------------
programLibrarySection
: PROGRAM_LIBRARY SECTION DOT_FS libraryDescriptionEntry*
;
libraryDescriptionEntry
: libraryDescriptionEntryFormat1 | libraryDescriptionEntryFormat2
;
libraryDescriptionEntryFormat1
: LD libraryName EXPORT libraryAttributeClauseFormat1? libraryEntryProcedureClauseFormat1?
;
libraryDescriptionEntryFormat2
: LB libraryName IMPORT libraryIsGlobalClause? libraryIsCommonClause? (libraryAttributeClauseFormat2 | libraryEntryProcedureClauseFormat2)*
;
libraryAttributeClauseFormat1
: ATTRIBUTE (SHARING IS? (DONTCARE | PRIVATE | SHAREDBYRUNUNIT | SHAREDBYALL))?
;
libraryAttributeClauseFormat2
: ATTRIBUTE libraryAttributeFunction? (LIBACCESS IS? (BYFUNCTION | BYTITLE))? libraryAttributeParameter? libraryAttributeTitle?
;
libraryAttributeFunction
: FUNCTIONNAME IS literal
;
libraryAttributeParameter
: LIBPARAMETER IS? literal
;
libraryAttributeTitle
: TITLE IS? literal
;
libraryEntryProcedureClauseFormat1
: ENTRY_PROCEDURE programName libraryEntryProcedureForClause?
;
libraryEntryProcedureClauseFormat2
: ENTRY_PROCEDURE programName libraryEntryProcedureForClause? libraryEntryProcedureWithClause? libraryEntryProcedureUsingClause? libraryEntryProcedureGivingClause?
;
libraryEntryProcedureForClause
: FOR literal
;
libraryEntryProcedureGivingClause
: GIVING dataName
;
libraryEntryProcedureUsingClause
: USING libraryEntryProcedureUsingName+
;
libraryEntryProcedureUsingName
: dataName | fileName
;
libraryEntryProcedureWithClause
: WITH libraryEntryProcedureWithName+
;
libraryEntryProcedureWithName
: localName | fileName
;
libraryIsCommonClause
: IS? COMMON
;
libraryIsGlobalClause
: IS? GLOBAL
;
// data description entry ----------------------------------
dataDescriptionEntry
: dataDescriptionEntryFormat1 | dataDescriptionEntryFormat2 | dataDescriptionEntryFormat3 | dataDescriptionEntryExecSql
;
dataDescriptionEntryFormat1
: (INTEGERLITERAL | LEVEL_NUMBER_77) (FILLER | dataName)? (dataRedefinesClause | dataIntegerStringClause | dataExternalClause | dataGlobalClause | dataTypeDefClause | dataThreadLocalClause | dataPictureClause | dataCommonOwnLocalClause | dataTypeClause | dataUsingClause | dataUsageClause | dataValueClause | dataReceivedByClause | dataOccursClause | dataSignClause | dataSynchronizedClause | dataJustifiedClause | dataBlankWhenZeroClause | dataWithLowerBoundsClause | dataAlignedClause | dataRecordAreaClause)* DOT_FS
;
dataDescriptionEntryFormat2
: LEVEL_NUMBER_66 dataName dataRenamesClause DOT_FS
;
dataDescriptionEntryFormat3
: LEVEL_NUMBER_88 conditionName dataValueClause DOT_FS
;
dataDescriptionEntryExecSql
: EXECSQLLINE+ DOT_FS?
;
dataAlignedClause
: ALIGNED
;
dataBlankWhenZeroClause
: BLANK WHEN? (ZERO | ZEROS | ZEROES)
;
dataCommonOwnLocalClause
: COMMON | OWN | LOCAL
;
dataExternalClause
: IS? EXTERNAL (BY literal)?
;
dataGlobalClause
: IS? GLOBAL
;
dataIntegerStringClause
: INTEGER | STRING
;
dataJustifiedClause
: (JUSTIFIED | JUST) RIGHT?
;
dataOccursClause
: OCCURS (identifier | integerLiteral) dataOccursTo? TIMES? dataOccursDepending? (dataOccursSort | dataOccursIndexed)*
;
dataOccursTo
: TO integerLiteral