-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobal.h
executable file
·1268 lines (1173 loc) · 40.3 KB
/
global.h
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
/*
* File: global.h
* Created Date: Tuesday August 26th 2014
* Author: Deepak Purandare
* -----
* Last Modified: Tuesday August 26th 2014 6:45:39 pm
* Modified By: Deepak Purandare - <deepak_purandare@hotmail.com>
* -----
* Copyright (c) 2019 Purndare Consulting
* This software is made available under GNU General Public License Version 3
* Visit http://www.gnu.org/licenses/gpl-3.0.html for terms of usage.
* Created on November 16, 2013, 1:43 PM
*/
#ifndef GLOBAL_H
#define GLOBAL_H
/***********************************
* Defines and enumerations *
***********************************/
#define BUFSIZE 2048
#define SMALL_BUFF 256
extern char char_buffer[BUFSIZE];
// Data division items
enum data_div_items{
CBD_FILE_SECTION = 1,
CBD_WORKING_STORGAGE_SECTION = 2,
CBD_LINKAGE_SECTION = 3,
CBD_COMMUNICATION_SECTION = 4,
CBD_SCREEN_SECTION = 5,
CBD_REPORT_SECTION = 6,
CBD_LOCALSTORAGE_SECTION = 7
};
// Procedure item types...
enum proc_def_types {
CB_PD_ITEM = 0,
CB_PD_SECTION = 1,
CB_PD_PARAGRAPH = 2,
CB_PD_SENTENCE = 3,
CB_PD_STATEMENT = 4,
CB_PD_STOP = 5,
CB_PD_SET = 6,
CB_PD_MOVE = 7,
CB_PD_IFELSE = 8,
CB_PD_EVALUATE = 9,
CB_PD_PERFORM = 10,
CB_PD_SEARCH = 11,
CB_PD_READ = 12,
CB_PD_WRITE = 13,
CB_PD_DELETE = 14,
CB_PD_RETURN = 15
};
enum sign_clause_enum {
CB_NOT_SPECIFICD = 0,
CB_LEADING = 101,
CB_TRAILING = 102
};
// type definitions...
enum datanames {
CB_NULL = 0,
CB_INT = 1,
CB_FLOAT = 2,
CB_BOOLEAN = 3,
CB_N_LITERAL = 4,
CB_C_LITERAL = 5,
CB_CHARPTR = 6,
CB_NUMERIC = 7,
CB_LITERAL = 8,
CB_HEX = 9,
CB_HEX_NO = 10,
CB_IDENTIFIER = 11,
CB_LENGTH = 12,
CB_ADDRESS = 13,
CB_SPECIAL = 14,
CB_FUNCTION = 15,
CB_ID_UNITVAL = 16,
CB_IMPLICIT = 17,
CB_LINES = 18,
CB_PAGES = 19,
CB_LINE_NEXTPAGE = 20,
CB_SIZE = 21,
CB_ADDRESS_IN = 22,
CB_ADDRESS_OF = 23
};
enum _common_items {
CB_ON = 1,
CB_OFF = 2,
CB_UP = 3,
CB_DOWN = 4,
CB_TRUE = 5,
CB_FALSE= 6,
CB_COMMON = 7,
CB_INITIAL = 8
};
enum devicenames {
CB_DISPLAY = 1,
CB_INPUT = 2,
CB_OUTPUT = 3,
CB_INPUT_OUTPUT = 4,
CB_RANDOM = 5,
CB_TAPE = 6
};
enum filetypeenum {
CB_FT_INPUT = 2,
CB_FT_OUTPUT = 3,
CB_FT_I_O = 4,
CB_FT_EXTEND = 5
};
enum fileaccesstype{
CB_FL_UNDEFINED = 0,
CB_FL_LINE_SEQUENTIAL = 1,
CB_FL_SEQUENTIAL = 2,
CB_FL_BIN_SEQUENTIAL = 3,
CB_FL_RELATIVE = 4,
CB_FL_INDEXED = 5
};
enum fileaccessmode {
CB_FM_SEQUENTIAL = 1,
CB_FM_RANDOM = 2,
CB_FM_DYNAMIC = 3
};
enum lockmodeenum {
CB_LM_NONE = 0,
CB_LM_MAN_ON_MUL_REC = 1,
CB_LM_AUT_ON_MUL_REC = 2,
CB_LM_EXCLUSIVE = 3
};
// Picture specific details
#define PIC_ALPHABETIC 0x01
#define PIC_NUMERIC 0x02
#define PIC_NATIONAL 0x04
#define PIC_EDITED 0x08
#define PIC_ALPHANUMERIC (PIC_ALPHABETIC | PIC_NUMERIC)
#define PIC_ALPHABETIC_EDITED (PIC_ALPHABETIC | PIC_EDITED)
#define PIC_ALPHANUMERIC_EDITED (PIC_ALPHANUMERIC | PIC_EDITED)
#define PIC_NUMERIC_EDITED (PIC_NUMERIC | PIC_EDITED)
#define PIC_NATIONAL_EDITED (PIC_NATIONAL | PIC_EDITED)
enum categoryname {
CB_CAT_NONE = 0,
CB_CAT_ALPHABETIC = 1,
CB_CAT_ALPHANUMERIC = 2,
CB_CAT_ALPHANUMERIC_EDITED = 3,
CB_CAT_DATA_POINTER = 4,
CB_CAT_NUMERIC = 5,
CB_CAT_NUMERIC_EDITED = 6,
CB_CAT_ALL = 7,
CB_CAT_BOOLEAN = 8,
CB_CAT_NATIONAL = 9,
CB_CAT_NATIONAL_EDITED = 10,
CB_CAT_OBJ_REF = 11,
CB_CAT_INDEX = 12
};
enum special_lit_enum {
CB_SL_SPACES = 1,
CB_SL_ZERO = 2,
CB_SL_QUOTES = 3,
CB_SL_HIGHVALUES = 4,
CB_SL_LOWVALUES = 5,
CB_SL_NULL = 6,
CB_SL_TRUE = 7,
CB_SL_FALSE = 8,
CB_SL_RECORDS = 9,
CB_SL_CHARACTERS = 10,
};
enum usage_clause_enum {
CB_UC_BINARY = 1,
CB_UC_COMP = 2,
CB_UC_COMP_1 = 3,
CB_UC_COMP_2 = 4,
CB_UC_COMP_3 = 5,
CB_UC_COMP_4 = 6,
CB_UC_COMP_5 = 7,
CB_UC_COMP_6 = 8,
CB_UC_DISPLAY = 9,
CB_UC_INDEX = 10,
CB_UC_PACKED_DECIMAL = 11,
CB_UC_POINTER = 12
};
enum synchronized {
CB_SY_UNDEFINED = 0,
CB_SY_LEFT = 1,
CB_SY_RIGHT = 2
};
enum nameorfiller {
CB_EMPTY_NF = 0,
CB_NAME = 1,
CB_FILLER = 2
};
enum withclause_enum {
CB_WC_AT_POS = 1,
CB_WC_AUTO = 2,
CB_WC_AUTO_SKIP = 3,
CB_WC_BEEP = 4,
CB_WC_NO_BEEP = 5,
CB_WC_BEFORE_TIME = 6,
CB_WC_BELL = 7,
CB_WC_NO_BELL = 8,
CB_WC_BLANK = 9,
CB_WC_BLINK = 10,
CB_WC_CONTROL = 11,
CB_WC_CONVERT = 12,
CB_WC_CURSER = 13,
CB_WC_ECHO = 14,
CB_WC_ERASE_EOL = 15,
CB_WC_ERASE_EOS = 16,
CB_WC_HIGH = 17,
CB_WC_HIGHLIGHT = 18,
CB_WC_LOW = 19,
CB_WC_LOWLIGHT = 20,
CB_WC_MODE_IS_BLOCK = 21,
CB_WC_OFF = 22,
CB_WC_PROMPT_CHAR = 23,
CB_WC_REVERSE = 24,
CB_WC_SECURE = 25,
CB_WC_SIZE = 26,
CB_WC_TAB = 27,
CB_WC_UPDATE = 28
};
enum with_clause_at_loc {
CB_WC_AT_LINE = 29,
CB_WC_AT_COLUMN = 30,
CB_WC_AT_POSITION = 31
};
enum implicit_def_clause_enum {
CB_ID_CENTURY_DATE = 1,
CB_ID_CENTURY_DAY = 2,
CB_ID_DATE = 3,
CB_ID_DATE_YYYYMMDD = 4,
CB_ID_DATE_TIME = 5,
CB_ID_DATE_COMPILED = 6,
CB_ID_DAY = 7,
CB_ID_DAY_YYYYDDD = 8,
CB_ID_DAY_TIME = 9,
CB_ID_DAY_WEEK = 10,
CB_ID_TIME = 11,
CB_ID_ESCAPE = 12,
CB_ID_EXCEPTION = 13
};
enum escape_exception_enum {
CB_ESCAPE = 1,
CB_EXCEPTION = 2,
CB_ERROR = 3
};
enum relational_operator{
CB_GT = 1,
CB_GE = 2,
CB_LT = 3,
CB_LE = 4,
CB_EQ = 5,
CB_NE = 6,
CB_FIRST = 7,
CB_LAST = 8
};
enum class_item {
CB_CI_NUMERIC = 1,
CB_CI_ALPHABETIC = 2,
CB_CI_ALPHA_UPPER = 3,
CB_CI_ALPHA_LOWER = 4
};
enum sign_indicator {
CB_SI_POSITIVE = 1,
CB_SI_NEGATIVE = 2,
CB_SI_ZERO = 3,
CB_SI_NON_ZERO = 4 // this is synthesized.
};
enum logical_operator {
CB_LO_AND = 1,
CB_LO_OR = 2
};
// CobFileDescription
enum fieldlistlocation {
CB_FILE_SECTION = 1,
CB_WS_SECTION = 2
};
enum arithm_expr_type_enum {
CB_AE_GNAME = 1,
CB_AE_CLASS = 2,
CB_AE_SIMPLE = 3,
CB_AE_QUOTE_EXP = 4,
CB_AE_UNRY = 5,
};
enum arithmetic_operator_enum{
CB_AO_PLUS = 1,
CB_AO_MINUS = 2,
CB_AO_MULTIPLY = 3,
CB_AO_DIVIDE = 4,
CB_AO_POWER = 5,
CB_AO_COLON = 6
};
enum rel_cond_type_enum {
CB_RC_SINGLE = 1,
CB_RC_SIMPLE = 2,
CB_RC_SIGN = 3,
CB_RC_CLASS = 4
};
enum simp_cond_type_enum {
CB_SC_REL = 1,
CB_SC_ID = 2,
CB_SC_COND = 3
};
enum abbr_item_type_enum {
CB_AI_ARITHM_EXPR = 1,
CB_AI_AE_AR = 2
};
enum before_after_enum {
CB_ABSENT = 0,
CB_BEFORE = 1,
CB_AFTER = 2
};
/***********************************
* structures *
***********************************/
typedef struct idvalStru {
char * idStr;
void * inofdata; // c++ list object ptr
void * subscripts; // this is c++ list object pointer
int rounded; // default to 0
//struct refnumbers * refs; // this is modified. The subscripts will hold the references as well.
} id_valwithopt;
// used with gname...
typedef struct valueType{
int type;
int intVal;
float floatVal;
id_valwithopt * idval;
char * strVal; /* identifier, dquote and squote strings, */
int splVal;
int allflag; /* default 0 - false */
int rounded; /* defaunt 8 - false */
} valtype, literalval;
// Use this with xval. check and decide if valueType is good enough.
typedef struct xvaldata {
int usetype; /* used only in specific cases */
int type;
int imp; /* for implicit info */
id_valwithopt * identifier;
int rounded; // 0 or 1
literalval * litval;
} xvaltype;
enum subscript_type {
// check first if required...
// looks like the sign should handle it.
CB_SUB_SUB = 1,
CB_SUB_REF = 2
};
enum subscript_item_type {
CB_SUBITEM_ID = 1,
CB_SUBITEM_LIT = 2,
CB_SUBITEM_SUBITEM = 3,
CB_SUBITEM_ADD = 4,
CB_SUBITEM_SUBTRACT = 5,
CB_SUBITEM_REF = 6
};
struct _subscript_item {
enum subscript_item_type type;
char * idstr;
struct valueType * litval;
struct _subscript_item * subitem;
int oper;
struct _subscript_item * subitem2;
};
/*
typedef struct _subscript{
valtype * value;
int sign; // 1 - plus, 2- minus, 3- colon
struct _subscript * next;
}subscript;
typedef struct refnumbers {
struct _subscript * left;
int right;
}ref_numbers;
*/
/***********************************
* Condition and Expression *
***********************************/
struct _condition {
struct _combinable_condition * comb_cond;
struct _comb_abbr_cond_list * comb_abri_cond_lst;
};
struct _comb_abbr_cond_list {
int count;
void * item_list;
};
enum comb_cond_item_enum{
CB_COMB_COND_COMB = 1,
CB_COMB_COND_ABBR = 2
};
struct _combinable_abbrivated_condition {
int op; // AND-OR
int type; // combi or abbri
struct _combinable_condition * comb_cond;
struct _abbriviation_rest * abbri_rest;
};
struct _combinable_condition {
int is_not;
struct _simple_condition * simp_cond;
};
struct _abbriviation_rest {
int count;
void * item_list;
};
struct _abbriviation_item {
int type;
int opt_not;
int rel_op;
struct _arithmetic_expression * arithm_stmt;
struct _abbriviation_rest * abbr_rest;
};
struct _simple_condition {
int type;
struct _relational_condition * rel_condition;
struct idvalStru * identifier;
struct _condition * cond;
};
struct _relational_condition {
int type; // regular, sign cond, class item
int is_not;
int rel_op;
struct _arithmetic_expression * left;
struct _arithmetic_expression * right;
int sign_cond;
int class_item;
};
struct _arithmetic_expression {
int exp_type;
struct valueType * val;
int class_item;
int oper;
struct _arithmetic_expression * left;
struct _arithmetic_expression * right;
int unary_sign; // 0 - none, 1- +, 2- -
};
// Picture specific details...
struct _picture_info {
char *orig; /* original picture string */
char *str; /* packed picture string */
int size; /* byte size */
int lenstr; /* length of picture string */
enum categoryname category; /* field category */
unsigned char digits; /* the number of digit places */
signed char scale; /* 1/10^scale */
unsigned char have_sign; /* have 'S' */
unsigned char spare; /* spare */
};
#ifdef __cplusplus
extern "C" {
#endif
/***********************************
* function declarations *
***********************************/
// initialization and release operations for the c++ system
// handling of the current initialization and release
int initialize_cpp(void);
int release_cpp(void);
// Project related functions
// Project dump...
void dumpProject();
void generate();
void analyze();
void setTargetPath(const char * str);
const char * getTargetPath();
void setIncludePath(const char *str);
const char * getIncludePath();
void setGenConfigPath(const char *str);
const char * getGenConfigPath();
void setFirstFile(char * pfilename);
const char * getFirstFile();
// Parser and dump related functions
int gethash( const char * s);
char * getJname(const char * pname);
char * start_buffer(char *str);
char * append_buffer(char *str);
char * strdupx(const char * s);
void dump_id(struct idvalStru * pid);
void dump_idlist(void * plst);
//void dump_refnumbers(struct refnumbers * pref);
void dump_subscript_list(void * plst);
void dump_subscript(struct _subscript_item * pitem);
void dump_value(struct valueType * pval);
const char * value_string(struct valueType * pval);
void dump_special_literal(int pval);
void dump_xval(struct xvaldata * pxval);
void delete_id(struct idvalStru * pid);
void delete_idlist(void * plst);
void delete_subscripts_list(void * plst);
void delete_subscript(struct _subscript_item * plst);
//void delete_refnumbers(struct refnumbers * pref);
void delete_value(struct valueType * pval);
void delete_xval(struct xvaldata * pxval);
struct _picture_info * construct_picture(char * str);
int datatype_from_category(int pcat);
struct _condition * construct_condition(struct _combinable_condition * pcomb_cond,
struct _comb_abbr_cond_list * pcomb_abri_list);
struct _comb_abbr_cond_list * start_comb_abri_list(struct _combinable_abbrivated_condition * pabbr_item);
struct _comb_abbr_cond_list * add_comb_abri_list(
struct _comb_abbr_cond_list * list,
struct _combinable_abbrivated_condition * pitem);
struct _combinable_abbrivated_condition * construct_comb_abri_cond(
struct _combinable_condition * pcomb_cond,
struct _abbriviation_rest * pabbr_rest);
struct _combinable_abbrivated_condition * update_comb_abri_cond(
int and_or,
struct _combinable_abbrivated_condition * pcomb_abri);
struct _combinable_condition * construct_comb_cond(
int pnot,
struct _simple_condition * psimp_cond);
struct _abbriviation_rest * start_abri_item_list(struct _abbriviation_item * pitem);
struct _abbriviation_rest * add_abri_item_list(struct _abbriviation_rest * plist,
struct _abbriviation_item * pabbr_item);
struct _abbriviation_item * construct_Abbr_item(
struct _arithmetic_expression * parithm_expr,
struct _abbriviation_rest * pabbr_rest);
struct _abbriviation_item * update_abbr_item(int pnot,
int prel_op, struct _abbriviation_item * pitem);
struct _simple_condition * construct_simp_cond(int ptype, struct _relational_condition * prel_cond);
struct _simple_condition * construct_simp_cond_id( int ptype, struct idvalStru * pid);
struct _simple_condition * construct_simp_cond_cond( int ptype, struct _condition * pcond);
struct _relational_condition * construct_rel_cond(int ptype,
int pis_not,
int prel_op,
struct _arithmetic_expression * pleft,
struct _arithmetic_expression * pright);
struct _relational_condition * construct_rel_cond_sign( int ptype, int psign_cond);
struct _relational_condition * construct_rel_cond_class( int ptype,
int pis_not,
struct _arithmetic_expression * pleft,
int pclass_item);
// Condition and expression
struct _arithmetic_expression * construct_arithm_expr_gname(int ptype, valtype * pVal);
struct _arithmetic_expression * construct_arithm_expr_class(int ptype, int pclass_item);
struct _arithmetic_expression * construct_arithm_expr_simple(int ptype, int poper,
struct _arithmetic_expression * pleft,
struct _arithmetic_expression * pright);
struct _arithmetic_expression * construct_arithm_expr_unary(int ptype, int poper,
struct _arithmetic_expression * pleft);
struct _arithmetic_expression * construct_arithm_expr_bracket(int ptype,
struct _arithmetic_expression * pleft);
int reverse_sign(int porig);
int reverse_logical_op(int porig);
void delete_condition(struct _condition * pcond);
void delete_combinable_condition(struct _combinable_condition * pcombcond);
void delete_comb_abri_cond_list(struct _comb_abbr_cond_list * plst);
void delete_simple_condition(struct _simple_condition * psimpcond);
void delete_comb_abri_cond(struct _combinable_abbrivated_condition * pitem);
void delete_abbrivation_rest(struct _abbriviation_rest * pitem);
void delete_arithmetic_expression(struct _arithmetic_expression * paeitem);
void delete_relational_condition(struct _relational_condition * prelcond);
void dump_condition(struct _condition * pcond);
void dump_combinable_condition(struct _combinable_condition * pcombcond);
void dump_comb_abri_cond_list(struct _comb_abbr_cond_list * plst);
void dump_simple_condition(struct _simple_condition * psimpcond);
void dump_comb_abri_cond(struct _combinable_abbrivated_condition * pitem);
void dump_abbrivation_rest(struct _abbriviation_rest * pitem);
void dump_arithmetic_expression(struct _arithmetic_expression * paeitem);
void dump_relational_condition(struct _relational_condition * prelcond);
void dump_op(int pop);
void dump_rel_op(int op);
/***********************************
* parser related items *
***********************************/
extern int yylineno;
int yylex(void);
extern int yyparse(void);
extern void yyerror(char *s, ...);
//extern dataclausetype * dataClauseCurrent;
/***********************************
* basic data, gname, xval *
***********************************/
// list of identifiers or literal values
void * startList(char *);
void * addListItem(void *, char *);
void delete_strlist(void * plst);
void dump_strlist(void * plst);
// list of identifiers or literal values
void * startList(char *);
void * addListItem(void *, char *);
// common functions
struct xvaldata * construct_xval( int valtype, void * valptr );
struct valueType * negate_numeric(literalval * pval);
struct valueType * get_numliteral( double dval, int pival);
struct valueType * get_charliteral( char * pstr, int pival );
struct valueType * get_specialliteral( int pval, int pival );
valtype * construct_gname_id(id_valwithopt * pval);
valtype * construct_gname_function(id_valwithopt * pval, int type);
// functions used in parser to construct the data structures
struct idvalStru * construct_identifier_1(char * str, void * inof,
void * subscripts);
struct _subscript_item * cons_subscript_item(enum subscript_item_type ptype,
char * pidstr, struct valueType * plitval,
struct _subscript_item * psubitem, int poper,
struct _subscript_item * subitem2);
void * start_subscript_list(struct _subscript_item * prev);
void * add_subscriptlist_item(void * lst, struct _subscript_item * prev);
/****************************************
* Identification Division *
****************************************/
enum _ident_option_type {
CB_IDD_AUTHOR = 1,
CB_IDD_INSTALL = 2,
CB_IDD_DATEWRI = 3,
CB_IDD_DATECOM = 4,
CB_IDD_SECURITY = 5,
CB_IDD_REMARKS = 6
};
struct _id_option {
enum _ident_option_type type;
char * val;
};
struct _id_option * cons_id_option(enum _ident_option_type ptype, char * pstr);
void * cons_identification_division(char * pprogname, int pcomm_initial,
void * pother_optlist, char * pfileName);
/****************************************
* Environment Division *
****************************************/
enum _special_names_enum {
CB_SN_CURRENCY = 1,
CB_SN_DECIMALPT = 2
};
struct _special_names {
int type;
char * currencysign;
};
struct _special_names * cons_special_names(int ptype, char * pcurrencysign);
void delete_special_names_list(void * plst);
void dump_special_names_list(void * plst);
enum _memory_options_enum {
CB_MEM_WORDS = 1,
CB_MEM_CHARS = 2,
CB_MEM_MODULE = 3
};
struct _intpair {
int first;
int second;
};
struct _intpair * cons_intpair(int pfirst, int psecond);
enum _obj_comp_clause_type {
CB_OBJCOMP_MEM = 1,
CB_OBJCOMP_SEQ = 2,
CB_OBJCOMP_SEG = 3
};
struct _obj_comp_clause {
enum _obj_comp_clause_type type;
struct _intpair * comp_memory;
char * comp_sequence;
int comp_segment;
};
struct _obj_comp_clause * cons_obj_comp_clause(enum _obj_comp_clause_type ptype,
struct _intpair * pintpair, char * pstr, int ival);
struct _object_computer_clauses {
char * comp_name;
void * obj_comp_clause_lst; // struct _obj_comp_clause * list
};
void delete_obj_comp_clause_lst(void * plst);
void delete_object_computer_clauses(struct _object_computer_clauses * item);
void dump_obj_comp_clause_lst(void * plst);
void dump_object_compute_clauses(struct _object_computer_clauses * item);
struct _object_computer_clauses * cons_object_computer_clauses(char * pname, void * plst);
struct _intcharpair {
char * strval;
int intval;
};
struct _intcharpair * cons_intchar_pair(char * pstr, int ival);
enum _config_section_type {
CB_CONFIG_SEC_SOURCE = 1,
CB_CONFIG_SEC_OBJECT = 2,
CB_CONFIG_SEC_SPNAMES = 3,
CB_CONFIG_SEC_REPOSITORY = 4
};
struct _config_section_option {
enum _config_section_type type;
struct _intcharpair * source_comp_opt;
struct _object_computer_clauses * obj_comp_opt;
void * special_names_list;
void * repository_items_list;
};
struct _config_section_option * cons_config_sec_option(
enum _config_section_type ptype,
struct _intcharpair * psource_comp_opt,
struct _object_computer_clauses * pobj_comp_opt,
void * pspecial_names_list,
void * prepository_item_list
);
void * cons_environment_division(void * penv_div_lst);
void * cons_configuration_section(void * pconf_sec_sectionlst);
void * cons_input_output_section(void * pfile_control, void * pio_section);
/**************** I-O CONTROL ***************/
enum _same_option_type {
CB_SAME_ABSENT = 0,
CB_SAME_RECORD = 1,
CB_SAME_SORT = 2,
CB_SAME_SORT_MERGE = 3
};
struct _same_clause {
int same_opt;
void * file_name_list;
};
struct _same_clause * cons_same_clause( int psame_opt, void * pfilenamelist);
void delete_file_name_list(void * plst);
struct _intidpair {
int ival;
struct idvalStru * idval;
};
struct _intidpair * cons_int_id_pair(int pval, struct idvalStru * pid);
enum _io_control_type {
CB_IOCONTROL_SAME = 1,
CB_IOCONTROL_MULTI = 2
};
struct _io_control_item {
enum _io_control_type type;
struct _same_clause * same_clause;
void * multi_file_lst; // struct _intidpair * lst
};
struct _io_control_item * cons_io_control_item(enum _io_control_type ptype,
struct _same_clause * psame_clause,
void * pmulti_file_lst);
void dump_io_control_item(struct _io_control_item * pitem);
void delete_io_control_item(struct _io_control_item * pitem);
void * cons_io_control(void * piocontrol_itemlst);
/*************** FILE CONTROL *****************/
enum optionalflag {
CB_OPT_NOTDEFINED = 0,
CB_OPT_OPTIONAL = 1,
CB_OPT_NOTOPTIONAL = 2
};
struct _gnamepair_int {
struct valueType * first;
struct valueType * second;
int ival;
};
struct _gnamepair_int * cons_file_assignment_clause(struct valueType * pfilename,
struct valueType * poptfilename, int pdevicetype);
const char * dump_device_file_name(int pdevtype);
struct _int_xval {
int pival;
struct xvaldata * pxval;
};
struct _int_xval * cons_accessmode_clause(int pmode, struct xvaldata * prelativekey);
void dump_accessmode_clause(struct _int_xval * pval);
void dump_lock_mode_clause(int pival);
struct _record_key_clause {
struct xvaldata * data_name;
char * splip_key_name;
void * split_key_value_list;
int duplicate_flag;
};
struct _record_key_clause * cons_record_key_clause( struct xvaldata * pdata_name,
char * psplip_key_name,
void * psplit_key_value_list);
struct _record_key_clause * mod_record_key_clause(struct _record_key_clause * porig,
int pdup);
void dump_record_key_clause(void * plst);
void delete_record_key_clause(void * plst);
enum filecontrolclausetype {
CB_FCC_ASSIGN = 1,
CB_FCC_RESERVE = 2,
CB_FCC_ORG = 3,
CB_FCC_PADDING = 4,
CB_FCC_DELIM = 5,
CB_FCC_ACCESS = 6,
CB_FCC_LOCK = 7,
CB_FCC_CODESET = 8,
CB_FCC_COLLATING = 9,
CB_FCC_RECKEY = 10,
CB_FCC_KEYCLAUSE = 11,
CB_FCC_FILESTATUE = 12
};
struct _file_control_clause {
enum filecontrolclausetype type;
struct _gnamepair_int * file_assignment_clause;
int reserve_clause;
int organization_clause;
struct valueType * padding_char;
struct xvaldata * delimiter_clause;
struct _int_xval * access_mode_clause;
int lock_mode_clause;
struct xvaldata * code_set;
struct xvaldata * collating_seq;
struct _record_key_clause * rec_key_clause;
void * alt_key_clause; //list of struct _record_key_clause *
struct xvaldata * file_status;
};
struct _file_control_clause * cons_fcc_item_gnamepair(enum filecontrolclausetype, struct _gnamepair_int * pval);
struct _file_control_clause * cons_fcc_item_int(enum filecontrolclausetype, int pival);
struct _file_control_clause * cons_fcc_item_val(enum filecontrolclausetype, struct valueType * pval);
struct _file_control_clause * cons_fcc_item_xval(enum filecontrolclausetype, struct xvaldata * pval);
struct _file_control_clause * cons_fcc_item_int_xval(enum filecontrolclausetype, struct _int_xval * pval);
struct _file_control_clause * cons_fcc_item_reckey(enum filecontrolclausetype, struct _record_key_clause * pval);
struct _file_control_clause * cons_fcc_item_key(enum filecontrolclausetype, void * pval);
void dump_file_control_clause_list(void * plst);
void delete_file_control_clause_list(void * plst);
const char * dump_organization_clause(int porganization_clause);
struct _file_control_expression{
int optionalflag;
char * filename;
void * fcclist; //struct _file_control_clause * fcc;
};
struct _file_control_expression * cons_file_control_expression(int poptflag,
char * pfilename, void * pfcc);
void * cons_file_control(void * pfile_ctrl_exprlst);
/****************************************
* Data Division *
****************************************/
void * cons_data_division(void * pdata_div_items);
void * cons_working_storage_section(void * pfdsditemlst);
// CobFileSection
void * cons_file_section(void * plst);
void * cons_file_description(char * pname, void * poptionslst, void * pitemlst);
enum fdsd_enum {
CB_FD_FD = 1,
CB_FD_SD = 2
};
void * set_file_description_type(enum fdsd_enum ptype, void * pfield_descr_item);
struct _int_id {
enum datanames type;
int ival;
struct idvalStru * idval;
};
struct _int_id * cons_int_id(enum datanames ptype, int pival,
struct idvalStru * pid);
struct _val_clause_item {
struct idvalStru * labelid;
struct valueType * valitem;
};
struct _val_clause_item * cons_val_clause_item(struct idvalStru * pid,
struct valueType * pval);
void dump_value_clause_list(void * plst);
struct _block_contains_clause{
int ival;
int toival;
enum special_lit_enum type;
};
struct _block_contains_clause * cons_block_contains_clause(int pival,
int ptoival, enum special_lit_enum ptype);
enum _record_contains_type {
CB_REC_CON = 1,
CB_REC_VAR = 2
};
struct _record_contains_clause {
enum _record_contains_type type;
struct _intpair * contains;
void * record_varyinglst;
};
struct _record_contains_clause * cons_record_contains_clause(
enum _record_contains_type ptype,
struct _intpair * pcontains,
void * precord_varyinglst);
void dump_record_contains_clause(struct _record_contains_clause * prcc);
enum _variation_clause_type {
CB_VAR_FROMTO = 1,
CB_VAR_DEPEND = 2
};
struct _variation_clause {
enum _variation_clause_type type;
struct _intpair * fromto;
struct idvalStru * depend;
};
struct _variation_clause * cons_variation_clause(enum _variation_clause_type ptype,
struct _intpair * pfromto,
struct idvalStru * pdepend);
struct _linage_clause {
struct _int_id * idival;
struct _int_id * idifooting;
struct _int_id * iditop;
struct _int_id * idibottom;
};
struct _linage_clause * cons_linage_clause(struct _int_id * pidival,
struct _int_id * pidifooting,
struct _int_id * piditop,
struct _int_id * pidibottom);
void dump_linage_clause(struct _linage_clause * pitem);
void dump_intid(struct _int_id * pintid);
void delete_linage_clause(struct _linage_clause * pitem);
enum _fd_sd_option_type {
CB_FDSD_EXTERNAL = 1,
CB_FDSD_GLOBAL = 2,
CB_FDSD_LAB_REC_CLAUSE = 3,
CB_FDSD_REC_CON_CLAUSE = 4,
CB_FDSD_BLO_CON_CLAUSE = 5,
CB_FDSD_DATA_REC_CLAUSE = 6,
CB_FDSD_VAL_OF_CLAUSE = 7,
CB_FDSD_LINAGE_CLAUSE = 8,
CB_FDSD_CODESET_CLAUSE = 9,
CB_FDSD_REPORT_CLAUSE = 10
};
struct _fd_sd_option {
enum _fd_sd_option_type type;
int is_ext;
int is_global;
void * label_rec_clause; // this is identifier_list
struct _record_contains_clause * recconcl;
struct _block_contains_clause * blocconcl;
void * data_records_clause;
void * value_oflst;
struct _linage_clause * linagecl;
char * codeset;
char * reportname;
};
struct _fd_sd_option * cons_fdsd_opt_int(enum _fd_sd_option_type ptype, int pival);
struct _fd_sd_option * cons_fdsd_opt_void(enum _fd_sd_option_type ptype, void * pval);
struct _fd_sd_option * cons_fdsd_opt_reccon(enum _fd_sd_option_type ptype,
struct _record_contains_clause * precconcl);
struct _fd_sd_option * cons_fdsd_opt_blockcon(enum _fd_sd_option_type ptype,
struct _block_contains_clause * pblocconcl);
struct _fd_sd_option * cons_fdsd_opt_linage_clause(enum _fd_sd_option_type ptype,
struct _linage_clause * plinagecl);
struct _fd_sd_option * cons_fdsd_opt_codeset(enum _fd_sd_option_type ptype, char * pstr);
struct _fd_sd_option * cons_fdsd_opt_report(enum _fd_sd_option_type ptype, char * pstr);
void dump_fd_sd_opt_list(void * plst);
typedef struct _usageclause {
enum usage_clause_enum usage_enum;
int usage_val;
} usageClauseVal;
void dump_usage_clause_enum(enum usage_clause_enum pval);
typedef struct _occurance {
int multi; // 0 - no, 1 - yes
int from;
int to;
char * denepdingon;
} occurancetype;
struct _occurance * construct_occurance(int pfrom, int pto, char * pdependingon);
struct _usageclause * construct_usage_clause(enum usage_clause_enum pusage, int pval);
enum _data_clause_enum {
CB_DC_REDEFINE = 1,
CB_DC_PICTURE = 2,
CB_DC_VALUE = 3,
CB_DC_USAGE = 4,