def read_files(args): global hold_doc root = Root() for fn in args: fname = fn # Open the filename for reading logging.debug('processing file ' + fname) file = F90File(fname) # Get first line cline = file.next() while cline != None: # programs check = check_program(cline, file) if check[0] != None: logging.debug(' program ' + check[0].name) root.programs.append(check[0]) cline = check[1] continue # modules check = check_module(cline, file) if check[0] != None: logging.debug(' module ' + check[0].name) root.modules.append(check[0]) cline = check[1] continue # jrk33 - hold doc comment relating to next module, subrt or funct check = check_doc(cline, file) if check[0] != None: if hold_doc == None: hold_doc = [check[0]] else: hold_doc.append(check[0]) cline = check[1] continue # stand-alone subroutines check = check_subt(cline, file) if check[0] != None: # logging.debug(' subroutine ' + check[0].name) root.procedures.append(check[0]) cline = check[1] continue # stand-alone functions check = check_funct(cline, file) if check[0] != None: # logging.debug(' function ' + check[0].name) root.procedures.append(check[0]) cline = check[1] continue cline = file.next() # apply some rules to the parsed tree from f90wrap.fortran import fix_argument_attributes, LowerCaseConverter root = fix_argument_attributes(root) root = LowerCaseConverter().visit(root) return root
def read_files(args, doc_plugin_filename=None): global doc_plugin_module global hold_doc if doc_plugin_filename is not None: sys.path.insert(0, os.path.dirname(doc_plugin_filename)) doc_plugin_module = __import__( os.path.splitext(os.path.basename(doc_plugin_filename))[0]) sys.path = sys.path[1:] else: doc_plugin_module = None root = Root() for fn in args: fname = fn # Open the filename for reading log.debug('processing file ' + fname) file = F90File(fname) # Get first line cline = file.next() while cline != None: # programs check = check_program(cline, file) if check[0] != None: log.debug(' program ' + check[0].name) root.programs.append(check[0]) cline = check[1] continue # modules check = check_module(cline, file) if check[0] != None: log.debug(' module ' + check[0].name) root.modules.append(check[0]) cline = check[1] continue # jrk33 - hold doc comment relating to next module, subrt or funct check = check_doc(cline, file) if check[0] != None: if hold_doc == None: hold_doc = [check[0]] else: hold_doc.append(check[0]) cline = check[1] continue # stand-alone subroutines check = check_subt(cline, file) if check[0] != None: # log.debug(' subroutine ' + check[0].name) root.procedures.append(check[0]) cline = check[1] continue # stand-alone functions check = check_funct(cline, file) if check[0] != None: # log.debug(' function ' + check[0].name) root.procedures.append(check[0]) cline = check[1] continue cline = file.next() # apply some rules to the parsed tree root = fix_argument_attributes(root) root = LowerCaseConverter().visit(root) root = RepeatedInterfaceCollapser().visit(root) return root