Class zc390
java.lang.Object
zc390
zc390 is the component of z390 used to translate
COBOL source programs (.CBL) to
z390 assembler source programs (.MLC).
It does the following:
- read source ascii cobol from parm1 with CBL default file type.
- parse space delimited COBOL into comma delimited z390 macro assembler source statements using MLC default file type.
- New macro for each new COBOL verb.
- labels with dashes converted to underscores.
- Continuation of words and literals handled.
- Periods and commas allowed within parms which are then enclosed in single quotes to avoid conflict with macro assembler parm parsing.
- Open/close () put in single quotes to avoid conflict with macro assembler parm parsing.
- Literals with single or double quotes allowed with double single/double quotes enclosed.
- Single '" wrapped in opposite type quotes.
- Single () wrapped in single quotes.
- Single . generates PERIOD verb in Procedure Division.
- Generate DATA END, PROCEDURE END,and END.
- Treat verbs as parms within EXEC to END-EXEC.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate class// #655 Define the divisions, sections, and paragraphs with their properties // #655(package private) class// #655 Custom exception // #655 -
Field Summary
FieldsModifier and TypeFieldDescription(package private) booleanvariable(package private) String[]variable(package private) Stringvariable(package private) intvariable(package private) int0 is primary CBL input(package private) booleanvariable(package private) booleanvariable(package private) booleanvariable(package private) booleanvariable(package private) booleanvariable(package private) String[]variable(package private) intvariable(package private) Filevariable(package private) BufferedWritervariable(package private) Stringremove dir from COPY statement to support LSN(package private) StringLABEL macros for section/paragraph(package private) booleanvariable(package private) Filevariable(package private) BufferedWritervariable(package private) Stringvariable(package private) Stringvariable(package private) Stringvariable(package private) intmlc parm count(package private) Stringvariable(package private) booleanvariable(package private) inttokens since pic mode turned on(package private) Stringvariable(package private) static zc390.section_definition[]Table of pre-defined sections, object format(package private) static final String[]Table of pre-defined sections, source format(package private) booleanvariable(package private) booleanvariable(package private) booleanvariable(package private) booleanvariable(package private) booleanvariable(package private) charvariable(package private) Stringvariable(package private) Stringvariable(package private) intvariable(package private) Stringvariable(package private) Stringvariable(package private) Stringvariable(package private) Stringvariable(package private) intvariable(package private) charvariable(package private) Stringvariable(package private) zc390.section_definitionvariable(package private) booleanvariable(package private) intvariable(package private) intvariable(package private) intvariable(package private) intvariable(package private) intvariable(package private) tz390variable(package private) booleanvariable(package private) String[]variable(package private) intvariable(package private) int[]variable(package private) intvariable(package private) booleanvariable(package private) booleanvariable(package private) intvariable(package private) booleancomment COPY except for ZC_LABELS.CPY(package private) Stringvariable(package private) booleanvariable(package private) Stringvariable(package private) Stringvariable(package private) String[]has trailing line after COPY .(package private) int[]next token on line index(package private) Stringvariable(package private) int[]next token on line index(package private) intvariable(package private) String[]replacing lit1(package private) String[]replacing lit2(package private) int[]next token on line index(package private) booleanvariable(package private) Patternparsing regular expression pattern(package private) booleanvariable(package private) booleanvariable(package private) File[]variable(package private) BufferedReader[]variable(package private) Stringvariable(package private) booleanvariable(package private) intparm (...) level used to allow verbs in DFHRESP/DFHVALUE etc.(package private) Stringlogical line with continuations added(package private) Stringvariable(package private) Stringlookahead rec for non split lit continuations(package private) Stringvariable(package private) intoffset to start of matcher(package private) Matcherdata name patrern matching(package private) Patternvalidate names(package private) charvariable(package private) booleanvariable(package private) intvariable(package private) intvariable(package private) Stringvariable(package private) booleanvariable(package private) charvariable(package private) booleanvariable(package private) intvariable(package private) intvariable(package private) Stringvariable(package private) booleanPRODECUDE DIV started(package private) Patternvariable(package private) booleanIs REPLACE currently active?(package private) intNumber of active replacement pairs(package private) String[]Pseudo-text to find(package private) String[]Replacement pseudo-text(package private) charliteral single quotes or double quotes(package private) booleanliteral split across lines(package private) Stringnext token or null at eof(package private) chartoken area A 8-11 or B 12 or greater(package private) intvariable(package private) booleanvariable(package private) intvariable(package private) intvariable(package private) Matchertoken pattern matching class(package private) booleanvariable(package private) intvariable -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidabort_error(String msg) display error and terminateprivate voidadd cpz file for stats list RPI 1042private voidadd_mlc_parm(String token) add token parm to mlc_line
Notes: If exec_mode and parm,private voidcopy_error(String msg) terminate COPY with error and dec cur_zc_file and flush lineprivate voidfind next token in zc_line else set zc_line = nullprivate booleandetermine if zc_token is a known COBOL verbprivate voidwrite pending CBL line comment if pendingprivate voidwrite pending mlc_line if anyprivate voidgen DATA END after any cics generated COPY for DFHEIBLK or DFHCOMMAREAprivate voidgenerate EXEC call with parm(value) parameters combinedprivate voidget next zc_line from nested copy filesprivate voidread next CBL file line set cbl_eof if end of file write each line as comment on MLC ignore lines with less than 8 characters and blank lines ignore comment lines with non-space in 7private voidread next zc_line with concatenated non split lit continuationsprivate voidSet zc_token to next logical cobol token including continued literal token split across 1 or more lines and non-literal tokens continued at next non-blank char on continuation line. Set to null at end of file. Set zc_token_area to A for token starting in col 8-11. Set zc_token_area to B for token starting in 12-72. If token not in quotes, make upper-case. If quotes: Convert single ampersand to double ampersand If orig ", convert "" to ", ' to ''private voidinit_zc390(String[] args) Display zcobol version Compile regular expression pattern Open CBL and MLC files Create section/paragraph definitionsprivate voiddisplay error and continuestatic voidstart instance of zcobol classprivate voidnew_mlc_line(String new_lab, String new_op, String new_parms) write pending mlc line and start new line and reset parm countprivate voidIf new level # less than current level #, decrement group level #. Generate new WS verb with level # as first parm indented to current group level.private voidmove next token to prev tokenprivate voidprocess cbl to mlc with or without trap exception handlerprivate voidexpand copy which may appear in the middle of sentence with the following options: COPY member (uses SYSCPY paths for dir search) COPY member OF/IN library (ddname of dir) COPY ...private voidProcess REPLACE statement per FIPS PUB 21-2 Section XII Chapter 3 #742 Format 1: REPLACE {==pseudo-text-1== BY ==pseudo-text-2==}...private voidprocess zc_token If token length > 1 and not literal replace - with _ and if ., included wrap in single quotes. Single char processing: Flush line at .private voiddisplay zc390 version, timestamp, and copyright on statstics fileprivate voidput zc_line as comment on MLCprivate voidput_mlc_line(String put_lab, String put_op, String put_parms) write line to MLC file if LABEL macros for PROCEDURE DIVISION section and paragraph names, write to CPY file concatenated in front of MLC to preload all label definitions for compile. Notes: If first char is " and not data_div assume comment-entry and make comment lineprivate voidput_text_rec(BufferedWriter file_buff, String text) write text record to MLC or CPY fileprivate voidput zcobol call source commentprivate voidreplace single ampersand with double ampersand replace "" with " replace ' with '' if split_char = "private voidget next token from CBL file and set pending CBL comment lineprivate voidinsert DFHEIBLK and DFHCOMMAREA parms add any user parms after above. flush through period.private voidset zc_line_id and zc_line_numprivate voidterm_zc()Add PROCEDURE END and END to mlc meta file. Display statistics. Exitprivate voidtranslate_cbl_to_mlc(String[] args, JTextArea log_text) translate cobol (CBL) to z390 macro assembler (.MLC)private voidzc_cbl_comment(String text) display CBL as comments if ZC_COMMENT
-
Field Details
-
zc390_rc
int zc390_rcvariable -
tz390
tz390 tz390variable -
tot_cbl
int tot_cblvariable -
tot_mlc
int tot_mlcvariable -
tot_lab
int tot_labvariable -
tot_err
int tot_errvariable -
zc_line_id
String zc_line_idvariable -
zc_line_num
String zc_line_numvariable -
zc_line
String zc_linelogical line with continuations added -
zc_line_lookahead
String zc_line_lookaheadlookahead rec for non split lit continuations -
zc_file_name
String zc_file_namevariable -
zc_comment
boolean zc_commentvariable -
zc_comment_copy
boolean zc_comment_copycomment COPY except for ZC_LABELS.CPY -
zc_pg_comment_mode
boolean zc_pg_comment_modevariable -
zc_cics
boolean zc_cicsvariable -
zc_extend
boolean zc_extendvariable -
zc_trunc
boolean zc_truncvariable -
linkage_sect
boolean linkage_sectvariable -
request_dfheiblk
boolean request_dfheiblkvariable -
request_dfhcommarea
boolean request_dfhcommareavariable -
request_proc
boolean request_procvariable -
request_data_end
boolean request_data_endvariable -
dfheiblk
boolean dfheiblkvariable -
dfheiblk_loading
boolean dfheiblk_loadingvariable -
dfhcommarea
boolean dfhcommareavariable -
zc_eof
boolean zc_eofvariable -
zc_comment_pending
boolean zc_comment_pendingvariable -
zc_comment_cnt
int zc_comment_cntvariable -
pic_token_cnt
int pic_token_cnttokens since pic mode turned on -
pic_mode
boolean pic_modevariable -
value_mode
boolean value_modevariable -
exec_mode
boolean exec_modevariable -
exec_parm
String[] exec_parmvariable -
exec_parm_index
int exec_parm_indexvariable -
data_div
boolean data_divvariable -
allow_verb
boolean allow_verbvariable -
skip_period
boolean skip_periodvariable -
zc_comment_line
String zc_comment_linevariable -
mlc_file_name
String mlc_file_namevariable -
mlc_file
File mlc_filevariable -
mlc_file_buff
BufferedWriter mlc_file_buffvariable -
lab_file_name
String lab_file_nameLABEL macros for section/paragraph -
lab_file_dir
String lab_file_dirremove dir from COPY statement to support LSN -
lab_file
File lab_filevariable -
lab_file_buff
BufferedWriter lab_file_buffvariable -
zc_copy_file_name
String zc_copy_file_namevariable -
zc_copy_member
String zc_copy_membervariable -
zc_copy_ddname
String zc_copy_ddnamevariable -
cpz_type
String cpz_typevariable -
tot_cpz_file_name
int tot_cpz_file_namevariable -
cpz_file_name
String[] cpz_file_namevariable -
cur_zc_file
int cur_zc_file0 is primary CBL input -
zc_file
File[] zc_filevariable -
zc_file_buff
BufferedReader[] zc_file_buffvariable -
zc_copy_trailer
boolean zc_copy_trailervariable -
zc_copy_rep_ix
int zc_copy_rep_ixvariable -
cur_rep_ix
int cur_rep_ixvariable -
zc_copy_line
String[] zc_copy_linehas trailing line after COPY . -
zc_copy_line_ix
int[] zc_copy_line_ixnext token on line index -
zc_copy_rep_fst_ix
int[] zc_copy_rep_fst_ixnext token on line index -
zc_copy_rep_lst_ix
int[] zc_copy_rep_lst_ixnext token on line index -
zc_copy_rep_lit1
String[] zc_copy_rep_lit1replacing lit1 -
zc_copy_rep_lit2
String[] zc_copy_rep_lit2replacing lit2 -
zc_replace_active
boolean zc_replace_activeIs REPLACE currently active? -
zc_replace_count
int zc_replace_countNumber of active replacement pairs -
zc_replace_lit1
String[] zc_replace_lit1Pseudo-text to find -
zc_replace_lit2
String[] zc_replace_lit2Replacement pseudo-text -
zc_token_count
int zc_token_countvariable -
zc_token_line_cnt
int zc_token_line_cntvariable -
zc_prev_line_cnt
int zc_prev_line_cntvariable -
zc_next_line_cnt
int zc_next_line_cntvariable -
zc_flush_cont_token
boolean zc_flush_cont_tokenvariable -
zc_prev_token
String zc_prev_tokenvariable -
zc_next_token
String zc_next_tokenvariable -
zc_next_index
int zc_next_indexvariable -
zc_prev_index
int zc_prev_indexvariable -
zc_prev_area
char zc_prev_areavariable -
zc_next_area
char zc_next_areavariable -
zc_prev_first
boolean zc_prev_firstvariable -
zc_next_first
boolean zc_next_firstvariable -
zc_token_first
boolean zc_token_firstvariable -
zc_token
String zc_tokennext token or null at eof -
zc_token_index
int zc_token_indexvariable -
zc_name_pattern
Pattern zc_name_patternvalidate names -
zc_data_token_pattern
Pattern zc_data_token_patternparsing regular expression pattern -
zc_proc_token_pattern
Pattern zc_proc_token_patternvariable -
zc_name_match
Matcher zc_name_matchdata name patrern matching -
zc_token_match
Matcher zc_token_matchtoken pattern matching class -
zc_match_offset
int zc_match_offsetoffset to start of matcher -
zc_token_area
char zc_token_areatoken area A 8-11 or B 12 or greater -
zc_split_lit
boolean zc_split_litliteral split across lines -
zc_split_char
char zc_split_charliteral single quotes or double quotes -
zc_proc_div
boolean zc_proc_divPRODECUDE DIV started -
proc_using_parms
String proc_using_parmsvariable -
mlc_lab
String mlc_labvariable -
mlc_op
String mlc_opvariable -
mlc_parms
String mlc_parmsvariable -
mlc_parm_cnt
int mlc_parm_cntmlc parm count -
zc_level
int zc_levelparm (...) level used to allow verbs in DFHRESP/DFHVALUE etc. -
ws_item_lvl
int ws_item_lvlvariable -
ws_lvl_index
int ws_lvl_indexvariable -
ws_lvl
int[] ws_lvlvariable -
ws_indent
String[] ws_indentvariable -
sc_current_token
String sc_current_tokenvariable -
sc_current_area
char sc_current_areavariable -
sc_previous_token
String sc_previous_tokenvariable -
sc_previous_area
char sc_previous_areavariable -
sc_section_definition
zc390.section_definition sc_section_definitionvariable -
sc_current_division
String sc_current_divisionvariable -
sc_current_section
String sc_current_sectionvariable -
sc_current_paragraph
String sc_current_paragraphvariable -
sc_change_flag
boolean sc_change_flagvariable -
sc_current_combination
String sc_current_combinationvariable -
sc_new_combination
String sc_new_combinationvariable -
sc_current_index
int sc_current_indexvariable -
sc_new_index
int sc_new_indexvariable -
PROGRAM_SECTIONS
Table of pre-defined sections, source format -
program_sections
Table of pre-defined sections, object format
-
-
Constructor Details
-
zc390
public zc390()Dummy constructor - no initialization needed
-
-
Method Details
-
main
start instance of zcobol class- Parameters:
argv- argument list
-
translate_cbl_to_mlc
translate cobol (CBL) to z390 macro assembler (.MLC)- Parameters:
args- argument listlog_text- optional log buffer
-
process_cbl
private void process_cbl()process cbl to mlc with or without trap exception handler -
init_zc390
- Display zcobol version
- Compile regular expression pattern
- Open CBL and MLC files
- Create section/paragraph definitions
- Parameters:
args- argument string
-
term_zc
private void term_zc()- Add PROCEDURE END and END to mlc meta file.
- Display statistics.
- Exit
-
put_copyright
private void put_copyright()display zc390 version, timestamp, and copyright on statstics file -
put_mlc_line
- write line to MLC file
- if LABEL macros for PROCEDURE DIVISION section and paragraph names, write to CPY file concatenated in front of MLC to preload all label definitions for compile.
- If first char is " and not data_div assume comment-entry and make comment line
- Parameters:
put_lab- labelput_op- operation (macro or instruction mnemonic)put_parms- parameters for operation
-
put_text_rec
write text record to MLC or CPY file- Parameters:
file_buff- ooutput filetext- record to be written
-
abort_error
display error and terminate- Parameters:
msg- error message to display
-
log_error
display error and continue- Parameters:
msg- error message to display
-
get_zc_token
private void get_zc_token()- Set zc_token to next logical cobol token including continued literal token
- split across 1 or more lines and non-literal tokens continued at next non-blank char on continuation line.
- Set to null at end of file.
- Set zc_token_area to A for token starting in col 8-11.
- Set zc_token_area to B for token starting in 12-72.
- If token not in quotes, make upper-case.
- If quotes:
- Convert single ampersand to double ampersand
- If orig ", convert "" to ", ' to ''
-
rep_amp_sq_dq
private void rep_amp_sq_dq()- replace single ampersand with double ampersand
- replace "" with "
- replace ' with '' if split_char = "
-
next_to_prev
private void next_to_prev()move next token to prev token -
set_next_token
private void set_next_token()get next token from CBL file and set pending CBL comment line -
put_mlc_comment
private void put_mlc_comment()put zc_line as comment on MLC -
get_zc_line
private void get_zc_line()- read next CBL file line
- set cbl_eof if end of file
- write each line as comment on MLC
- ignore lines with less than 8 characters and blank lines
- ignore comment lines with non-space in 7
-
zc_cbl_comment
display CBL as comments if ZC_COMMENT- Parameters:
text- comment text
-
get_next_zc_line
private void get_next_zc_line()get next zc_line from nested copy files -
get_zc_read_cont
private void get_zc_read_cont()read next zc_line with concatenated non split lit continuations -
flush_comment_line
private void flush_comment_line()write pending CBL line comment if pending -
find_next_token
private void find_next_token()find next token in zc_line else set zc_line = null -
process_zc_token
private void process_zc_token()process zc_token- If token length > 1 and not literal
- replace - with _ and if ., included
- wrap in single quotes.
- Single char processing:
- Flush line at . and gen PERIOD if Proc. div. else ignore period.
- Ignore commas.
- If '" wrap in opposite quotes
- If () wrap in single quotes.
- comma or semicolon ignored
- If token length > 1 and not literal
-
gen_data_end
private void gen_data_end()gen DATA END after any cics generated COPY for DFHEIBLK or DFHCOMMAREA -
set_zc_line_id_num
private void set_zc_line_id_num()set zc_line_id and zc_line_num -
set_proc_using_parms
private void set_proc_using_parms()- insert DFHEIBLK and DFHCOMMAREA parms
- add any user parms after above.
- flush through period.
-
new_ws_line
private void new_ws_line()- If new level # less than current level #, decrement group level #.
- Generate new WS verb with level # as first parm indented to current group level.
-
new_mlc_line
write pending mlc line and start new line and reset parm count- Parameters:
new_lab- labelnew_op- operation - macro or instruction mnemonicnew_parms- parameters for operation
-
flush_last_mlc_line
private void flush_last_mlc_line()write pending mlc_line if any -
put_zc_line
private void put_zc_line()put zcobol call source comment -
add_mlc_parm
add token parm to mlc_line
Notes:- If exec_mode and parm,
- Parameters:
token- token to be created
-
gen_exec_stmt
private void gen_exec_stmt()generate EXEC call with parm(value) parameters combined -
find_verb
private boolean find_verb()determine if zc_token is a known COBOL verb- Returns:
- true if current token is a valid verb; false otherwise
-
process_copy
private void process_copy()expand copy which may appear in the middle of sentence with the following options:- COPY member (uses SYSCPY paths for dir search)
- COPY member OF/IN library (ddname of dir)
- COPY ... REPLACING lit1 BY lit2
-
copy_error
terminate COPY with error and dec cur_zc_file and flush line- Parameters:
msg- error message text
-
process_replace
private void process_replace()Process REPLACE statement per FIPS PUB 21-2 Section XII Chapter 3 #742 Format 1: REPLACE {==pseudo-text-1== BY ==pseudo-text-2==}... Format 2: REPLACE OFF -
add_cpz_file
private void add_cpz_file()add cpz file for stats list RPI 1042
-