parameters: (xml)
return_statement: return insns
docstring: Parse udis86 optable.xml file and return list of
             instruction definitions.
docstring_summary: Parse udis86 optable.xml file and return list of
             instruction definitions.
docstring_tokens: Parse udis86 optable . xml file and return list of instruction definitions .
function: def parseOptableXML(xml):
          """Parse udis86 optable.xml file and return list of
             instruction definitions.
          """
          from xml.dom import minidom
  
          xmlDoc = minidom.parse(xml)
          tlNode = xmlDoc.firstChild
          insns  = []
  
          while tlNode and tlNode.localName != "x86optable": 
              tlNode = tlNode.nextSibling
  
          for insnNode in tlNode.childNodes:
              if not insnNode.localName:
                  continue
              if insnNode.localName != "instruction":
                  raise Exception("warning: invalid insn node - %s" % insnNode.localName)
              mnemonic = insnNode.getElementsByTagName('mnemonic')[0].firstChild.data
              vendor, cpuid = '', []
  
              for node in insnNode.childNodes:
                  if node.localName == 'vendor':
                      vendor = node.firstChild.data.split()
                  elif node.localName == 'cpuid':
                      cpuid = node.firstChild.data.split()
  
              for node in insnNode.childNodes:
                  if node.localName == 'def':
                      insnDef = { 'pfx' : [] }
                      for node in node.childNodes:
                          if not node.localName:
                              continue
                          if node.localName in ('pfx', 'opc', 'opr', 'vendor', 'cpuid'):
                              insnDef[node.localName] = node.firstChild.data.split()
                          elif node.localName == 'mode':
                              insnDef['pfx'].extend(node.firstChild.data.split())
                      insns.append({'prefixes' : insnDef.get('pfx', []),
                                    'mnemonic' : mnemonic,
                                    'opcodes'  : insnDef.get('opc', []),
                                    'operands' : insnDef.get('opr', []),
                                    'vendor'   : insnDef.get('vendor', vendor),
                                    'cpuid'    : insnDef.get('cpuid', cpuid)})
          return insns
function_tokens: def parseOptableXML ( xml ) : from xml . dom import minidom xmlDoc = minidom . parse ( xml ) tlNode = xmlDoc . firstChild insns = [ ] while tlNode and tlNode . localName != "x86optable" : tlNode = tlNode . nextSibling for insnNode in tlNode . childNodes : if not insnNode . localName : continue if insnNode . localName != "instruction" : raise Exception ( "warning: invalid insn node - %s" % insnNode . localName ) mnemonic = insnNode . getElementsByTagName ( 'mnemonic' ) [ 0 ] . firstChild . data vendor , cpuid = '' , [ ] for node in insnNode . childNodes : if node . localName == 'vendor' : vendor = node . firstChild . data . split ( ) elif node . localName == 'cpuid' : cpuid = node . firstChild . data . split ( ) for node in insnNode . childNodes : if node . localName == 'def' : insnDef = { 'pfx' : [ ] } for node in node . childNodes : if not node . localName : continue if node . localName in ( 'pfx' , 'opc' , 'opr' , 'vendor' , 'cpuid' ) : insnDef [ node . localName ] = node . firstChild . data . split ( ) elif node . localName == 'mode' : insnDef [ 'pfx' ] . extend ( node . firstChild . data . split ( ) ) insns . append ( { 'prefixes' : insnDef . get ( 'pfx' , [ ] ) , 'mnemonic' : mnemonic , 'opcodes' : insnDef . get ( 'opc' , [ ] ) , 'operands' : insnDef . get ( 'opr' , [ ] ) , 'vendor' : insnDef . get ( 'vendor' , vendor ) , 'cpuid' : insnDef . get ( 'cpuid' , cpuid ) } ) return insns