code: def get_keywords(lexer):
      
      if not hasattr(lexer, 'tokens'):
          return []
      if 'keywords' in lexer.tokens:
          try:
              return lexer.tokens['keywords'][0][0].words
          except:
              pass
      keywords = []
      for vals in lexer.tokens.values():
          for val in vals:
              try:
                  if isinstance(val[0], words):
                      keywords.extend(val[0].words)
                  else:
                      ini_val = val[0]
                      if ')\\b' in val[0] or ')(\\s+)' in val[0]:
                          val = re.sub(r'\\.', '', val[0])
                          val = re.sub(r'[^0-9a-zA-Z|]+', '', val)
                          if '|' in ini_val:
                              keywords.extend(val.split('|'))
                          else:
                              keywords.append(val)
              except Exception:
                  continue
      return keywords
docs: Get the keywords for a given lexer.