docs: def main():
      """
      Function for PDA to CNF Operation
      :type argv: list
      :param argv: Parameters
      """
      if len(argv) < 3:
          print 'Usage for getting CFG: %s CFG_fileA CFG ' % argv[0]
          print 'Usage for getting STR: %s CFG_fileA STR ' \
                'Optimize[0 or 1] splitstring[0 or 1] ' % argv[0]
          print ''
          print 'For example: python pdacnf.py grammar.y STR 1 0'
          print '             python pdacnf.py grammar.y STR 1 1'
          print '             python pdacnf.py grammar.y CFG'
          return
  
      alphabet = createalphabet()
  
      mode = argv[2]
  
      optimized = 0
      splitstring = 0
      if mode == 'STR':
          optimized = int(argv[3])
          splitstring = int(argv[4])
  
      cfgtopda = CfgPDA(alphabet)
      print '* Parsing Grammar:',
      mma = cfgtopda.yyparse(argv[1])
      print 'OK'
      print ' - Total PDA states are ' + repr(len(mma.s))
  
      print '* Simplify State IDs:',
      simple_a = SimplifyStateIDs()
      mma.s, biggestid, newaccepted = simple_a.get(mma.s)
      if newaccepted:
          print 'OK'
      else:
          print 'OK'
  
      print '* Eliminate READ states:',
      replace = ReadReplace(mma.s, biggestid)
      mma.s = replace.replace_read()
      print 'OK'
      print ' - Total PDA states now are ' + repr(len(mma.s))
      maxstate = replace.nextstate() - 1
  
      print '* Reduce PDA:',
      simple_b = ReducePDA()
      mma.s = simple_b.get(mma.s)
      print 'OK'
      print ' - Total PDA states now are ' + repr(len(mma.s))
  
      print '* PDA to CFG transformation:',
      cnfgenerator = PdaCnf(mma.s)
      grammar = cnfgenerator.get_rules(optimized)
      print 'OK'
      print ' - Total CFG rules generated: ' + repr(len(grammar))
  
      if mode == 'STR':
          gen = CFGGenerator(CNFGenerator(grammar),
                             optimized=optimized,
                             splitstring=splitstring,
                             maxstate=maxstate)
          print gen.generate()
      else:
          print grammar