original_docstring:  This function parses the XML tree of a Fortran file and tracks and
          maps relevant object relationships 
docstring: This function parses the XML tree of a Fortran file and tracks and
  maps relevant object relationships
docstring_tokens: This function parses the XML tree of a Fortran file and tracks and maps relevant object relationships
code: def parse_tree(self, root, module_logs) -> bool:
          """ This function parses the XML tree of a Fortran file and tracks and
          maps relevant object relationships """
  
          # Find name of PROGRAM module
          for item in root.iter():
              if item.tag == "program":
                  self.main = item.attrib["name"].lower()
  
          variable_type = None
  
          for item in root.iter():
              # Get the name of the XML file being parsed
              if item.tag == "file":
                  file_name = item.attrib["path"]
                  file = file_name.split('/')[-1]
                  file_regex = r'^(.*)_processed(\..*)$'
                  path_regex = r'^.*(delphi/[^delphi].*)/\w+'
                  match = re.match(file_regex, file)
                  if match:
                      self.fileName = match.group(1) + match.group(2)
                  match = re.match(path_regex, file_name)
                  if match:
                      self.path = match.group(1)
  
              elif item.tag.lower() in ["module", "program"]:
                  self.current_context = item.attrib["name"].lower()
                  self.modules.append(item.attrib["name"].lower())
  
              elif (
                      item.tag.lower() == "type"
                      and "name" in item.attrib
              ):
                  variable_type = item.attrib["name"].lower()
              elif item.tag.lower() == "variable":
                  if item.attrib.get("name"):
                      if not self.current_context:
                          self.current_context = self.main
                      self.public.setdefault(self.current_context, []).append(
                          item.attrib["name"].lower())
                      self.variable_types[item.attrib["name"].lower()] = variable_type
  
              elif item.tag.lower() in ["subroutine", "function"]:
                  if not self.current_context:
                      self.current_context = self.main
                  self.subprograms.setdefault(self.current_context, []).append(
                      item.attrib["name"].lower())
                  self.current_context = item.attrib["name"].lower()
  
              elif item.tag.lower() == "declaration":
                  # This function parses the <declaration> tag of the XML and
                  # checks if private variables are defined in the respective
                  # module/program. Private variables tend to be inside the
                  # declaration tag
                  private_status = False
                  for child in item.iter():
                      if child.tag.lower() == "access-spec" and child.attrib.get(
                              "keyword").lower() == "private":
                          private_status = True
                      if child.tag.lower() == "variable" and private_status:
                          if not self.current_context:
                              self.current_context = self.main
                          if child.attrib.get("name"):
                              self.private.setdefault(self.current_context,
                                                      []).append(
                                  child.attrib["name"].lower())
  
              elif item.tag.lower() == "use":
                  # If a module, program or subroutine uses (imports) another
                  # module, a USE statement is used and we want to map the
                  # relationship between different program scopes that occur
                  # with the use of the USE statement
                  only_symbols = []
                  for child in item:
                      if child.tag.lower() == "only":
                          for innerChild in child:
                              if innerChild.tag.lower() == "name":
                                  only_symbols.append(innerChild.attrib[
                                                          "id"].lower())
                  if not self.current_context:
                      self.current_context = self.main
                  self.uses.setdefault(self.current_context, []).append({
                      item.attrib["name"].lower(): only_symbols} if only_symbols
                      else {item.attrib["name"].lower(): ["*"]})
  
          self.populate_symbols()
          self.populate_symbol_types()
          self.populate_exports()
          self.populate_imports(module_logs)
  
          return True
code_tokens: def parse_tree ( self , root , module_logs ) -> bool : for item in root . iter ( ) : if item . tag == "program" : self . main = item . attrib [ "name" ] . lower ( ) variable_type = None for item in root . iter ( ) : if item . tag == "file" : file_name = item . attrib [ "path" ] file = file_name . split ( '/' ) [ - 1 ] file_regex = r'^(.*)_processed(\..*)$' path_regex = r'^.*(delphi/[^delphi].*)/\w+' match = re . match ( file_regex , file ) if match : self . fileName = match . group ( 1 ) + match . group ( 2 ) match = re . match ( path_regex , file_name ) if match : self . path = match . group ( 1 ) elif item . tag . lower ( ) in [ "module" , "program" ] : self . current_context = item . attrib [ "name" ] . lower ( ) self . modules . append ( item . attrib [ "name" ] . lower ( ) ) elif ( item . tag . lower ( ) == "type" and "name" in item . attrib ) : variable_type = item . attrib [ "name" ] . lower ( ) elif item . tag . lower ( ) == "variable" : if item . attrib . get ( "name" ) : if not self . current_context : self . current_context = self . main self . public . setdefault ( self . current_context , [ ] ) . append ( item . attrib [ "name" ] . lower ( ) ) self . variable_types [ item . attrib [ "name" ] . lower ( ) ] = variable_type elif item . tag . lower ( ) in [ "subroutine" , "function" ] : if not self . current_context : self . current_context = self . main self . subprograms . setdefault ( self . current_context , [ ] ) . append ( item . attrib [ "name" ] . lower ( ) ) self . current_context = item . attrib [ "name" ] . lower ( ) elif item . tag . lower ( ) == "declaration" : private_status = False for child in item . iter ( ) : if child . tag . lower ( ) == "access-spec" and child . attrib . get ( "keyword" ) . lower ( ) == "private" : private_status = True if child . tag . lower ( ) == "variable" and private_status : if not self . current_context : self . current_context = self . main if child . attrib . get ( "name" ) : self . private . setdefault ( self . current_context , [ ] ) . append ( child . attrib [ "name" ] . lower ( ) ) elif item . tag . lower ( ) == "use" : only_symbols = [ ] for child in item : if child . tag . lower ( ) == "only" : for innerChild in child : if innerChild . tag . lower ( ) == "name" : only_symbols . append ( innerChild . attrib [ "id" ] . lower ( ) ) if not self . current_context : self . current_context = self . main self . uses . setdefault ( self . current_context , [ ] ) . append ( { item . attrib [ "name" ] . lower ( ) : only_symbols } if only_symbols else { item . attrib [ "name" ] . lower ( ) : [ "*" ] } ) self . populate_symbols ( ) self . populate_symbol_types ( ) self . populate_exports ( ) self . populate_imports ( module_logs ) return True
short_docstring: This function parses the XML tree of a Fortran file and tracks and
  maps relevant object relationships
short_docstring_tokens: This function parses the XML tree of a Fortran file and tracks and maps relevant object relationships
comment: """ This function parses the XML tree of a Fortran file and tracks and
          maps relevant object relationships """$SEP$# Find name of PROGRAM module$SEP$# Get the name of the XML file being parsed$SEP$# This function parses the <declaration> tag of the XML and$SEP$# checks if private variables are defined in the respective$SEP$# module/program. Private variables tend to be inside the$SEP$# declaration tag$SEP$# If a module, program or subroutine uses (imports) another$SEP$# module, a USE statement is used and we want to map the$SEP$# relationship between different program scopes that occur$SEP$# with the use of the USE statement