Class zc390


public class zc390 extends Object
zc390 is the component of z390 used to translate COBOL source programs (.CBL) to z390 assembler source programs (.MLC). It does the following:
  1. read source ascii cobol from parm1 with CBL default file type.
  2. parse space delimited COBOL into comma delimited z390 macro assembler source statements using MLC default file type.
    1. New macro for each new COBOL verb.
    2. labels with dashes converted to underscores.
    3. Continuation of words and literals handled.
    4. Periods and commas allowed within parms which are then enclosed in single quotes to avoid conflict with macro assembler parm parsing.
    5. Open/close () put in single quotes to avoid conflict with macro assembler parm parsing.
    6. Literals with single or double quotes allowed with double single/double quotes enclosed.
    7. Single '" wrapped in opposite type quotes.
    8. Single () wrapped in single quotes.
    9. Single . generates PERIOD verb in Procedure Division.
    10. Generate DATA END, PROCEDURE END,and END.
    11. Treat verbs as parms within EXEC to END-EXEC.
  • Field Details

    • zc390_rc

      int zc390_rc
      variable
    • tz390

      tz390 tz390
      variable
    • tot_cbl

      int tot_cbl
      variable
    • tot_mlc

      int tot_mlc
      variable
    • tot_lab

      int tot_lab
      variable
    • tot_err

      int tot_err
      variable
    • zc_line_id

      String zc_line_id
      variable
    • zc_line_num

      String zc_line_num
      variable
    • zc_line

      String zc_line
      logical line with continuations added
    • zc_line_lookahead

      String zc_line_lookahead
      lookahead rec for non split lit continuations
    • zc_file_name

      String zc_file_name
      variable
    • zc_comment

      boolean zc_comment
      variable
    • zc_comment_copy

      boolean zc_comment_copy
      comment COPY except for ZC_LABELS.CPY
    • zc_pg_comment_mode

      boolean zc_pg_comment_mode
      variable
    • zc_cics

      boolean zc_cics
      variable
    • zc_extend

      boolean zc_extend
      variable
    • zc_trunc

      boolean zc_trunc
      variable
    • linkage_sect

      boolean linkage_sect
      variable
    • request_dfheiblk

      boolean request_dfheiblk
      variable
    • request_dfhcommarea

      boolean request_dfhcommarea
      variable
    • request_proc

      boolean request_proc
      variable
    • request_data_end

      boolean request_data_end
      variable
    • dfheiblk

      boolean dfheiblk
      variable
    • dfheiblk_loading

      boolean dfheiblk_loading
      variable
    • dfhcommarea

      boolean dfhcommarea
      variable
    • zc_eof

      boolean zc_eof
      variable
    • zc_comment_pending

      boolean zc_comment_pending
      variable
    • zc_comment_cnt

      int zc_comment_cnt
      variable
    • pic_token_cnt

      int pic_token_cnt
      tokens since pic mode turned on
    • pic_mode

      boolean pic_mode
      variable
    • value_mode

      boolean value_mode
      variable
    • exec_mode

      boolean exec_mode
      variable
    • exec_parm

      String[] exec_parm
      variable
    • exec_parm_index

      int exec_parm_index
      variable
    • data_div

      boolean data_div
      variable
    • allow_verb

      boolean allow_verb
      variable
    • skip_period

      boolean skip_period
      variable
    • zc_comment_line

      String zc_comment_line
      variable
    • mlc_file_name

      String mlc_file_name
      variable
    • mlc_file

      File mlc_file
      variable
    • mlc_file_buff

      BufferedWriter mlc_file_buff
      variable
    • lab_file_name

      String lab_file_name
      LABEL macros for section/paragraph
    • lab_file_dir

      String lab_file_dir
      remove dir from COPY statement to support LSN
    • lab_file

      File lab_file
      variable
    • lab_file_buff

      BufferedWriter lab_file_buff
      variable
    • zc_copy_file_name

      String zc_copy_file_name
      variable
    • zc_copy_member

      String zc_copy_member
      variable
    • zc_copy_ddname

      String zc_copy_ddname
      variable
    • cpz_type

      String cpz_type
      variable
    • tot_cpz_file_name

      int tot_cpz_file_name
      variable
    • cpz_file_name

      String[] cpz_file_name
      variable
    • cur_zc_file

      int cur_zc_file
      0 is primary CBL input
    • zc_file

      File[] zc_file
      variable
    • zc_file_buff

      BufferedReader[] zc_file_buff
      variable
    • zc_copy_trailer

      boolean zc_copy_trailer
      variable
    • zc_copy_rep_ix

      int zc_copy_rep_ix
      variable
    • cur_rep_ix

      int cur_rep_ix
      variable
    • zc_copy_line

      String[] zc_copy_line
      has trailing line after COPY .
    • zc_copy_line_ix

      int[] zc_copy_line_ix
      next token on line index
    • zc_copy_rep_fst_ix

      int[] zc_copy_rep_fst_ix
      next token on line index
    • zc_copy_rep_lst_ix

      int[] zc_copy_rep_lst_ix
      next token on line index
    • zc_copy_rep_lit1

      String[] zc_copy_rep_lit1
      replacing lit1
    • zc_copy_rep_lit2

      String[] zc_copy_rep_lit2
      replacing lit2
    • zc_replace_active

      boolean zc_replace_active
      Is REPLACE currently active?
    • zc_replace_count

      int zc_replace_count
      Number of active replacement pairs
    • zc_replace_lit1

      String[] zc_replace_lit1
      Pseudo-text to find
    • zc_replace_lit2

      String[] zc_replace_lit2
      Replacement pseudo-text
    • zc_token_count

      int zc_token_count
      variable
    • zc_token_line_cnt

      int zc_token_line_cnt
      variable
    • zc_prev_line_cnt

      int zc_prev_line_cnt
      variable
    • zc_next_line_cnt

      int zc_next_line_cnt
      variable
    • zc_flush_cont_token

      boolean zc_flush_cont_token
      variable
    • zc_prev_token

      String zc_prev_token
      variable
    • zc_next_token

      String zc_next_token
      variable
    • zc_next_index

      int zc_next_index
      variable
    • zc_prev_index

      int zc_prev_index
      variable
    • zc_prev_area

      char zc_prev_area
      variable
    • zc_next_area

      char zc_next_area
      variable
    • zc_prev_first

      boolean zc_prev_first
      variable
    • zc_next_first

      boolean zc_next_first
      variable
    • zc_token_first

      boolean zc_token_first
      variable
    • zc_token

      String zc_token
      next token or null at eof
    • zc_token_index

      int zc_token_index
      variable
    • zc_name_pattern

      Pattern zc_name_pattern
      validate names
    • zc_data_token_pattern

      Pattern zc_data_token_pattern
      parsing regular expression pattern
    • zc_proc_token_pattern

      Pattern zc_proc_token_pattern
      variable
    • zc_name_match

      Matcher zc_name_match
      data name patrern matching
    • zc_token_match

      Matcher zc_token_match
      token pattern matching class
    • zc_match_offset

      int zc_match_offset
      offset to start of matcher
    • zc_token_area

      char zc_token_area
      token area A 8-11 or B 12 or greater
    • zc_split_lit

      boolean zc_split_lit
      literal split across lines
    • zc_split_char

      char zc_split_char
      literal single quotes or double quotes
    • zc_proc_div

      boolean zc_proc_div
      PRODECUDE DIV started
    • proc_using_parms

      String proc_using_parms
      variable
    • mlc_lab

      String mlc_lab
      variable
    • mlc_op

      String mlc_op
      variable
    • mlc_parms

      String mlc_parms
      variable
    • mlc_parm_cnt

      int mlc_parm_cnt
      mlc parm count
    • zc_level

      int zc_level
      parm (...) level used to allow verbs in DFHRESP/DFHVALUE etc.
    • ws_item_lvl

      int ws_item_lvl
      variable
    • ws_lvl_index

      int ws_lvl_index
      variable
    • ws_lvl

      int[] ws_lvl
      variable
    • ws_indent

      String[] ws_indent
      variable
    • sc_current_token

      String sc_current_token
      variable
    • sc_current_area

      char sc_current_area
      variable
    • sc_previous_token

      String sc_previous_token
      variable
    • sc_previous_area

      char sc_previous_area
      variable
    • sc_section_definition

      zc390.section_definition sc_section_definition
      variable
    • sc_current_division

      String sc_current_division
      variable
    • sc_current_section

      String sc_current_section
      variable
    • sc_current_paragraph

      String sc_current_paragraph
      variable
    • sc_change_flag

      boolean sc_change_flag
      variable
    • sc_current_combination

      String sc_current_combination
      variable
    • sc_new_combination

      String sc_new_combination
      variable
    • sc_current_index

      int sc_current_index
      variable
    • sc_new_index

      int sc_new_index
      variable
    • PROGRAM_SECTIONS

      static final String[] PROGRAM_SECTIONS
      Table of pre-defined sections, source format
    • program_sections

      static zc390.section_definition[] program_sections
      Table of pre-defined sections, object format
  • Constructor Details

    • zc390

      public zc390()
      Dummy constructor - no initialization needed
  • Method Details

    • main

      public static void main(String[] argv)
      start instance of zcobol class
      Parameters:
      argv - argument list
    • translate_cbl_to_mlc

      private void translate_cbl_to_mlc(String[] args, JTextArea log_text)
      translate cobol (CBL) to z390 macro assembler (.MLC)
      Parameters:
      args - argument list
      log_text - optional log buffer
    • process_cbl

      private void process_cbl()
      process cbl to mlc with or without trap exception handler
    • init_zc390

      private void init_zc390(String[] args)
      1. Display zcobol version
      2. Compile regular expression pattern
      3. Open CBL and MLC files
      4. Create section/paragraph definitions
      Parameters:
      args - argument string
    • term_zc

      private void term_zc()
      1. Add PROCEDURE END and END to mlc meta file.
      2. Display statistics.
      3. Exit
    • put_copyright

      private void put_copyright()
      display zc390 version, timestamp, and copyright on statstics file
    • put_mlc_line

      private void put_mlc_line(String put_lab, String put_op, String put_parms)
      1. write line to MLC file
      2. 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:
      1. If first char is " and not data_div assume comment-entry and make comment line
      Parameters:
      put_lab - label
      put_op - operation (macro or instruction mnemonic)
      put_parms - parameters for operation
    • put_text_rec

      private void put_text_rec(BufferedWriter file_buff, String text)
      write text record to MLC or CPY file
      Parameters:
      file_buff - ooutput file
      text - record to be written
    • abort_error

      private void abort_error(String msg)
      display error and terminate
      Parameters:
      msg - error message to display
    • log_error

      private void log_error(String msg)
      display error and continue
      Parameters:
      msg - error message to display
    • get_zc_token

      private void get_zc_token()
      1. Set zc_token to next logical cobol token including continued literal token
      2. split across 1 or more lines and non-literal tokens continued at next non-blank char on continuation line.
      3. Set to null at end of file.
      4. Set zc_token_area to A for token starting in col 8-11.
      5. Set zc_token_area to B for token starting in 12-72.
      6. If token not in quotes, make upper-case.
      7. If quotes:
        1. Convert single ampersand to double ampersand
        2. 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()
      1. read next CBL file line
      2. set cbl_eof if end of file
      3. write each line as comment on MLC
      4. ignore lines with less than 8 characters and blank lines
      5. ignore comment lines with non-space in 7
    • zc_cbl_comment

      private void zc_cbl_comment(String text)
      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
      1. If token length > 1 and not literal
        1. replace - with _ and if ., included
        2. wrap in single quotes.
      2. Single char processing:
        1. Flush line at . and gen PERIOD if Proc. div. else ignore period.
        2. Ignore commas.
        3. If '" wrap in opposite quotes
        4. If () wrap in single quotes.
        5. comma or semicolon ignored
    • 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()
      1. insert DFHEIBLK and DFHCOMMAREA parms
      2. add any user parms after above.
      3. flush through period.
    • new_ws_line

      private void new_ws_line()
      1. If new level # less than current level #, decrement group level #.
      2. Generate new WS verb with level # as first parm indented to current group level.
    • new_mlc_line

      private void new_mlc_line(String new_lab, String new_op, String new_parms)
      write pending mlc line and start new line and reset parm count
      Parameters:
      new_lab - label
      new_op - operation - macro or instruction mnemonic
      new_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

      private void add_mlc_parm(String token)
      add token parm to mlc_line
      Notes:
      1. 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:
      1. COPY member (uses SYSCPY paths for dir search)
      2. COPY member OF/IN library (ddname of dir)
      3. COPY ... REPLACING lit1 BY lit2
    • copy_error

      private void copy_error(String msg)
      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